Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use ghostscript to convert PDF to PDF/A or PDF/X?

Is there a way to use ghostscript to convert PDF to PDF/A or PDF/X? I know it can be used to convert PDF to images, but I don't know if it can be used to convert PDF/A. What parameters should I use?

like image 758
imgen Avatar asked Nov 02 '09 02:11

imgen


People also ask

How do I change a PDF from X to PDF?

With your PDF open in Acrobat: Go to your Tools: Print Production-> Preflight -> Options ->Convert Current PDF to PDF/X • Select the "Convert to PDF/X-1a" option and hit “Analyze and Fix” • You will receive a report indicating that your PDF was created successfully and that there were no issues encountered.

Can Ghostscript edit PDF?

This paper intends to introduce some of the ways the Ghostscript tools can be used to manipulate a PDF file, including creation of bookmarks, annotations, and setting document properties.

How do I automate a PDF conversion?

Open the PDF Converter Settings panel from Start > Programs > AssistMyTeam PDF Converter for Windows. Alternatively, invoke it from the context menu of Windows Explorer. From the Settings panel, go to Auto PDF tab and check 'Enable Automation' option.

What can I do with Ghostscript?

Ghostscript can be used as a raster image processor (RIP) for raster computer printers—for instance, as an input filter of line printer daemon—or as the RIP engine behind PostScript and PDF viewers. It can also be used as a file format converter, such as PostScript to PDF converter.


2 Answers

This is to convert a pdf document (not pdf/a) into pdf/a: gs -dPDFA -dBATCH -dNOPAUSE -dUseCIEColor -sProcessColorModel=DeviceCMYK -sDEVICE=pdfwrite -sPDFACompatibilityPolicy=1 -sOutputFile=output_filename.pdf input_filename.pdf

Hope this will help some one!

like image 90
Artur Avatar answered Sep 19 '22 14:09

Artur


Hope this answer helps others coming from Google with the same problem:

To convert from PDF to PDFA-1b or PDFA-2b, you can use Ghostscript. I suggest you use the latest version (9.19 today).

Install it

In Mac OS, you may prefer to use Homebrew:

brew install ghostscript 

In Linux, some distros bring a much older version (rhel7 sports 9.07). To download a fully independent modern one-file-only ghostscript, download it directly from the site:

wget https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs919/ghostscript-9.19-linux-x86_64.tgz 

If the link above is broken when you try it 20 years from now, please refer to ghostscript.com and search for download section. Download the binary version, don't go for the source, unless you know what you are doing.

In Windows, I cannot help you, but if you manage to install it, the following commands will also work, if you substitute the location of files and gs executable.

Command line

gs-919-linux_x86_64 -dPDFA=1 -dNOOUTERSAVE -sProcessColorModel=DeviceRGB -sDEVICE=pdfwrite -o output_file.pdf /path/to/PDFA_def.ps -dPDFACompatibilityPolicy=1 input_file.pdf 

In Mac gs-919-linux_x86_64 will be simply gs.

Please note that output_file.pdf and input_file.pdf must be changed to the names of the output file (the converted file) and the input file (the file to be converted). /path/to/PDFA_def.ps is your copy of the file PDFA_def.ps.

-dPDFA=1 is for PDFA-1b.

-dPDFA=2 if you want PDFA-2b.

What is PDFA_def.ps?

PDFA_def.ps is some sort of template ghostscript uses to create a PDFA file. The tricky part is that, for some reason, ghostcript comes with a non-working file.

You'll need to edit PDFA_def.ps and include the path to a valid ICC (color profile) file. Download a good color profile from Adobe:

wget http://tutankhamon.acc.umu.se/mirror/archive/ftp.sunet.se/pub/vendor/adobe/adobe/iccprofiles/win/

Inside that zip, find a file called AdobeRGB1998.icc, put it somewhere and put the path to that file INSIDE you PDFA_def.ps file.

Here is a version of PDFA_def.ps, change PATH_TO_YOUR_ICC_FILE to the path of you AdobeRGB1998.icc.

https://gist.githubusercontent.com/weltonrodrigo/19df77833f023fbe1572168982e4b515/raw/ea86e87379d14120d7ff26f6f235ac7eeb5f5dd5/PDFA_def.ps

like image 30
motobói Avatar answered Sep 19 '22 14:09

motobói