Difference between revisions of "PDF/A (LaTeX)"

From Wiki
Jump to navigation Jump to search
Line 61: Line 61:
  
 
= Possibility 3: hyperref & hyperxmp =
 
= Possibility 3: hyperref & hyperxmp =
 
+
Now an example using the <code>hyperref</code> and <code>hyperxmp</code> packages:
 
<syntaxhighlight lang="latex">
 
<syntaxhighlight lang="latex">
 
\documentclass{article}
 
\documentclass{article}
Line 76: Line 76:
  
 
\immediate\pdfobj stream attr{/N 3} file{srgb.icc}
 
\immediate\pdfobj stream attr{/N 3} file{srgb.icc}
\pdfcatalog{%
+
\pdfcatalog{
 
/OutputIntents [
 
/OutputIntents [
 
<<
 
<<
Line 96: Line 96:
 
\end{document}
 
\end{document}
 
</syntaxhighlight>
 
</syntaxhighlight>
 +
Build it with:
 +
* <code>pdflatex test.tex</code>
 +
* <code>lualatex test.tex</code>
  
 
= Validation =
 
= Validation =

Revision as of 16:16, 14 August 2021

Generating a valid PDF/A document with LaTeX is quiet a journey. The success depends on your distribution (TexLive, MikTeX, ...) and your compiler (pdflatex, lualatex, xelatex). Here are some notes to make your live a bit easier.

Prerequisites

Before generating a PDF/A, you'll need an ICC-Profile:

Get the file AdobeRGB1998.icc, put it into your folder and rename it to srgb.icc.

Possibility 1: Ghostscript

The easiest way is to compile your LaTeX document normally and than rework it with Ghostscript. Let's say you have a file called thesis.pdf and you want to convert it into a PDF/A conform file thesis-a.pdf with metadata (like author). First create a file called pdfmarks.txt, which includes the metadata:

[ /Title (document title)
  /Author (author name)
  /Subject (subject description)
  /Keywords (keyword1, keyword2, keywordX)
  /ModDate (D:20210814112233)
  /CreationDate (D:20210814112233)
  /Creator (application name or creator note)
  /Producer (PDF producer name or note)
  /DOCINFO pdfmark

Now it is time to convert your file, this example is executed on a Windows system using PowerShell:

gswin64c -q -dNOSAFER -dPDFA=3 -dBATCH -dNOPAUSE -dNOOUTERSAVE -dPDFSETTINGS=/prepress `
    -sColorConversionStrategy=RGB `
    -sProcessColorModel=DeviceRGB `
    -sDEVICE=pdfwrite `
    -dPDFACompatibilityPolicy=1 `
    -sOutputFile="thesis-a.pdf" "PDFA_def.ps" "thesis.pdf" "pdfmarks.txt"

The file PDFA_def.ps comes with Ghostscript. There might be some errors because Ghostscript has to remove some things, but the result should be a valid PDF/A-3B document.

Possibility 2: pdfx

A simple example (pdfx.tex):

\documentclass{article}

\usepackage{lipsum}
\usepackage[a-3b]{pdfx}

\title{Creating valid PDF/A files with \LaTeX}
\author{Me}

\begin{document}
\maketitle
\lipsum[1-2]
\end{document}

You may build the document with:

  • pdflatex pdfx.tex
  • xelatex -shell-escape pdfx.tex

Possibility 3: hyperref & hyperxmp

Now an example using the hyperref and hyperxmp packages:

\documentclass{article}

\usepackage{lipsum}
\usepackage[pdfa]{hyperref}
\usepackage{hyperxmp}

\hypersetup{
	pdflang=en,
	pdfapart=3,
	pdfaconformance=B
}

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

\title{Creating valid PDF/A files with \LaTeX}
\author{Me}

\begin{document}
\maketitle
\lipsum[1-2]
\end{document}

Build it with:

  • pdflatex test.tex
  • lualatex test.tex

Validation