# Creating a PDF/A, PDF/X and PDF/UA multistandard compliant thesis or paper

I am writing a thesis/paper. It will be printed, the publisher requires PDF/X format. It will also be distributed (and archived by my university library) online. The library requires PDF/A standard. Last but not least I am for equal opportunity. My document should be accessible to people with disabilities. The PDF/UA standard is a way to document that I made some provisions.

How do I create a single document that complies with all three standards?

I tried to convert my document to PDF/A in Acrobat Pro, then converting it to PDF/X. But the conversion to one standard removes information required by the other.

So I created a custom conversion in Acrobat Preflight that converts to PDF/A and PDF/X at the same time. This does not work either.

I also tried ConTeXt which has fairly good support for tagged PDF. But it does not support more than one standard at once. I am about to give up.

Good news is that it's possible! Theoretically, you could create a tagged PDF with package tagpdf. But the code will be hard to read and you would need a tremendous amount of time to generate the tags in your LaTeX document, similar to writing a HTML document in a text editor.

The easier way is to do the tagging in Acrobat Pro.

Here are the neccessary steps:

### Step 1: Create a PDF with relevant metadata and OutputIntent

Small working example
\documentclass{scrartcl}
\usepackage{lipsum}
\usepackage[pdfa,bookmarks=false]{hyperref}
\usepackage[latin]{babel}
\usepackage{hyperxmp}[2020/03/01]
\usepackage[cmyk,hyperref]{xcolor}
\usepackage{embedfile}

\embedfile[mimetype=application/x-tex,afrelationship=/Source,ucfilespec=\jobname.tex]{\jobname.tex}

% Which paper did the authors have in mind when they created the document?
\immediate\pdfobj stream attr{/N 4} file{PSO_Uncoated_ISO12647_eci.icc}
\edef\iccobj{\the\pdflastobj}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S /GTS_PDFX
/DestOutputProfile \iccobj\space 0 R
/Info(PSO Uncoated ISO12647 (ECI))
/OutputCondition(Offset printing, according to ISO 12647-2:2004/Amd1, OFCOM, paper type 4 = uncoated white, 115 g/m2, tone value increase curves C (CMY) and D (K))
/OutputConditionIdentifier (Uncoated FOGRA47)
/RegistryName(http://www.color.org)
>>
<<
/Type /OutputIntent
/S /GTS_PDFA1
/DestOutputProfile \iccobj\space 0 R
/Info(PSO Uncoated ISO12647 (ECI))
/OutputCondition(Offset printing, according to ISO 12647-2:2004/Amd1, OFCOM, paper type 4 = uncoated white, 115 g/m2, tone value increase curves C (CMY) and D (K))
/OutputConditionIdentifier (Uncoated FOGRA47)
/RegistryName(http://www.color.org)
>> ]
}

\makeatletter
% Bugfix of hyperref to produce CMYK links
\let\HyColor@HyperrefBorderColor\HyColor@XZeroOneThreeFour
\makeatother

\makeatletter
%we need to tell PDF/X the final format of the paper. This needs adjustment if you want graphics on the page border, called bleeding
\@tempdima=0.99626400996264009962\paperwidth
\edef\boxwd{\strip@pt\@tempdima}
\@tempdima=0.99626400996264009962\paperheight
\edef\boxht{\strip@pt\@tempdima}
\makeatother
\edef\next{%
\protect\pdfpageattr{
/TrimBox[0.0 0.0 \boxwd\space \boxht]
}%
}
\next

\hypersetup{%
pdflang={la},
pdftrapped=False,
pdfkeywords={key1,key2},
pdfsubject=text,
pdfaconformance=A,
pdfapart=3,
pdfuapart=1,
pdfversionid=1,
pdfxstandard={PDF/X-4},
pdfdisplaydoctitle=true,
pdfstartpage={},
urlbordercolor=red,
}

\author{anonymus}
\title{Multistandard PDF document}

\begin{document}
\begin{NoHyper} %comment out to produce clickable links

\maketitle

\lipsum

\href{https://tex.stackexchange.com/questions/545903/creating-a-pdf-a-pdf-x-and-pdf-ua-multistandard-compliant-thesis-or-paper}{Stackexchange}

\end{NoHyper}
\end{document}


This intermediate PDF is somewhat dangerous because it claims to be compliant to PDF/A-3a and /UA while it does not. Do not send it to anyone! The sole standard that should validate at this stage is PDF/X-4. There is an OutputIntent for coated paper in the example. Use the appropriate OutputIntent for your printing condition. Ask your print shop/publisher if in doubt.

You can include images but they should be PDFs conforming to PDF/A-Nb and PDF/X. You can achieve this by converting JPG images in Acrobat Pro.

The example above should work with pdfTeX and LuaTeX.

### Step 2: Tag the document

Open the PDF in Acrobat Pro, enable editing and automatically tag your document.

Then, make sure the top tag is of type Document and the first heading is of type H1. Make sure not to skip headings, i.e. after H1 the next heading must be either H1 or H2. At this stage you should also provide meaningful alternative text to your images and links. You can do that in the tags tree.

When you choose to enable editing the PDF Acrobat removed PDF/A metadata. If you would save as PDF/A now Acrobat would remove PDF/X and PDF/UA metadata. So save this code as an .xmp file and append it to your PDF under File->Properties->Additional Metadata->Advanced. I copied the code from my PDF before editing it in Acrobat.

Important: Do not save your PDF at this stage! Acrobat would delete metadata.

### Step 4: Apply a custom conversion in Preflight

Create a new Preflight set. This screenshot shows where to click:
Put the following custom fixups in your profile:
1. Embed fonts (even if text is invisible)
2. Remove CIDset if incomplete
3. Remove XMP Metadata if not compliant
4. Substitute characters using .notdef Glyph
5. Set Trapped key to false

Instead of creating your custom profile you can save this ready made profile as a .kfp file and import it in preflight.

Choose Analyze and fix with your custom profile. By applying a fix Acrobat does not do the secret «optimisations» it would do under Save as. Done!

### Proof

You should check everything worked well. Do the following checks:
1. PDF/A conformance in Preflight
2. PDF/X conformance in Preflight
3. Reflowing in Acrobat (Ctrl+4)
4. Accessibility in PAC3

### A few notes on successful standard combinations

The above example is for PDF/A-3a, PDF/X-4 and PDF/UA. Embedded .tex files only work for PDF/A-3. If you renounce that feature the example could also work with PDF/A-2a or A-1a. You may need additional fixups. On the PDF/X side you could use PDF/X-3 as well. But PDF/X-1a is not recommended together with PDF/A because it forces CMYK conversion of RGB images that may look better on screen. Forget PDF/X-1.

Hyperlinks and even worse bookmarks are forbidden in all current PDF/X. I consider this a bug in the standards since bookmarks can make life easier in prepress. The standards commitee is aware of this but unfortunately they don't send a clear signal that these features will be available in the upcoming PDF/X-6. But you can be bold and knowingly send a PDF/X document with links and bookmarks to the print shop.

• What a pity that this method is manual and requires a commercial and closed tool... May 24, 2020 at 7:03
• It is neither a bug in the standards that pdf/X doesn't allow links nor a bug in hyperref that it doesn't support cmyk for the link color. These are design decisions and missing features that you don't like. May 24, 2020 at 8:47
• @PaulGaborit What a pity that all this standards with the purpose of facilitating graphics exchange (PDF/X) and "archiving and long-term preservation" (PDF/A) are based on closed ISO (speech valid for every standard you have to pay to read...). May 24, 2020 at 8:58
• @UlrikeFischer Feel free to select the term of your choice: Issue, suboptimal design decision, bug … Time is better spent on finding solutions instead of political correct wording. The idea behind PDF/X-3 (every X-3 is also an X-4) is a media neutral workflow. In this regard, to forbid bookmarks and links is a decision not taken to it's full conclusion. The fact that something is likely going to change in X-6 proves me right. May 24, 2020 at 17:25
• @PaulGaborit Feel free to file some pull requests for issues in package accessibility May 24, 2020 at 17:31