i-effect Manual
German English
German English

Create PDF/A compatible PDF with Ghostscript

For the ZUGFeRD conversion, a custom PDF can also be merged with the generated XML file. This PDF must comply with the PDF/A standard.

To create a compatible PDF/A, Ghostscript can be used, which can simply be installed via SSH.

/QOpenSys/pkgs/bin/yum install ghostscript

Furthermore, a color profile is required as an .icc file, which is used during the conversion and embedded in the PDF/A. Any ICC v2 .icc file can be used for this; a suitable source is e.g.: https://github.com/saucecontrol/Compact-ICC-Profiles/blob/master/profiles/AdobeCompat-v2.icc


The installed Ghostscript should be located under "\QOpenSys\pkgs\share\ghostscript\<version>\lib". In this folder there is the file PDFA_def.ps, in which the .icc profile is linked.

In the following example, the .icc profile and PDFA_def.ps were copied into the newly created folder "/home/ieffect/ghostscript/", and the following lines in PDFA_def.ps were adjusted:

% Define an ICC profile :
/ICCProfile (/home/ieffect/data/ghostscript/sRGB-v2.icc) % Customise

In addition, the folders /in and /out were created, and the Ghostscript call was saved in the file ghostscript.sh:

#!/QOpenSys/pkgs/bin/bash

BASE=/home/ieffect/data/ghostscript

# PDF/A-1b erzeugen: i-effect/Mustang (ZUGFeRDExporterFromA1)
# erwartet A-1 und stuft selbst auf PDF/A-3 hoch.
/QOpenSys/pkgs/bin/gs \
  --permit-file-read="$BASE/sRGB-v2.icc" \
  -dPDFA=1 \
  -dBATCH -dNOPAUSE -dNOOUTERSAVE \
  -dPDFACompatibilityPolicy=1 \
  -dEmbedAllFonts=true -dSubsetFonts=true \
  -sDEVICE=pdfwrite \
  -sColorConversionStrategy=RGB \
  -sProcessColorModel=DeviceRGB \
  -sOutputFile="$BASE/out/test_a.pdf" \
  "$BASE/PDFA_def.ps" \
  "$BASE/in/test.pdf" \
  > "$BASE/out/gs-output.log" 2> "$BASE/out/gs-error.log"

  rc=$?
echo "gs exit code: $rc"
exit $rc


This can then be called via QSH or as a server process in i-effect:

QSH CMD('/home/ieffect/data/ghostscript/ghostscript.sh')