2

I have a problem with hyperref: how to break long lines in pdf fields : the pdftitle is very long and I want hyperref to begin a new line, just like it does for key-words.

I compile with pdflatex, xelatex and lualatex.

\documentclass[oneside,a4paper, 12pt]{article}


%%\usepackage[T1]{fontenc}
%%\usepackage[frenchb]{babel}


%%%% \usepackage{alternative4ht}
  \usepackage{fontspec}
  \setmainfont{TeX Gyre Termes}
  \usepackage{polyglossia}
  \setmainlanguage{czech}



\usepackage{hyperref}
\hypersetup{
pdfencoding=auto,
psdextra,
}

\hypersetup{
pdftitle={\today Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
}

\begin{document}
\today








\end{document}
  • 1
    My version of Acrobat only has enough room for one line of title, but several lines of keywords. Any line breaking is done by the browser. not the document. – John Kormylo Jan 4 '16 at 17:44
0

The PDF format does not support explicit line breaks in PDF information fields.

\textLF (line feed) or \textCR (carriage return) could be tried:

\documentclass{article}
\usepackage{hyperref}
\hypersetup{
  pdftitle={Hello\textLF World},
  pdfsubject={Hello\textCR World},
}
\begin{document}
Hello World
\end{document}

And evince shows indeed line breaks. But AR shows only the first line and the rest of the title or subject is not displayed. Therefore this method is not recommended.

  • summatra shows the LF and CR indeed, but not foxit.... – Koala Jan 5 '16 at 5:41
1

To illustrate the point, using

\hypersetup{
pdftitle={\today Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
pdfkeywords={Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit Lorem ipsum dolor sit amet, consectetur adipiscing elit.},
}

the corresponding object in the PDF is

15 0 obj
<<
/Author()/Title(January\0404,\0402016Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit.)/Subject()/Creator(LaTeX with hyperref package)/Producer(LuaTeX-0.80.0)/Keywords(Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit\040Lorem\040ipsum\040dolor\040sit\040amet,\040consectetur\040adipiscing\040elit.)
/CreationDate (D:20160104115430-06'00')/ModDate (D:20160104115430-06'00')/Trapped/False/PTEX.Fullbanner (This is LuaTeX, Version beta-0.80.0 (MiKTeX 2.9 64-bit) (rev 5238))>>
endobj

The title and keywords are stored precisely the same.

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.