# pdfx package fails with veraPDF and preflight does not support special characters (UTF-8 not used) and

I finished (after a lot of work) my Ph.D. thesis in LaTeX. However, I got a big problem after I read that I have to submit the PDF as PDF/A file. First of all I tried to convert it by using the Acrobat Professional Software (the IT did it) but we failed. So I went a step back and tried to build the PDF/A file via LaTeX and came across the package pdfx. While using this package, I cannot use the usepackage[utf8]{inputenc} based on the fact that it is a dependency of the pdfx package. However, after changing a few own commands and other math operators such as \bullet, which are already in use or do not exist anymore, I got the the problem that the umlaut ä ü ö ß are not working anymore.

Update this problem was related to a non-updated version of pdfx package. After the update, the \usepackage[utf8]{inputenc} can be used and everything works fine.

The second problem is that the generated pdf is not PDF/A conform. preflight and veraPDF gave a bunch of errors that I cannot handle. Any ideas.

I hope that someone can give me some advice.

• Since you have IT support with Acrobat Pro: Forget pdfx package. Re-compile your TeX using lualatex. You need to \usepackage{fontenc} and load fonts by the methods described in that package doc. You will also need to remove inputenc and fontenc because 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. – user139954 Feb 20 '18 at 16:57
• What is the problem if you activate inputenc? It works fine for me (in both locations). – Ulrike Fischer Feb 20 '18 at 23:17
• Is your system uptodate? What is the version of pdfx? – Ulrike Fischer Feb 21 '18 at 7:53
• I tried out veraPDF a few weeks ago because of another question, (tex.stackexchange.com/questions/402431/…) and it complained about things where Adobe preflight didn't. I also had the impression that veraPDF is still under development. So I would check with adobe pro too. – Ulrike Fischer Feb 21 '18 at 9:37
• Just want to update. I reduced a lot of errors in my PDFA while hacking the pdfx package. 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. The verapdf is more strict than the one of adobe. – Tobi Feb 21 '18 at 16:34

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}
\Author{Tobias Holzmann\sep And Others}
\Keywords{Your\sep Keywords\sep}
\Publisher{...}
\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
\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
\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 ...
\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.de/forums/pdfx.sty

• Just FYI: PDF/A (unlike PDF/X) requires actual space character between words. Compiler pdflatex can do PDF/A, and can do PDF/X,, but cannot easily do utf-8, or use Open Type fonts. Compiler LuaLaTeX can do utf-8 and PDF/X, but not PDF/A (no actual spaces). Compiler XeTeX can do utf-8 and PDF/A with issues, but not PDF/X. That's AFAIK. – user139954 Feb 21 '18 at 22:45
• One other thing: It's nice to see someone who is writing a dissertation, and who is willing to investigate TeX problems. Too often, dissertation writers visit here, with obvious questions they could have answered themselves, or they simply give up when the answer might be complicated. Makes me wonder how they manage to get their Ph.D.s. – user139954 Feb 21 '18 at 22:50
• @RobtAll Possibly their PhDs are not on the topic of LaTeX? – cfr Feb 22 '18 at 3:26
• @cfr No doubt. But often, they are working with TeX templates required by their university, or by some academic publisher. You'd think those things would be routine by now. – user139954 Feb 22 '18 at 5:33
• Hi, I am in contact with the pdfx editors, just if you are interested. If I will get some new information I will let you know. Right now we exchange the problematic. By the way, most of the people I know - here - do not care about the style of the Ph.D. at all. They write in word 12pt double spacing (looks incredible) and get 100 pages easily. In addition, graphics have 72 dpi, plots are not vectorized etc. I care about that and I like to share my experience; hopefully in order to help others. – Tobi Feb 22 '18 at 9:39