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.

2
  • without the eps it is not possible to test this. Why do you use the latex-dvips route instead of pdflatex? Commented Mar 2, 2021 at 16:18
  • @UlrikeFischer I added the picture. I am stuck with latex-dvips because of some PStricks figure in the document.
    – xounamoun
    Commented Mar 3, 2021 at 10:43

3 Answers 3

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}
7
  • 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
    Commented Mar 4, 2021 at 13:50
  • Ok, the new version neutralises only the /DOCINFO pdfmark, other pdfmarks used inside fignu05.eps are not affected.
    – AlexG
    Commented Mar 4, 2021 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
    Commented Mar 4, 2021 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
    Commented Mar 4, 2021 at 14:36
  • And, of course, the NoDocinfo environment should tightly enclose the image inclusion.
    – AlexG
    Commented Mar 4, 2021 at 14:39
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.

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}

You must log in to answer this question.

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