ho-tex / oberdiek

Updating the oberdiek bundle
Other
16 stars 6 forks source link

pax and pdfx to produce pdf/a: validation error "Except for annotation dictionaries whose Subtype value is Popup, all annotation dictionaries shall contain the F key." #86

Closed aolney closed 3 years ago

aolney commented 3 years ago

I'm using pdfx in conjuction with pdfpages to add a footer to a pdf with embedded fonts.

The process works if \usepackage{pax} is commented out. By works, I mean a pdf is output and passes veraPDF compliance checks, and the resulting hyperlinks work properly.

If \usepackage{pax} is introduced, veraPDF produces this error:

Rule Status
Specification: ISO 19005-2:2011, Clause: 6.3.2, Test number: 1  
Except for annotation dictionaries whose Subtype value is Popup, all annotation dictionaries shall contain the F key. Failed
3 occurrences  
PDAnnot  
Subtype == "Popup" || F != null  

root/document[0]/pages[0](6 0 obj PDPage)/annots[2](28 0 obj PDAnnot) root/document[0]/pages[0](6 0 obj PDPage)/annots[1](27 0 obj PDAnnot) root/document[0]/pages[0](6 0 obj PDPage)/annots[0](26 0 obj PDAnnot)

My original (without footer) pdf was generated with this:

\documentclass[12pt,letterpaper]{article}
\usepackage[utf8]{inputenc}
\usepackage{hyperref}
\author{Andrew Olney}
\begin{document}

For further references see \href{http://www.sharelatex.com}{Something Linky} 
or go to the next url: \url{http://www.sharelatex.com}

\end{document}

My pax file associated with it is this:

\[{pax}{0.1l}\\
\[{file}{\<7375626D697373696F6E2E706466\>}{
  Size={17661},
  Date={D:20201219122032-06'00'},
}\\
\[{pagenum}{1}\\
\[{page}{1}{0 0 612 792}{}\\
\[{annot}{1}{Link}{261.168 650.594 350.664 663.545}{URI}{
  C={[0 1 1]},
  H={/I},
  URI={\<687474703A2F2F7777772E73686172656C617465782E636F6D\>},
  Border={[0 0 1]},
}\\
\[{annot}{1}{Link}{467.641 650.594 500.394 663.545}{URI}{
  C={[0 1 1]},
  H={/I},
  URI={\<687474703A2F2F7777772E73686172656C617465782E636F6D\>},
  Border={[0 0 1]},
}\\
\[{annot}{1}{Link}{109.858 637.808 234.889 649.099}{URI}{
  C={[0 1 1]},
  H={/I},
  URI={\<687474703A2F2F7777772E73686172656C617465782E636F6D\>},
  Border={[0 0 1]},
}\\

And my latex file that adds the header is this:

\begin{filecontents*}[overwrite]{\jobname.xmpdata}
\Title{Document’s title}
\Author{Author’s name}
\Language{en-US} 
\Subject{The abstract, or short description.}
\Keywords{keyword1\sep keyword2\sep keyword3}
\end{filecontents*}
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{colorprofiles}
\usepackage[a-2b,mathxmp]{pdfx}[2018/12/22]
\usepackage{pdfpages}
\usepackage{pax}
\iffalse
  \usepackage{hyperref}
  \hypersetup{
    filebordercolor={1 1 0},
    pdfa,
    pdfstartview=,
  }
\fi
%\usepackage[usenames]{xcolor}
%\usepackage[bottom=1cm,right=3.25cm,left=2.5cm,top=1cm]{geometry}
\usepackage[bottom=2cm,right=1in,left=1in,top=1cm]{geometry}
\usepackage{fancyhdr} %started above geometry load, moved below

\renewcommand{\thepage}{\roman{page}} %FOR ACKNOWLEDGEMENTS; COMMENT FOR EVERYTHING ELSE

\def\pdffilename{submission.pdf}
\def\artvolume{9}
\def\artno{1}
\def\artmonthyear{2017}
\def\startpage{1}               % page numbering based on whole volumes
%\def\showcolor{white}

\setcounter{page}{\startpage}

\pagestyle{fancy}
\rhead{~}
\chead{~}%\colorbox{white}{\raisebox{0pt}[48pt][24pt]{\parbox{\textwidth}{~}}}}

\cfoot{\colorbox{white}{\raisebox{0pt}[24pt][24pt]{\parbox{.8\textwidth}{~}}}} %original file had ~ as _, causing error
\rfoot{\colorbox{white}{\raisebox{0pt}[24pt][24pt]{Journal of Educational Data Mining, Volume \artvolume, No \artno, \artmonthyear}}}
\lfoot{\colorbox{white}{\raisebox{0pt}[24pt][24pt]{\parbox{.8\textwidth}{\thepage}}}}
\renewcommand{\headrulewidth}{0pt}

%IF WE CORRECT THIS ERROR, THE ORIGINAL PAGE # REAPPEARS ABOVE THE NEW FOOTER
%\setlength{\headheight}{72pt} %https://tex.stackexchange.com/questions/327285/what-does-this-warning-mean-fancyhdr-and-headheight

\begin{document}

\includepdf[pages=-,rotateoversize=true,noautoscale=true,pagecommand={\thispagestyle{fancy}}]{\pdffilename}
%\includepdf[pages={-},pagecommand={\thispagestyle{fancy}}]{\pdffilename} %blows up, Missing $ inserted
%\includepdf[pages={-},pagecommand={\thispagestyle{fancy}},fitpaper]{\pdffilename}

\end{document}

My understanding is that the F annotation needs to specify Print, according the the PDF standard (p493). However, I'm not sure how to do this. I tried to inject tags like F={1} into the pax file, but that did not seem to help anything. In order to allow that tag, I made a trivial modification to pax.sty: \DeclareStringOption{F}.

Any suggestions would be appreciated, including posting this question elsewhere.

u-fischer commented 3 years ago

pax is not maintained in this repository. But beside this you could try

\makeatletter
\def\PAX@attrs@URI#1{/F 4 #1}
\makeatletter
aolney commented 3 years ago

I couldn't make that work, but thank you for the suggestion.

To follow up, would you recommend another repo, or should I try on stackexchange?

u-fischer commented 3 years ago

I couldn't make that work, but thank you for the suggestion.

What do you mean? I tried it, and it inserted the /F key into the annotation.

This are your annotations without the code:

25 0 obj
<<
/Type /Annot
/Subtype/Link/Border[0 0 1]/H/I/C[0 1 1]/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [261.185 650.615 350.686 663.566]
>>
endobj
26 0 obj
<<
/Type /Annot
/Subtype/Link/Border[0 0 1]/H/I/C[0 1 1]/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [467.67 650.615 500.425 663.566]
>>
endobj
27 0 obj
<<
/Type /Annot
/Subtype/Link/Border[0 0 1]/H/I/C[0 1 1]/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [109.865 637.828 234.904 649.12]
>>
endobj

and this with

25 0 obj
<<
/Type /Annot
/Subtype/Link/F 4 /C [0 1 1]/Border [0 0 1]/H /I/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [261.185 650.615 350.686 663.566]
>>
endobj
26 0 obj
<<
/Type /Annot
/Subtype/Link/F 4 /C [0 1 1]/Border [0 0 1]/H /I/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [467.67 650.615 500.425 663.566]
>>
endobj
27 0 obj
<<
/Type /Annot
/Subtype/Link/F 4 /C [0 1 1]/Border [0 0 1]/H /I/A<</Type/Action/S/URI/URI<687474703A2F2F7777772E73686172656C617465782E636F6D>>>
/Rect [109.865 637.828 234.904 649.12]
>>
endobj

As you can see the /F 4 is there

To follow up, would you recommend another repo, or should I try on stackexchange?

There is no other repo, you need direct contact to the maintainer, and on tex.sx it would be probably me who would answer.

aolney commented 3 years ago

Thanks so much for following up. Your code worked - I just misapplied it :facepalm:

I confirm that with your code, pax + pdfpages + pdfx (as in my example above) passes veraPDF validation profile PDF/A-2B :tada: