0

Inserting data about article to the PDF

It is possible to pass title and author of the article to the appropriate hyperref package options? I want to be the values of \title - Title of the article and \author - A.U. Thor automatically assigned to pdftitle and pdfauthor.

\documentclass[]{article}
\usepackage{lipsum}
\RequirePackage[colorlinks=true,
    urlcolor = blue, %Colour for external hyperlinks
    linkcolor  = red, %Colour of internal links
    citecolor  = green, %Colour of citations
    bookmarks,
    bookmarksnumbered=true,
    unicode,
    linktoc = all,
    hypertexnames=false,
    pdftitle={Title of the article},
    pdfauthor={A.U. Thor}]{hyperref}
%opening
\title{Title of the article}
\author{A.U. Thor}

\begin{document} \maketitle

\section{One} \lipsum[1-3] \end{document}

Extracting data from PDF

I have another question, which is relate to this one. In the referred question, the .tex file reads the data about title and authors from external .dat-file and then use it for some purposes (creating TOC, for example). Now I want to use only .pdf as a data container. Thus, how it is possible to extract appropriate fields from PDF file to the LaTeX using pdfpages package?

enter image description here

sergiokapone
  • 5,578
  • 1
  • 16
  • 39
  • To the first question, unless you are doing batch work, i don't see why one would go into the trouble of redefining author and title. You would need to assure that hyperref is loaded an all that. – Johannes_B Jan 28 '15 at 11:01
  • What do you mean with the second question? Can you elaborate on that? – Johannes_B Jan 28 '15 at 11:01
  • @Johannes_B I has added some explanation in the question. Hope, it will become a little clearer. – sergiokapone Jan 28 '15 at 12:21

1 Answers1

3

Delay setting the options when \@title and \@author have been set:

\documentclass[]{article}
\usepackage{lipsum}
\RequirePackage[colorlinks=true,
    urlcolor = blue, %Colour for external hyperlinks
    linkcolor  = red, %Colour of internal links
    citecolor  = green, %Colour of citations
    bookmarks,
    bookmarksnumbered=true,
    unicode,
    linktoc = all,
    hypertexnames=false,
]{hyperref}
%opening
\title{Title of the article}
\author{A. U. Thor}

\makeatletter
\hypersetup{
  pdftitle=\@title,
  pdfauthor=\@author,
}
\makeatother


\begin{document}
\maketitle


\section{One}
\lipsum[1-3]
\end{document}

enter image description here

egreg
  • 1,121,712
  • Thanx! Do you know how to extract this data from the pdf using pdfpages. This related with your answer http://tex.stackexchange.com/questions/223471/write-read-values-of-the-latex-commands-like-title-author-etc-in-file-usin I want to do the same but without using any additional dat-files, but only pdf as a data container. It seems to me, it will be more economical. – sergiokapone Jan 28 '15 at 12:09
  • You can use a program such as pdfinfo. – egreg Jan 28 '15 at 12:46