4

I am working on making my XeLaTeX-compiled PDF file compliant with PDF/X-1a:2001 standard.

When I use this answer with TeXLive 2015, document validates fully (in Acrobat Pro DC). However, when I test same solution on my actual document, which includes chapters, table of contents and other interactivity, I get errors.

I compiled code below with xelatex -output-driver="xdvipdfmx -V 3" pdfx.tex:

\documentclass{book}
\usepackage{atbegshi}
\AtBeginShipout{
    \special{pdf: put @thispage
      <<
        /TrimBox [0 0 210.990 162.086]
      >>
    }
}
\special{pdf: put @thispage
  <<
    /TrimBox [0 0 210.990 162.086]
  >>
}
\special{pdf:docinfo
  <<
    /GTS_PDFXVersion (PDF/X-1:2001)
    /GTS_PDFXConformance (PDF/X-1a:2001)
  >>
}

\special{pdf:put @catalog
<<
  /PageMode /UseNone
  /OutputIntents [
    <<
      /Info (none)
      /Type /OutputIntent
      /S /GTS_PDFX
      /OutputConditionIdentifier (Custom)
      /RegistryName (http://www.color.org/)
    >>
  ]
>>
}%

\usepackage{datetime}
\usepackage{hyperref}
\hypersetup{% 
    pdftitle={Title},
    pdfinfo={
        ModDate={D:\pdfdate},
        Trapped={False},      
   },
}


\begin{document}
\chapter{Some chapter}
\chapter{Some chapter}
\chapter{Some chapter}
\chapter{Some chapter}
\end{document}

and resulting PDF validation outputs "Document contains actions" error in Acrobat:

PDF "actions" error

Some documents I tested also throw following error: "Annotation inside page area", which points to table of contents generated with \tableofcontents command and internal links generated with \hyperlink command. (Hyperlinks are in the document, as basically same source is used for generation of interactive document and print version.)

So problem is interactivity in document.

I tried to disable it by changing

\usepackage{hyperref}

to

\usepackage[draft]{hyperref}

but this not only disables interactivity added by hyperref, but also skips hypersetup, which results in document modification date, title and trapped key not being included in compiled PDF. Effect: there is no error regarding interactivity, but document is still not compliant with PDF/X-1a:2001, since it requires hypersetup metadata to be included.

How can I completely disable all interactivity in a document while still making hypersetup work?

In theory, I could redefine/overwrite all "interactive" hyperref commands as well as all my custom commands that use interactivity (at the very end of the preamble, so that all earlier definitions are overwritten):

…
\def \hyperlink#1#2{#2}
\def \href#1#2{#2}
\def \url#1{#1}
\begin{document}
…

but:

  • I am not sure how can I disable interactivity of \pageref without loosing page number in the document
  • This approach is very document-specific, as it requires checking where exactly interactivity was added and by which commands
  • While it works for some of the documents I tested it with, it doesn't do the trick for MWE above.

Is there any more straightforward/generic way to disable interactivity globally in whole document?

2
  • Try this template i made: gist.github.com/LSinev/74ea05423c9208d6677d. I wanted to create complex documents compatible with all (pdf|Xe|Lua)LaTeX compilers wuth pdf/x and pdf/a support. I still have not made Xelatex to produce good pdf/a but with pdf/x seems ok.
    – Leonid
    Mar 23, 2016 at 20:43
  • @Leonid While your template compiles well and then validates fully, I have hard time trying to incorporate it into MWE in this question. I see that \hypersetup{draft,} disables interactivity, but it has same side effect as if it was used during package load, that is: missing metadata. I was able to add trapped key using your template, but modification date and title addition eludes me if I try to incorporate only parts of your template that are relevant to this question. Would you be able to modify my MWE only to disable interactivity, without loosing metadata (for XeLaTeX only)?
    – Rafal
    Mar 24, 2016 at 10:34

1 Answer 1

3

The NoHyper environment might do what you are looking for: inside its scope, most hyperref features are disabled, by redefining the internal macros hyperref uses to produce links so that they do nothing. However, in contrast to the draft package option, it does not deactivate the creation of bookmarks, the inclusion of document information etc.

Usually, you would enclose the parts of your document where you want to diable links in

\begin{NoHyper}
    ...
\end{NoHyper}

In this case, as you want to avoid links throughout the whole document, it might be easier to just replace

\usepackage{hyperref}

in your example by

\usepackage[bookmarks=false]{hyperref}
\NoHyper

to disable links and bookmarks globally, while still being able to include metadata in the PDF file. Disabling bookmarks is a requirement, as their presence will trigger same validation error shown in the question.

1
  • 1
    When I tested your solution, Acrobat still complained about actions in the document. I tried to disable bookmarks as well and it worked perfectly! I edited your answer to include that information, as well as removed draft option from code sample (I put it in MWE inadvertently and it did not match code that caused error on screenshot).
    – Rafal
    Mar 25, 2016 at 8:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .