0

After normal compiling, I am processing a PDF file with the following ghostscript command in order to produce a (hopefully) PDF/A compliant file.

gs -dPDFA
   -sDEVICE=pdfwrite
   -dPDFACompatibilityPolicy=1
   -dPrinted=false
   -dPDFSETTINGS=/printer
   -dSAFER
   -dNOPAUSE
   -dQUIET
   -dBATCH
   -dNOOUTERSAVE 
   -sColorConversionStrategy=UseDeviceIndependentColor
   -sProcessColorModel=DeviceRGB
   -sOutputFile=thesis.pdf
   main.pdf pdfmarks

This mostly works (I have a working outline in my PDF viewer and hyperlinks also work now), except for one thing. The text is selectable and copyable on almost all pages, except for pages which contain images. It does not matter if the image is another PDF or a PNG. Tikz pictures and MetaFont images are fine, though.

I tried a different PDFSETTINGS, /prepress and in an earlier iteration of this command also without -dSAFER and -dPrinted=false.

The original PDF file is compiled with pdflatex, if it makes any difference.

This question is quite difficult to research, since almost all ghostscript documentation contains the words "text" and "image".

1

I would put my effort in directly creating a PDF/A compliant pdf with pdflatex or lualatex in the first place. This will give you a valid PDF/A directly:

\documentclass{article}

\usepackage[pdfa]{hyperref}
\usepackage{hyperxmp}[2020/03/01]

\author{me,him}
\title{How to create a PDF/A-1b document}

\immediate\pdfobj stream attr{/N 3} file{sRGB.icc}
\pdfcatalog{%
  /OutputIntents [ <<
    /Type /OutputIntent
    /S /GTS_PDFA1
      /DestOutputProfile \the\pdflastobj\space 0 R
    /OutputConditionIdentifier (sRGB IEC61966-2.1)
    /Info(sRGB IEC61966-2.1)
  >> ]
}

\begin{document}

lorem ipsum \url{http://stackexchange.com/}

\end{document}

This example validates in Acrobat DC and verapdf 1.14.8 both when compiled with LuaLaTeX and pdfLaTeX with up to date packages.
Preflight validation result
It looks like Graipher's font setup is dodgy.

If you want to include images later I recommend including pdf that already validate pdf/a. Jpg images with embedded colour profiles can work but some validators request the embedded images metadata to be PDF/A compliant. This is hard to achieve without Acrobat Pro. You would run into that problem also with Ghostscript. PNG do not work because they don't provide embedded colour profiles.

| improve this answer | |
  • I downloaded the colour profile from here and tried compiling it afterwards. It complains that keeppdfinfo is not a valid option for hypersetup. – Graipher Mar 26 at 8:53
  • Without that option it seems to work and produce a PDF/A file, but now the hyperlinks no longer work. Apart from a load of additional packages being loaded, I currently first load hyperxmp and then hyperref, does that make a difference? – Graipher Mar 26 at 9:00
  • And the produced file fails compliance using verapdf with many failures. – Graipher Mar 26 at 9:13
  • keeppdfinfo and hyperlinks: update your package hyperxmp to at least 5.0. Verapdf failures: They come from embedded graphics. Convert them to PDF/A-1b before including them in LaTeX. Flatten Transparency in embedded graphics or use a newer standard such as PDF/A-2b. – tanGIS Apr 9 at 18:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.