1

I would like to see if is possible to add something like the download date of a document I created in LaTeX. If yes, how could I do this?

See the blue marked part

Werner
  • 603,163

1 Answers1

4

The following process relies on 2 packages and using \pdffilemoddate{<file.ext>} to extract the file modified date from <file.ext>. The original downloaded file is included using pdfpages. And, with each page of the downloaded file that is included, we execute a pagecommand that inserts a watermark containing the file modification date (which should correspond to the download date). The watermark is inserted in the ForeGround of each page using eso-pic's \AddToShipoutPictureFG*.

enter image description here

\documentclass{article}

\usepackage{eso-pic,pdfpages,lipsum}

% https://tex.stackexchange.com/a/12310/5764
\newcommand*{\filedate}[1]{%
  \expandafter\filedateX\pdffilemoddate{#1}\relax
}
\def\filedateX#1#2#3#4#5#6#7#8{%
  \filedateXX{#3#4#5#6}{#7#8}%
}
\def\filedateXX#1#2#3#4#5#6#7#8{%
  \filedateXXX{#1}{#2}{#3#4}{#5#6}{#7#8}%
}
\def\filedateXXX#1#2#3#4#5#6#7#8\relax{%
  \formatdate{#1}{#2}{#3}{#4}{#5}{#6#7}%
}

\newcommand*{\formatdate}[6]{%
   #1-#2-#3\ #4:#5:#6%
}

\begin{document}

\lipsum[1]% Text before the included/downloaded file (if it exists/is needed)

\includepdf[
  pages=1-2,
  pagecommand={
    \thispagestyle{empty}% Remove header/footer
    \AddToShipoutPictureFG*{%
      \AtPageLowerLeft{%
        \hspace{2em}% Move watermark into page
        \rotatebox{90}{%
          \makebox[\paperheight]{\Large Downloaded on \filedate{lipsum.pdf}}%
        }%
      }%
    }%
  }
]{lipsum}% Include downloaded file

\lipsum[2]% Text after the included/downloaded file (if it exists/is needed)

\end{document}

The conversion of the \pdffilemoddate output into something more readable is thanks to Date of file creation.

Werner
  • 603,163