Update: Patch for pdfx added at the bottom (23.02.2018)
Today I made some investigation into the topic of PDF/A file generation with LaTeX and the pdfx package and figured out the solution. Actually I will present two versions and the validation check by using the veraPDF application. Okay lets start. The easiest way is to use Acrobat Professional (if it is available).
Using Acrobat Professional
- Compile your LaTeX file as it is into a PDF
- Open the PDF on the computer with the installed Adobe software
- Print the file by using the
Adobe PDF printer and choose the PDF/A option
- Check with
veraPDF or preflight -> valid
- Done & happy
In my case I could not convert it directly because I got some errors. I have no idea why but the only possible way was the above mentioned one.
Using pdfx package in LaTeX
- Be sure to have the latest
pdfx package available. For that purpose you can simple use the kpsewhere pdfx.sty function in Linux to get the path to the file and check the version (open it with an editor). In my case I had an older package and had to update the package (https://ctan.org/pkg/pdfx?lang=en)
- All information are provided in the documentation as well as further thinks such as
how to add the meta keywords.
For example, I added a new file at the first position using the inputfunction (attention: before the document class definition).
\input{Pre/Pre_MetaData}
\documentclass[...]
\input{Pre/Pre_Packages}
\input{Pre/Pre_Settings}
while in the Pre_MetaData file one will find this kind of code (which can be extended according to the documentation of the pdfx package:
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
\begin{filecontents*}{\jobname.xmpdata}
\Title{Your Title of the work}
\Author{Tobias Holzmann\sep And Others}
\Keywords{Your\sep Keywords\sep}
\Publisher{...}
\Copyright{...}
\end{filecontents*}
% % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %
If one is using the pdfx package at the end of the work (I mean you wrote a book or thesis and realize that you have to build a PDF/A file), it can happen that you have to make a workaround of own generated commands. So I recommend to everybody who directly knows that it has to be a PDF/A file, directly start including the pdfx package. In addition - as it is stated in the documentation - it is a good idea to load that package at first position. After that, you can re-compile the document and the PDF/A pdf is generated. Summing up:
- Ensure that you have the latest
pdfx package installed
- Include the meta data right at the beginning (before the document class starts)
- Include the
pdfx package at the first place (also read the dependency list: e.g. the hyperref package does not have to be included by the user anymore because pdfx is loading it...)
- Add the color scheme to your LaTeX project (you will find one in the source files or here http://www.color.org/iccprofile.xalter)
- Remove problems of own defined commands (if ever)
- Compile it with pdflatex (I did it in that way)
- Check it with
veraPDF and you will probably see a bunch of errors which are summed up and resolved below
- If everything is fine you are done, congrats :)
Errors with veraPDF and pdfx
I realized that while using the first method (Acrobat Pro), preflight and veraPDF gave me a valid PDF/A result while with LaTeX and the pdfx package I failed a lot of checks. However, this told me that there are some problems with the pdfx package or in general with the PDF written by LaTeX.
I got a range of error messages during the verification of the PDF/A file generated by LaTeX by using veraPDF and preflight. At the beginning I had more than half million failed checks ~ 543.000. Most of the errors were related to a non-included color scheme (point #4 in the list above). This can be easily resolved by adding the color scheme and done.
Another bunch of errors were tricky to figure out and were related to transparency figures and other features which (now I know it) are not supported by the pdf version 1.4. In my LaTeX project, there are more than 50 eps files that are converted to pdfs by using the epstopdf package. Here the problem starts with pdfx based on a problem that is introduced by that package. I guess it is a bug and I sent already a message to the creators.
- In any case the
pdfx package will set the pdf version we create to the version 1.4 which is correct for the PDF/A-1 standard published 2005; cf. ISO 190005-1 (https://en.wikipedia.org/wiki/PDF/A).
- However, any setting/option one will set for the
pdfx package will lead to a pdf version 1.4. Even if a specification of PDF/A-2 is done. This should give in fact a pdf version 1.7.
- And here the problem starts because the
epstopdf generates pdf's which are of pdf version 1.5 while the LaTeX document will be in version 1.4. This is not compatible and the graphic pdfs of version 1.5 do have features that are not supported in version 1.4
- This discrepancy in versions lead to a lot of errors in
veraPDF with opacity and transparency of figures especially with the ca value etc. (https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Part-1-rules)
By the way, you can figure out the version of a pdf in Linux by using the pdfinfo myPDF.pdf command.
In order to get rid of the problem, one has to hack the pdfx package to set the correct version for the pdf. To do so, one has to find the path to the pdfx.sty file by using kpsewhere pdfx.sty again and open it by using an editor one likes (sudo it):
sudo vim /usr/share/texlive/texmf-dist/tex/latex/pdfx/pdfx.sty
Search for that comment - line 750 (in version v1.5.84)
%% Hyperref options for PDF/A and PDF/E
And add, after the hyperref stuff, the following line while changing the version according to the version you would like to have for your pdf.
\thepdfminorversion=6 % Corresponds to version 1.6
In order to give a better statement of the position in my case I added it to line 815:
\ifpdfx@x
\@ifpackageloaded{hyperref}{%
\ifxetex
\expandafter\hypersetup\expandafter{\pdfx@pdfX@opts@xetex}
\else\ifluatex
\expandafter\hypersetup\expandafter{\pdfx@pdfX@opts@luatex}
\else
\expandafter\hypersetup\expandafter{\pdfx@pdfX@opts@pdftex}
\fi\fi
}{%
\ifxetex
\expandafter\RequirePackage\expandafter[\pdfx@pdfX@opts@xetex]{hyperref}
\else\ifluatex
\expandafter\RequirePackage\expandafter[\pdfx@pdfX@opts@luatex]{hyperref}
\else
\expandafter\RequirePackage\expandafter[\pdfx@pdfX@opts@pdftex]{hyperref}
\fi\fi
}%
\else
\ifpdfx@e
\@ifpackageloaded{hyperref}{%
\ifxetex
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@xetex}
\else\ifluatex
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@luatex}
\else
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@pdftex}
\fi\fi
}{%
\ifxetex
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@xetex]{hyperref}
\else\ifluatex
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@luatex]{hyperref}
\else
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@pdftex]{hyperref}
\fi\fi
}%
\else % generating PDF/A or ...
\@ifpackageloaded{hyperref}{%
\ifxetex
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@xetex}%
\else\ifluatex
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@luatex}%
\else
\expandafter\hypersetup\expandafter{\pdfx@pdfAE@opts@pdftex}%
\fi\fi
}{%
\ifxetex
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@xetex]{hyperref}
\else\ifluatex
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@luatex]{hyperref}
\else
\expandafter\RequirePackage\expandafter[\pdfx@pdfAE@opts@pdftex]{hyperref}
\fi\fi
}%
\fi\fi
\hypersetup{pdfencoding=auto}% unicode
\expandafter\ifx\csname KV@Hyp@psdextra\endcsname\relax\else
\hypersetup{psdextra}
\fi
\thepdfminorversion=6 % Corresponds to version 1.6
After that save the file and update the TeX environment: sudo texhash. Done. Now recompile your pdf and you will get the pdf version you need (use pdfinfo to check it). After re-checking the pdf by using Acrobat Pro -> preflight the PDF/A file was valid and I was happy. For the veraPDF tool, I still get 1 error that is related to font programs Rule 6.3.4-1 (https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Part-1-rules#rule-634-1) but I have no idea what it tells me. Any comment is welcomed here.

pdfx package
During my investigation into the pdfx package I realized that the authors have a bunch of possible options which are not listed in the documentation. However, the options do not influence anything (as far as I got it); e.g. the pdf16 option which should change the pdf version to 1.6. However, I realized that the hyperref code snipped, which is given above, is the part in which the variable \thepdfminorversion is changed to 4 in any case. I wrote it to the creators and hope to get some feedback - maybe one of you is interested too and can figure out more (I am not too familiar with the LaTeX syntax).
veraPDF
Just a few notes to the veraPDF application.
I got the idea with the PDF version based on the output of preflight -> wrong PDF version and LaTeX which stated some version 1.4 and 1.5 things with my pictures.
Sorry that it is now a long answer but maybe someone can get some new information out of that and can solve the problem. If I will get any feedback from the creators, I will make a comment
Finally: pdfx works very well now for my Ph.D. thesis. Thanks for the comments and of course, if you use lualatex I guess you can use the way RobtAll was explaining. Great forum, great people! Thanks Tobi
pdfx patch
Right now I am in contact with Ross Moore and he sent me some patch which is more appropriate than my fix. It is not updated to the official repository right now so I share it here.
https://Holzmann-cfd.com/forums/pdfx.sty
pdfxpackage. Re-compile your TeX usinglualatex. You need to\usepackage{fontenc}and load fonts by the methods described in that package doc. You will also need to removeinputencandfontencbecause you will automatically be using UTF-8. If you can get it to compile and it looks good, then have IT convert to PDF/A using Acrobat Pro. At most you can get A-1b (not A-1a), after allowing the program to automatically add tags. Whether this method is an easy deal, or hard work, depends more on your use of fonts than on anything else. – Feb 20 '18 at 16:57fontspecandlualatex. I will check out the package andlualatexnow. @Ulrike Fischer, if I activate theinputencafterpdfxI get a clash error. – Tobi Feb 21 '18 at 06:21inputencbeforepdfx, everything compiles well and looks fine. However, theverapdfvalidator tells me that it is notA-1bconform.fontspecwithxelatexgives me a bunch of error (just tried based on the fact that I saw that it works withfontspectoo). I will check outlualatexduring the day. By the way. It is my Ph.D. thesis and I hope that I do not have to change tooooo much in any case. – Tobi Feb 21 '18 at 06:51inputencpackage. I also reduced my > 500.000 validation failed checks to 98 now. I think I am on the right way but I have to figure out how to deal with the other things. Aspdffontstell me, all fonts are embedded but I still get an error during validation by usingverapdf(https://github.com/veraPDF/veraPDF-validation-profiles/wiki/PDFA-Part-1-rules#rule-634-1) I will try to fix everything today. If it is not working, I trylualatexbut I guess I got other problems then. – Tobi Feb 21 '18 at 09:02pdfxpackage. There is only one problem that I am trying to resolve and after that I will make a summary and the workaround I did to get it work. By the way, you are right. Theverapdfis more strict than the one of adobe. – Tobi Feb 21 '18 at 16:34