1

I would like to edit the title of the final pdf file. Following this post I got the following code, which works perfectly

\documentclass{article}
\usepackage{hyperref}
\hypersetup{pdftitle={Title I want}}
\usepackage{graphicx}

\begin{document} This file is not completely empty. %\includegraphics[width=0.7\textwidth]{fignu05.eps}

\end{document}

Compilation is done through latex+dvips+ps2pdf.

My problem appears when I uncomment the includegraphics line. For some reason, the meta data of the picture (which is " Test.eps ") erases the " Title I want " and I don't know how to solve this.

I tried placing the hypersetup command after the includegraphics one, this does not solve the problem.

Any help would be greatly appreciated.

EDIT : answering to a comment below, I share the image here.

AlexG
  • 54,894
xounamoun
  • 221

3 Answers3

1

Metadata are inserted in the PDF output by means of the /DOCINFO pdfmark during PS to PDF conversion.

The pdfmark command can be temporarily redefined to clear all its arguments from the operand stack. Here we do this specifically for the /DOCINFO pdfmark in order to prevent the included EPS from contaminating the main PDF with its metadata. Other pdfmarks, e. g. for Link creation, are not affected.

\documentclass{article}

\usepackage{hyperref} \hypersetup{pdftitle={Title I want}} \usepackage{graphicx}

\newenvironment{NoDocinfo}{% \special{ps: save /pdfmark {dup /DOCINFO eq {cleartomark}{systemdict /pdfmark get exec} ifelse} def}% \ignorespaces% }{% \unskip% \special{ps: restore}% }

\begin{document}

\begin{NoDocinfo} \fbox{\includegraphics[width=0.7\textwidth]{fignu05.eps}} \end{NoDocinfo}

\end{document}

AlexG
  • 54,894
  • I first voted to your answer because it solved the issue but I discovered that some reason all the internal hyperref links are not working anymore when I add these two lines. Any idea ? – xounamoun Mar 04 '21 at 13:50
  • Ok, the new version neutralises only the /DOCINFO pdfmark, other pdfmarks used inside fignu05.eps are not affected. – AlexG Mar 04 '21 at 14:23
  • Thanks for the reactivity ! I just notice now that there's an error message (even with the previous version), and the pdf file stops at page ten : " Error: /invalidrestore in --restore-- " and " PL Ghostscript 9.50: Unrecoverable error, exit code 1 GPL Ghostscript 9.50: ERROR: A pdfmark destination page 11 points beyond the last page 10." – xounamoun Mar 04 '21 at 14:30
  • It works for me with gs-9.53.3. I have edited the code, but just for making it more user-friendly. The result should be the same. Could you please post another EPS with interactive elements, for testing? – AlexG Mar 04 '21 at 14:36
  • And, of course, the NoDocinfo environment should tightly enclose the image inclusion. – AlexG Mar 04 '21 at 14:39
  • You solved it :) Thanks ! – xounamoun Mar 05 '21 at 15:35
  • Glad to hear this! – AlexG Mar 05 '21 at 15:36
0

Well ... the comment of Ulrike Fischer suggested me to try avoiding pdflatex and I followed this post which is just fine for my problem.

xounamoun
  • 221
0

The problem is that the graphics contains also an instruction to fill the info dictionary and is later then the code from hyperref.

With the new LaTeX PDF management code (which is currently in the testphase and requires a very new tex system) it will work as this code adds the info dictionary much later:

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress}

\documentclass{article} \usepackage{hyperref} \hypersetup{pdftitle={Title I want}}

\usepackage{graphicx}

\begin{document} This file is not completely empty. \includegraphics[width=0.7\textwidth]{fignu05.eps}

\end{document}

A bit hacky alternative is to use the expl3 backend command, to overwrite the graphics entry:

\documentclass{article}
\usepackage{hyperref}
\usepackage{graphicx}
\hypersetup{pdftitle={Title I want}}
\begin{document}
This file is not completely empty.
\includegraphics[width=0.7\textwidth]{fignu05.eps}

\ExplSyntaxOn\makeatletter \exp_args:Nnx __pdf_backend_info_gput:nn{Title}{(@pdftitle)} \ExplSyntaxOff \end{document}

Ulrike Fischer
  • 327,261