16

I'd like to produce a PDF/A-1b compliant document. To validate it, I installed veraPDF.

There are several really good answers about producing PDF/A, see here: https://tex.stackexchange.com/a/349521/4736 and https://tex.stackexchange.com/a/295137/4736 by @Leonid.


EDIT:

I can produce a validated, PDF/A-1B conform PDF using the LuaLaTeX engine, see the example at the end of this question. But I'd like to stick to pdfTeX for the time being, because it is a lot faster than LuaLaTeX.


I produced a pdf file based on the MWE printed below using pdfLaTeX.

The validation tells me, there are two kinds of issues with the PDF, I'm copying from the validation report:

Rule Status Specification: ISO 19005-1:2005, Clause: 6.3.6, Test number: 1
For every font embedded in a conforming file and used for rendering, the glyph width information in the font dictionary and in the embedded font program shall be consistent. Failed 6 occurrences Hide Glyph
renderingMode == 3 || isWidthConsistent == null || isWidthConsistent == true

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[11]/usedGlyphs3(FVQJUG+LinBiolinumB 115 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[31]/usedGlyphs2(YKWZWP+LinBiolinum 110 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[31]/usedGlyphs[5](YKWZWP+LinBiolinum 111 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[34]/usedGlyphs1(WJGWGZ+LinBiolinumI 117 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[19]/usedGlyphs[6](JSDWAF+LinLibertineI 99 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[34]/usedGlyphs[0](WJGWGZ+LinBiolinumI 97 0)

Specification: ISO 19005-1:2005, Clause: 6.3.5, Test number: 1
Embedded font programs shall define all font glyphs referenced for rendering with conforming file. Failed 6 occurrences
Hide Glyph
renderingMode == 3 || isGlyphPresent == null || isGlyphPresent == true
root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[11]/usedGlyphs3(FVQJUG+LinBiolinumB 115 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[19]/usedGlyphs[6](JSDWAF+LinLibertineI 99 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[34]/usedGlyphs1(WJGWGZ+LinBiolinumI 117 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[31]/usedGlyphs2(YKWZWP+LinBiolinum 110 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[31]/usedGlyphs[5](YKWZWP+LinBiolinum 111 0)

root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[34]/usedGlyphs[0](WJGWGZ+LinBiolinumI 97 0)

How can I find out, which glyphs the validation refers to? Which glyph is »LinBiolinumI 97 0«?

Here my (stolen -- steal proudly!) MWE for pdfLaTeX:

\documentclass[ngerman]{scrartcl}
\pdfminorversion 4
\pdfcompresslevel=0
\immediate\pdfobj stream attr{/N 4} file{coated_FOGRA39L_argl.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>> ]
}
\usepackage[cmyk]{xcolor}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa]{hyperref}
\hypersetup{%
  colorlinks = true,
    pdfauthor          = {a},
    pdfkeywords        = {a, b, c},
    pdflang            = {en},
    pdftitle           = {a},
    pdfsubject         = {a},
  pdfcaptionwriter   = {a},
  pdfcontactaddress  = {a},
  pdfcontactcity     = {a},
  pdfcontactcountry  = {a},
  pdfcontactemail    = {a},
  pdfcopyright       = {a},
  pdfmetalang        = {en},
}

\makeatletter
% Dirty hack of hyperref to make rgb-like links annotated with C mark become annotated with K mark to work in PDF/A with CMYK
% makeatletter - makeatother needed
\usepackage{etoolbox}
\patchcmd{\hyper@linkfile}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkurl}{/C[}{/K[}{}{}
\patchcmd{\find@pdflink}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkstart}{/C[}{/K[}{}{}
\makeatother

\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{babel}
\usepackage{libertine}
\begin{document}
\section{Erster Abschnitt}
\label{CLA:erster-abschnitt}

Ein Text mit \emph{Auszeichnung} und sogar \textbf{fettem} Text, sogar {\sffamily{}
  LinBiolium als Schrift \emph{auch noch hervorgehoben}}. 


\end{document}

I found a discussion with similiar topic in a German forum, but the question has not been answered there.

And by the way: if I use the pdfx package, I get more or less the same validation issues, but unfortunately plus an issue with color.


EDIT

Thanks to a comment I tested succesfully using the LuaLaTeX engine. The following example led to a validated PDF/A-1B pdf:

\RequirePackage{luatex85}
\documentclass[ngerman]{scrartcl}
\pdfminorversion 4
\pdfcompresslevel=0
\immediate\pdfobj stream attr{/N 4} file{coated_FOGRA39L_argl.icc}
\pdfcatalog{%
/OutputIntents [ <<
/Type /OutputIntent
/S/GTS_PDFA1
/DestOutputProfile \the\pdflastobj\space 0 R
/OutputConditionIdentifier (Coated FOGRA39)
/Info(FOGRA39L)
>> ]
}
\usepackage[cmyk]{xcolor}
\usepackage{etoolbox}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\setsansfont{Linux Biolinum O}
% % \usepackage[T1]{fontenc}
% % \usepackage[utf8]{inputenc}
% \usepackage{babel}
\usepackage{libertine}
\usepackage{hyperxmp}
\usepackage[pdftex, pdfa]{hyperref}
\hypersetup{%
  colorlinks = true,
    pdfauthor          = {a},
    pdfkeywords        = {a, b, c},
    pdflang            = {en},
    pdftitle           = {a},
    pdfsubject         = {a},
  pdfcaptionwriter   = {a},
  pdfcontactaddress  = {a},
  pdfcontactcity     = {a},
  pdfcontactcountry  = {a},
  pdfcontactemail    = {a},
  pdfcopyright       = {a},
  pdfmetalang        = {en},
}

\makeatletter
% Dirty hack of hyperref to make rgb-like links annotated with C mark become annotated with K mark to work in PDF/A with CMYK
% makeatletter - makeatother needed

\patchcmd{\hyper@linkfile}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkurl}{/C[}{/K[}{}{}
\patchcmd{\find@pdflink}{/C[}{/K[}{}{}
\patchcmd{\hyper@linkstart}{/C[}{/K[}{}{}
\makeatother


\begin{document}
\section{Erster Abschnitt}
\label{CLA:erster-abschnitt}

Ein Text mit \emph{Auszeichnung} und sogar \textbf{fettem} Text, sogar {\sffamily{}
  LinBiolium als Schrift \emph{auch noch hervorgehoben}}. 


\end{document}

Which is usefull, but I'd really appreciate a solution for pdfLaTeX!

  • Is the problem specific to these fonts? If you run with CM or LM, does it validate? Note that hyperref should be loaded last excepting known exceptions (e.g. cleveref). Also \sffamily doesn't take an argument. Are you trying to insert an extra space or something? – cfr Jan 10 '18 at 1:15
  • @cfr Same kind of error messages with \usepackage{lmodern} instead of libertine, more of the kind root/document[0]/pages[0](7 0 obj PDPage)/contentStream[0](10 0 obj PDContentStream)/operators[45]/font[0](ZTXVEC+LMRoman10-Regular). I moved every \usepackage before hyperref. – Keks Dose Jan 10 '18 at 8:19
  • I know very little about fontenc, but I wonder: Have you tried compiling your document in pdflatex, using the LY1 encoding? Looking at the validation results, it seems that the offending characters are from the upper range of Latin-1. I believe that LY1 (texnansi) maps these correctly. But again, that's a guess. – user139954 Jan 10 '18 at 15:22
  • I compiled your example and checked with with Adobe Pro/preflight and it claims that there are no problems, the document is pdf/a-1b. – Ulrike Fischer Jan 12 '18 at 17:28
  • @UlrikeFischer Thank you, Ulrike. Trouble seems to be that different »validators« deliver different results. PDFBox (preflight app) either crashes or has issues. VeraPDF gives the list printed above. There is a real issue behind my question: German jurisdiction will switch from paper to PDF without such a thing as educating judges and lawyers about all the funny things JavaScript embedded in a PDF can do. There is a halfhearted attempt to make PDF/A-1B compulsory. But as far as I can see, you'd even had to regulate the validation software... – Keks Dose Jan 17 '18 at 16:33
6
+25

The pdfathesis package seems to fare better:

\documentclass[ngerman]{scrartcl}
\usepackage{pdfathesis}
% \usepackage[withhyperref]{pdfathesis}  %% if hyperlinks are needed in the doc

\usepackage[T1]{fontenc}
% \usepackage[utf8]{inputenc} % pdfathesis already sets it to utf8
\usepackage{babel}
\usepackage{libertine}
\begin{document}
\section{Erster Abschnitt}
\label{CLA:erster-abschnitt}

Ein Text mit \emph{Auszeichnung} und sogar \textbf{fettem} Text, sogar {\sffamily{}
  LinBiolium als Schrift \emph{auch noch hervorgehoben}}.

\end{document}

After compiling this with pdflatex, you'll see a newly generated .sh file for post-processing the PDF with GhostScript which helps with the fonts. Running that .sh file will produce a xxx-PDFA.pdf output, which veraPDF validated to be PDF/A-1b for me.

  • 2
    Very interesting answer! I never heard of pdfathesis. Thank you very much. Two issues: The source of pdfathesis includes macros like \Degree, which aren't usefull outside academics. So a package to »universalise« the pdfathesis is needed, with lines like (just guessing) \renewcommand{\Degree}{}. Well, and then I have to find out, how to use it under Windows without a Linux box, the equivalent of the Linux call sh mythesis.sh to invoke Ghostscript. Maintaining a running Cygwin on Windows seems kind of out of proportion. – Keks Dose Jan 10 '18 at 10:08
  • \Degree{} would do for now; that keeps the metadata a bit cleaner too. But yes I agree that some conditional definition would be useful here, i.e. if no \Degree{...} etc is specified, then leave the DocumentType etc metadata out of it. – LianTze Lim Jan 10 '18 at 15:20
  • By far this is the easiest way to create a pdfa-compliant document (in Linux, that is). – Joseph Oct 3 '18 at 19:17
5

I can only provide some assistance; it may not be what you need.

Get the FontForge program. Open the offending font. I just did this with the Open Type Linux Biolinum Regular, LinBiolinum_R.otf (fresh from CTAN).

In the menu, Encoding > Reencode > Glyph Order. This shows the glyphs in the order they were created by the designer, rather than in the encoding (utf) order.

In this font, glyph 970 is Cyrillic small letter GJE, also known as afii10100. It is at Unicode location 0453.

EDIT: Actually, you asked about glyph 97 0, rather than 970. SEE BELOW.

Now, there are many possibilities (for 970, not 97). One is that TeX re-orders the glyphs when embedding subsets, in which case the above information is meaningless. Another possibility is that the validator program is unhappy with the afii10100 glyph name, and would prefer uni0453 or some similar syntax.

If the second case, you could edit the glyph names in FontForge. Right-click the glyph, Glyph Info > set from value. Do that where necessary, then File > Generate Fonts to Open Type. Don't worry about validation complaints; the problems observed (in this font) are very technical and will not affect you.

The third possibility is that uni0453 is not declared as a Unicode character, so you have to add it:

\DeclareUnicodeCharacter{0453}{uni0453} % or maybe afii10100

I doubt that the Unicode declaration is the problem, nowadays.

EDIT: I misread the 97 0 as 970, when I first replied. As for glyph 97:

In this font, glyph 97 is the inverted exclamation mark, name exclamdown, uni00a1. That is a standard name and Unicode location. If you are compiling with a Unicode-aware compiler, such as LuaTeX or XeTeX, and also using the Open Type font, then there should not be a problem. But if nevertheless there is a problem, then something needs to be done about that by the TeX experts (I am not one of them).

If you compiled with pdflatex, it is possible that fontenc assigned the glyph to an unexpected code slot. In this case, a different (or custom) TeX encoding might help. But it is easier to switch compilers.

Anyway, that's all I know.

  • fontenc cannot do that. It does not assign glyphs to code slots. It just makes a particular (output) encoding active. Which glyph is in which slot (in this sense) for the activated encoding is determined by the TFM and, possibly, VF files, combined with the mapping information from the relevant .map files (which may specify a reencoding). – cfr Jan 10 '18 at 1:10
  • @cfr Ah, I keep forgetting that fontenc exists. I use only LuaLaTeX. But as I wrote, that's all I know. – user139954 Jan 10 '18 at 2:44
  • But you talk about fontenc, so you must have known it existed when you wrote the answer. Er ... I would have thought? – cfr Jan 10 '18 at 3:19
  • @cfr fontenc goes in one ear, out the other. You are right, I wrote it... then immediately forgot about it. It's so Twentieth Century. – user139954 Jan 10 '18 at 4:27
  • 1
    @RobtAll Thank you, mentioning LuaTeX was very helpful, I edited my question, see above. However, I'd really be glad if somebody provided an answer solving the issue with pdfTeX. Let's wait and see. We need much more attention for PDF/A, because this will be more and more important for every PDF. – Keks Dose Jan 10 '18 at 8:42
2

Piece of cake with ConTeXt. ;)

You need to download the ICC color profiles form the PDF/X page in the Garden (direct link: zip) and extract them into the ConTeXt source tree. I recommend to read the linked article in the Garden and also checkout the examples in the ConTeXt distribution.

Unfortunately the Libertine typescript shipped with ConTeXt standalone doesn't work properly (probably misspelled filenames) but you can easily roll your own in just a few lines.

Then I pointed ConTeXt to the directory where Libertine is installed,

OSFONTDIR=/path/to/libertine/ context test.tex

In my case I used the ones from TeXlive 2017 in /usr/local/texlive/2017/texmf-dist/fonts/opentype/public/libertine/.

\setupbackend
  [format=PDF/A-1b:2005,
   intent=sRGB IEC61966-2.1,
   profile=sRGB.icc]

\setuptagging[state=start]

\starttypescriptcollection[libertine]
  \starttypescript [serif] [libertine] [name]
    \setups[font:fallback:serif]
    \definefontsynonym [Serif]            [file:LinLibertine_R]   [features=default]
    \definefontsynonym [SerifItalic]      [file:LinLibertine_RI]  [features=default]
    \definefontsynonym [SerifSlanted]     [file:LinLibertine_RI]  [features=default]
    \definefontsynonym [SerifBold]        [file:LinLibertine_RB]  [features=default]
    \definefontsynonym [SerifBoldItalic]  [file:LinLibertine_RBI] [features=default]
    \definefontsynonym [SerifBoldSlanted] [file:LinLibertine_RBI] [features=default]
    \definefontsynonym [SerifCaps]        [file:LinLibertine_R]   [features=smallcaps]
  \stoptypescript

  \starttypescript [sans] [biolinum] [name]
    \setups[font:fallback:sans]
    \definefontsynonym [Sans]           [file:LinBiolinum_R]   [features=default]
    \definefontsynonym [SansBold]       [file:LinBiolinum_B]   [features=default]
    \definefontsynonym [SansItalic]     [file:LinBiolinum_RI]  [features=default]
    \definefontsynonym [SansSlanted]    [file:LinBiolinum_RI]  [features=default]
    \definefontsynonym [SansBoldItalic] [file:LinBiolinum_RBO] [features=default]
    \definefontsynonym [SansCaps]       [file:LinBiolinum_R]   [features=smallcaps]
  \stoptypescript

  \starttypescript [libertine]
    \definetypeface [libertine] [rm] [serif] [libertine] [default]
    \definetypeface [libertine] [ss] [sans]  [biolinum]  [default]
    \definetypeface [libertine] [tt] [mono]  [default]   [default]
    \definetypeface [libertine] [mm] [math]  [default]   [default]
    \quittypescriptscanning
  \stoptypescript

\stoptypescriptcollection

\setupbodyfont[libertine,10pt]

\starttext

\startsection
  [title={Erster Abschnitt},
   reference={CLA:erster-abschnitt}]

  Ein Text mit \emph{Auszeichnung} und sogar \bold{fettem} Text,
  sogar \sans{LinBiolium als Schrift \emph{auch noch hervorgehoben}}.

\stopsection

\stoptext

enter image description here

To verify I used the Apache PDFBox preflight app.

$ java -jar preflight-app-2.0.8.jar test.pdf 
The file test.pdf is a valid PDF/A-1b file

VeraPDF is happy as well.

enter image description here

  • I wasted hours to get the preflight app to work. Crashes under Linux as well as under Win 8.1, in all versions I tried. Sigh. – Keks Dose Jan 12 '18 at 9:45
  • @KeksDose Works without any problems on Ubuntu 16.04 with openjdk version 1.8.0_151. – Henri Menke Jan 12 '18 at 10:00
  • I tested pdfbox preflight with multiple PDFs. Crashes with many of them, but others are ok. So there is something in my experminental PDF/A-1B, which makes preflight crash. Maybe I'll report about it on the mailinglist of pdfbox. Thank you for your confirmation. – Keks Dose Jan 12 '18 at 10:24
1

Check this attempt to create example of PDF/A-1b, PDF/A-2b, PDF/A-2u or PDF/X-1 with Linux Libertine and Linux Biolinum using pdfLaTeX supporting datetime control (PDF/A PDF/X), cyrillic, CMYK icc and sRGB icc.

% !TeX program = pdflatex
% !TeX encoding = UTF-8
%%% PDF/A-1b, PDF/A-2b, PDF/A-2u or PDF/X-1 with Linux Libertine
%%% and Linux Biolinum using pdfLaTeX supporting datetime control (PDF/A PDF/X),
%%% cyrillic, CMYK icc and sRGB icc

%%%% PDF/A PDF/X setup part %%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% Variables initiating  %%%
\newcounter{colourmode}
\newcounter{pdftype}
\newcounter{iccinsert}

%% Control of colour mode and pdf type
\setcounter{colourmode}{1}  % 0 --- undefined (or rgb); 1 --- cmyk (always for pdf/x); 2 --- rgb
\setcounter{pdftype}{2}     % 0 --- undefined; 1 --- pdf/x; 2 --- pdf/a
\setcounter{iccinsert}{0}   % 0 --- don't upload icc cmyk inside pdf/x; 1 --- upload icc cmyk inside pdf/x;
\newcommand{\pdfapart}{1}        % PDF/A part (1, 2)
\newcommand{\pdfaconformance}{B} % PDF/A conformance (A, B, U)

%% Setting date
\newcommand{\docModDate}{\DTMdisplay{2016}{10}{02}{-1}{20}{00}{21}{03}{00}} % Some particular date example
%\newcommand{\docModDate}{\DTMnow} %current time, usual situation (today time)
\newcommand{\docCreationDate}{\docModDate}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\RequirePackage{etoolbox}[2015/08/02]

\ifnumequal{\value{pdftype}}{1}{
    \pdfobjcompresslevel=0%
    \pdfminorversion=3% must be set 3 for PDF 1.3 required by PDF/X
}{}
\ifboolexpr{test {\ifnumequal{\value{pdftype}}{2}} and test {\ifdefstring{\pdfapart}{1}}}{
    \pdfobjcompresslevel=0%
    \pdfminorversion=4% must be set 4 for PDF 1.4 required by PDF/A-1
}{}
\pdfinclusioncopyfonts=1
\PassOptionsToPackage{safe, warn}{textcomp}

%%%% PDF/A PDF/X setup part END %%%%

%%% Main class setting %%%
\documentclass[a4paper,12pt]{article}

%%% PDF/A PDF/X needed packages %%%
\usepackage{datetime2} % for date and time fields control
\usepackage{atbegshi}

%%%% For proper copypasting of text from pdf
\input glyphtounicode.tex
\input glyphtounicode-cmr.tex %from pdfx package
\pdfgentounicode=1

%%%% Setting options for russian language that follows.
\usepackage{cmap}              % Better search for text in pdf-file
\defaulthyphenchar=127         % Better hyphenation for copypasting
%\usepackage{textcomp}
\usepackage[T2A, T1]{fontenc}   % Russian letters support with T2A
\usepackage[utf8]{inputenc}[2014/04/30]
\usepackage[english, russian, ukrainian, german]{babel}[2014/03/24] %main language has to be set last
\babelensure[fontenc=T2A]{russian}

%%% Colours
\ifboolexpr{test {\ifnumequal{\value{colourmode}}{1}} or test {\ifnumequal{\value{pdftype}}{1}}}{
    \usepackage[dvipsnames, table, hyperref, cmyk]{xcolor}  % cmyk colours --- needed for PDF/X, questionable for PDF/A
}{%
    \ifnumequal{\value{colourmode}}{2}{%
        \usepackage[dvipsnames, table, hyperref, rgb]{xcolor}  % rgb colours
    }{%
        \usepackage[dvipsnames, table, hyperref]{xcolor}
    }
}

\usepackage{libertine}[2017/03/22]
\usepackage[libertine]{newtxmath}

%%% Hyperlinks %%%
\usepackage{hyperxmp}[2017/02/23] % extended pdf options
\ifnumless{\value{pdftype}}{2}{%
    \usepackage{hyperref}[2012/11/06]
}{%
    \usepackage[pdfa]{hyperref}[2012/11/06]
}

\newcommand{\docTitle}{Тестовый ŘÍŽŤŮĚĎ документ --- PDF/A and PDF/X test document}
\newcommand{\docAuthor}{Имя Фамилия ŠŘÍŽŤŮĚĎ}
\newcommand{\AuthorURL}{http://orcid.org/0000-0000-0000-0000} 

\title{\docTitle}
\author{\docAuthor}

\definecolor{citecolor}{cmyk}{0,0.6,0,0}

\selectlanguage{russian}
\hypersetup{% 
    unicode=true,
    pdftitle={\docTitle},
    pdfauthor={\docAuthor},
    pdfcopyright={This work is licensed under Creative Commons Public Attribution 4.0 International License},
    pdfsubject={Subject}, 
    pdfkeywords={PDF/A} {PDF/X} {TeX} {LaTeX} {Typesetting},
    pdflicenseurl={http://creativecommons.org/licenses/by/4.0/},
    pdfmetalang={en},
    pdflang={ru},
    bookmarksopen=true,
    bookmarksopenlevel=3,
    hypertexnames=false,% use guessable names for links
    linktocpage=true,
    plainpages=false,           % Forces page anchors to be named by the Arabic form  of the page number, rather than the formatted form
    colorlinks,
    breaklinks,
    citecolor={citecolor},
    pdfcontacturl = {\AuthorURL},
    pdfcontactaddress = {123456\xmpcomma\ Москва\xmpcomma\ \AuthorURL},
    pdfcontactcity = {Город \AuthorURL},
    pdfcontactcountry = {Россия},
    pdfcontactemail = {some\_mail@mail.ru}, 
    pdfcontactphone = {+7 (333) \AuthorURL},
    pdfcontactpostcode = {123456 postcode \AuthorURL},
    pdfcontactregion = {Регион \AuthorURL},
}

\ifnumgreater{\value{pdftype}}{0}{%
    \DTMsetstyle{pdf} % sets further dates to be in PDF format

    \hypersetup{
        pdfcreationdate={\docCreationDate}, % hyperref defined, hyperref expects it to be in PDF format
        pdfmoddate={\docModDate}, % hyperref defined, hyperref expects it to be in PDF format
        pdfdate={\docModDate}, % hyperxmp defined, can be in either PDF format or XMP format
        pdfmetadate={\docModDate}, % hyperxmp defined, can be in either PDF format or XMP format
    }

    \pdfstringdef\inputTitle{\docTitle}
}{}

\makeatletter
\ifboolexpr{test {\ifnumequal{\value{pdftype}}{2}} and test {\ifnumequal{\value{colourmode}}{1}}}{%
    % Dirty hack of hyperref to make rgb-like links annotated with C mark become annotated with K mark to work in PDF/A with CMYK
    % makeatletter - makeatother needed
    \patchcmd{\hyper@linkfile}{/C[}{/K[}{}{}
    \patchcmd{\hyper@linkurl}{/C[}{/K[}{}{}
    \patchcmd{\find@pdflink}{/C[}{/K[}{}{}
    \patchcmd{\hyper@linkstart}{/C[}{/K[}{}{}
}{}
\makeatother

%%%Does not work inside ifthen environments
%%http://tex.stackexchange.com/a/248911
%%72.27 pt is 72 bp, 800/803 %%http://tex.stackexchange.com/a/113513
%%(mm size * 72)/25.4 = bp size
\makeatletter
\edef\pwbp{\strip@pt\dimexpr0.996264009963\paperwidth\relax} %paper width in bp (PS points)
\edef\phbp{\strip@pt\dimexpr0.996264009963\paperheight\relax} %paper height in bp (PS points)
\makeatother

\edef\calcpdfpageattr{%
    /TrimBox [0.00000 0.00000 \pwbp\space\phbp]%
}

\ifnumequal{\value{pdftype}}{1}{%
    \hypersetup{pdfstartpage={},% disable openaction of hyperref for PDF/X compliance
    }

%%%%%%%%% PDF-X stuff, IF USING pdflatex or lualatex %%%%%%%%%
    \expandafter\pdfpageattr\expandafter{\calcpdfpageattr} %works

    \pdfinfo{ %for PDF/X %fill manually
      /Title(\inputTitle)
      /GTS_PDFXVersion (PDF/X-1:2001)
      /GTS_PDFXConformance (PDF/X-1a:2001)
    }%

    \ifnumequal{\value{iccinsert}}{1}{
        % insert CMYK icc from pdfx package inside file
        \immediate\pdfobj stream attr{/N 4^^J/Alternate/DeviceCMYK} file{coated_FOGRA39L_argl.icc}
        \pdfcatalog{%
          /PageMode /UseNone
          /OutputIntents [
            <<
              /Info (FOGRA39L)
              /Type /OutputIntent
              /S /GTS_PDFX
              /DestOutputProfile \the\pdflastobj\space 0 R
              /OutputConditionIdentifier (Coated FOGRA39)
              /RegistryName (http://www.color.org/)
            >>
          ]
        }
    }{%
        % don't insert CMYK icc from pdfx package inside file
        \pdfcatalog{ %for PDF/X
          /PageMode /UseNone
          /OutputIntents [
            <<
              /Info (none)
              /Type /OutputIntent
              /S /GTS_PDFX
              /OutputConditionIdentifier (Custom)
              /RegistryName (http://www.color.org/)
            >>
          ]
        }%
    }%

    \NoHyper%Have to kill all links/annotations for pdf-x compliance
    %http://tex.stackexchange.com/a/300675 %NoHyper environment does not deactivate the creation of bookmarks, the inclusion of document information etc.
}{}

\ifnumequal{\value{pdftype}}{2}{%
%%%%%%%%% PDF-A stuff, IF USING pdflatex or lualatex %%%%%%%%%
    \expandafter\pdfpageattr\expandafter{\calcpdfpageattr} %not really needed for PDF/A

    \ifnumequal{\value{colourmode}}{1}{%
        \immediate\pdfobj stream attr{/N 4} file{coated_FOGRA39L_argl.icc} %loads from pdfx package distribution
        \pdfcatalog{ %for PDF/A
          /PageMode /UseNone
          /OutputIntents [
            <<
              /Type /OutputIntent
              /S /GTS_PDFA1
              /DestOutputProfile \the\pdflastobj\space 0 R
              /OutputConditionIdentifier (Coated FOGRA39)
              /Info(FOGRA39 (ISO Coated v2 300\% (ECI)))
              /RegistryName (http://www.argyllcms.com/)
            >>
          ]
        }%
    }{%
        \immediate\pdfobj stream attr{/N 3^^J/Alternate/DeviceRGB} file{sRGB_IEC61966-2-1_black_scaled.icc}
        \pdfcatalog{ %for PDF/A
          /PageMode /UseNone
          /OutputIntents [
            <<
              /Type /OutputIntent
              /S /GTS_PDFA1
              /DestOutputProfile \the\pdflastobj\space 0 R
              /OutputConditionIdentifier (sRGB_IEC61966-2-1_black_scale)
              /Info(sRGB IEC61966 v2.1 with black scaling)
              /RegistryName (http://www.color.org/)
            >>
          ]
        }%
    }

    %%% Setting custom PDF/A part and conformance through hyperxmp
    \hypersetup{%
        pdfapart = {\pdfapart},
        pdfaconformance = {\pdfaconformance},
    }
}{}

%%% Solving \textnumero problem in russian pdflatex
%%% Don't know how to explain why this works
\UndeclareTextCommand{\textnumero}{T2A}
\UndeclareTextCommand{\S}{T2A}
\UndeclareTextCommand{\textpertenthousand}{T2A}
\usepackage{textcomp} %depending on previous font packages this may be second call to package

\begin{document}

\begin{otherlanguage*}{russian}
\maketitle
\end{otherlanguage*}

\section{Erster Abschnitt}
\label{CLA:erster-abschnitt}

Ein Text mit \emph{Auszeichnung} und sogar \textbf{fettem} Text, sogar {\sffamily{}
    LinBiolium als Schrift \emph{auch noch hervorgehoben}}.

Testing usually problematic symbols: \textnumero \S \textpertenthousand
\textthreequarters \textohm \textmho \textmu \texttimes \textdiv

\section{Some text (pangrams) in different languages}

\begin{otherlanguage*}{russian}
Любя, съешь щипцы, "--- вздохнёт мэр, "--- кайф жгуч. Шеф взъярён тчк щипцы
с~эхом гудбай Жюль. Эй, жлоб! Где туз? Прячь юных съёмщиц в~шкаф. Экс-граф?
Плюш изъят. Бьём чуждый цен хвощ! Эх, чужак! Общий съём цен шляп (юфть) "---
вдрызг!
\end{otherlanguage*}

Příliš žluťoučký kůň úpěl ďábelské ódy! Typographie ist zweidimensionale
Architektur und bedingt extra Qualität in jeder vollkommenen Ausfuehrung.
\begin{otherlanguage*}{russian}
Государев указ: душегубцев да шваль всякую высечь, да калёным железом по щекам
этих физиономий съездить! 200\dots450~{\textdegree}C. Широкая электрификация
южных губерний даст мощный толчок подъёму сельского хозяйства. Подъехал шофёр
на рефрижераторе грузить яйца для обучающихся элитных медиков.
\end{otherlanguage*}
1234567890.

\begin{otherlanguage*}{russian}
\[
\alpha = \frac{1}{l_0}\cdot \frac{\mathrm{d}l}{\mathrm{d}T},
\]
где $\alpha$ "--- ящерицы чешут вперёд за ключом,~1/{\textdegree}C;
$l_0$ "--- месторождения кварцующихся фей без слёз,~м;
$\mathrm{d}l$ "--- фиг выговоришь этюд,~м;
$\mathrm{d}T$ "--- жирафы честно в цель шагают, да щук объять,~{\textdegree}C.
\end{otherlanguage*}

El veloz murciélago hindú comía feliz cardillo y kiwi. La cigüeña tocaba el
saxofón detrás del palenque de paja.

\begin{otherlanguage*}{russian}
\begin{tabular}{c|c}
1 & 2 поводок\\
3 missisipy & 4
\end{tabular}
\end{otherlanguage*}

\begin{otherlanguage*}{ukrainian}
Матеріали конференції присвячені сучасним проблемам фізики та фізичних
технологій, перспективним напрямкам фізики енергетичних систем, теорії
безпеки, криптографічного захисту інформації та криптоаналізу, захисту
інформації в комп’ютерних мережах та комунікаціях, забезпеченню цілісності баз
даних, захисту від витоку інформації по каналах побічного електромагнітного
випромінювання, локальним мережам різної струк\-тури, технічного захисту
об’єктів, а також науковим дослідженням фундаментального та прикладного
характеру у сфері інформаційних наук.
\end{otherlanguage*}

\end{document}

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.