Giter Site home page Giter Site logo

miyako / 4d-plugin-factur-x Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 0.0 489.88 MB

Convert PDF to PDF/A-3. combine XML and PDF to generate Factur-X.

License: MIT License

C 47.52% C++ 10.03% Objective-C 0.10% 4D 1.44% XSLT 40.92%
4d-plugin 4d-plugin-apple-silicon factur-x pdf

4d-plugin-factur-x's Introduction

version platform license downloads

4d-plugin-factur-x

Convert PDF to PDF/A-3. combine XML and PDF to generate Factur-X.

PDF/A

first step is to create a PDF/A document.

if you don't care why we need this, jump to Factur-X

Validator

  1. install OpenJDK

https://formulae.brew.sh/cask/temurin

brew install --cask temurin
  1. install VeraPDF

https://docs.verapdf.org/install/

Validate 4D print to PDF

VeraPDF validation reports failure in 2 domains.

  • ISO 19005-1:[email protected]: The document catalog dictionary of a conforming file shall contain the Metadata key.

  • ISO 19005-1:[email protected]: If a document information dictionary does appear at a document, then all of its entries that have analogous properties in predefined XMP schemas, shall also be embedded in the file in XMP form with equivalent values.

we are not using any banned features, at the same time, we have no metadata. the PDF is too basic.

PDF→PDF/A

use GhostScript to prepare PDF for archive.

$error:=PDF TO PDFA($input; $output)

Note: warning message

Use of -dUseCIEColor detected!
Since the release of version 9.11 of Ghostscript we recommend you do not set
-dUseCIEColor with the pdfwrite/ps2write device family.

Factur-X

next step is to extract, edit and embed XML in PDF.

if you don't care how it works, jump to Distribution

pip3 install -U factur-x 
pip3 install -U pyinstaller
cd /opt/homebrew/bin

or

cd /usr/local/bin
pyinstaller facturx-pdfextractxml
pyinstaller facturx-pdfgen
pyinstaller facturx-webservice 
pyinstaller facturx-xmlcheck
$status:=PDFA GET XML($inPDF; $outXML)
$status:=PDFA SET XML($inPDF; $inXML; $outPDF{; $attachments})
  • "GET" internally calls facturx-pdfextractxml
  • "SET" internally calls facturx-pdfgen

Distribtution

a very large plugin.

contains python for Apple Silicon and Intel and Windows 64-bit. contains factur-x and all its dependencies such as PyPDF4, lxml. also contains ghostscript for Apple Silicon and Intel and Windows 64-bit.

Examples

/*
	
	generate electronic invoice data (XML)
	
*/

$invoice:=InvoiceExample
$template:=Folder(fk resources folder).file("template.xml")
$data:=toXML($invoice; $template)
$XML:=Folder(Temporary folder; fk platform path).file("data.xml")
$XML.setText($data)

/*
	
	generate PDF using native printing commands (result is not PDF/A)
	
*/

$PDF:=toPDF("TEST")

/*
	
	convert to PDF/A; internally using ghostscript
	
*/

$PDFA:=Folder(Temporary folder; fk platform path).file("TEST.pdf")
$error:=PDF TO PDFA($PDF.path; $PDFA.path)

/*
	
	convert to Factur-X internally using python
	
*/

If ($error=0)
	
	$output:=Folder(fk desktop folder).file("TEST.pdf")
	
	If ($output.exists)
		$output.delete()  //library will not overwrite existing file
	End if 
	
	$status:=PDFA SET XML($PDFA.path; $XML.path; $output.path)
	$info:=Split string($status.info; "\n")
	
	If ($status.success)
		SHOW ON DISK($output.platformPath)
	End if 
	
End if

Validate

スクリーンショット 2022-08-07 0 39 55

Note for Windows

  • pip3 install -U factur-x might fail because of hard-coded folder separators in MANIFEST.in. download the repo, edit the file and pip on a local path.

  • some XSD files have extra long names. see Maximum Path Length Limitation

4d-plugin-factur-x's People

Contributors

miyako avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.