43

When writing a referee report for a journal, it would be preferrable to have the resulting PDF file generated by pdflatex be completely anonymous.

Does one need to take special actions to ensure this? For example, if any references to file names with their paths are included anywhere in the resulting file, that will result in information (my home directory is /home/mariano/... for example)

28

pdfTeX and luaTeX write additional information into the resulting PDF as documented in pdftex-pdfkeys.pdf:

  1. The Document Catalog contains an additional key PTEX.Fullbanner which contains the full version of pdftex/luatex, i.e. "This is pdfTeX, Version 3.1415926-2.4-1.40.13 (TeX Live 2012) kpathsea version 6.1.0)". This key can be seen in some version of Adobe Reader and Adobe Acrobat (Document Properties -> Advanced).

For every included image theses keys are added to the XObject containing the image:

  1. PTEX.FileName is the filename as seen by pdfTeX, e.g. "./sample2e.pdf"
  2. PTEX.PageNumber is the page number of an included PDF
  3. PTEX.InfoDict is a copy of the Info Dictionary (e.g. Title, Author, etc.) of an included PDF.

Since pdftex 1.40.17 these keys can be turned off; see @BeingQuisitive's answer.

  • Is there a flag to turn this off somewhere? This is one way to leak personal information, I guess. – Mariano Suárez-Álvarez Jan 23 '13 at 23:00
  • 4
    +1 for investigating! Do you know if anything of this is preserved when piping the PDF through the pdf2ps | ps2pdf route as suugested by Mariano? – Daniel Jan 24 '13 at 6:49
  • Are there any (free) tools to examine this information? – Daniel Jan 24 '13 at 6:57
  • 1
    Could you at least post a summary of the linked document. A full answer to the question should also include a way to avoid this additional information or an explanation why this is not possible. – Martin Scharrer Jan 24 '13 at 9:28
  • 4
    @KeksDose: Answers on this side should be mostly self-contained. Also this doesn't answer the question. It's just points out an issue which has to be solved. – Martin Scharrer Jan 24 '13 at 10:02
17

If you wish to erase that you can try:

\usepackage{hyperref}
\hypersetup{
  pdfinfo={
  pdfproducer={},
  Title={},
  Subject={},
  Author={},
  }
}

(for all keys described in § 3.9 of the hyperref package documentation).


Using Werner's suggestion---of which I was completely unaware---you can accomplish the same directly with the PDFTeX engine, thus:

\pdfinfo{
  /Title ()
  /Creator ()
  /Producer ()
  /Author ()
  /Subject ()
  /Keywords ()
}

Yet I'm a bit puzzled with this slashed syntax (instead of the TeX backslash).

  • 4
    Technically you don't need hyperref to set meta data. pdfTeX internally supports this. See Is hyperref really the best way to add metadata to a TeX file? – Werner Jan 24 '13 at 15:25
  • 3
    Just a small comment on the /Title () syntax. This is just the PDF syntax, it is not anyhow related to TeX – Vincent Fourmond Jan 1 '15 at 19:08
  • 1
    @NVaughan "I guess the path you see is not really written in your PDF, but it is the relative path where the PDF is currently located. Apart from general information of the PDF producer ("LaTeX with hyperref package", etc.) I see no private information". ARE you kidding?! You definitely get a fat downvote from me, because it is an information leak (!). If you have latex on your server to create PDFs it can leak paths and latex version. Please don't answer if your answer doesn't make sense or you don't know an answer. And path is in PDF. You can open PDF with regular editor and verify – notyourdolly Sep 12 at 13:51
  • 1
    @noyourdolly Definitely not my dolly. – NVaughan Sep 13 at 18:25
13

PDF meta-data can be about either the main document or included PDFs.

Main PDF

We can remove the main PDF meta-data from the Document Catalog. If you are not using the hyperref package you can use the following tex code (credit to NVaughan/Werner):

\pdfinfo{ /Creator ()  /Producer () /ModDate ()  /CreationDate () } 

(You can also zero-out Title,Author, Subject, and Keywords but these aren't usually set, at least by MiKTeX.) If you are using the hyperref package then it will write some of these fields again. It will write Creator and Producer with values, Subject and Keywords that are usually blank, and Author and Title which it may autopopulate. So you will have to at least do either

\hypersetup{pdfinfo={ Creator={}, Producer={}, ModDate={...}, CreationDate={...} }}

or

\pdfinfo{ /ModDate ()  /CreationDate () }
\hypersetup{pdfinfo={ Creator={}, Producer={} }}

If you are using pdfTeX version 1.40.17 or greater (included in MiKTeX already), then the following will remove the trailer ID (often a hash of content and timestamp) and the PTEX.Fullbanner

\pdftrailerid{} %Remove ID
\pdfsuppressptexinfo15 %Suppress PTEX.Fullbanner and info of imported PDFs

For earlier versions of pdfTeX you will have to post-process to get rid of these field (see perl example below).

Included PDFs

For removing meta-data from included PDFs, the line above works for pdfTeX 1.40.17

\pdfsuppressptexinfo15 %Suppress PTEX.Fullbanner and info of imported PDFs

(See the full bit mask options for pdfsuppressptexinfo.) Otherwise, you can post-process the PDF to at least remove the file-names using:

perl -pe 's|(/PTEX.FileName \()([^\)]+)|$1 . " " x length($2)|ge' orig.pdf > orig.anon.pdf

This post-processing will not remove the PTEX.PageNumber (likely harmless) or PTEX.InfoDict (which you may want to ensure doesn't contain anything sensitive).

LuaTeX

PDFs made from LuaTeX can also be made reproducible, by adding options

\pdfvariable suppressoptionalinfo 767

Some packages seem to rewrite some of the suppressed fields (e.g. hyperref or doi), in which case the document can be made reproducible with the additional line (which will include blank entries)

\hypersetup{pdfinfo={ Creator={}, Producer={} }}

Edited 2016-05-25 to include options for newer versions of pdfTeX.

Edited 2017-08-31 to include options for newer versions of LuaTeX.

  • upvote for \pdfsuppressptexinfo. I think this should be an accepted answer. – notyourdolly Sep 12 at 16:07
10

Rejoice ! pdfprivacy can now do that automagically !

From the documentation of the package

To use pdfprivacy, simple include it: \usepackage[〈options〉]{pdfprivacy} […] By default, […] [t]his removes/suppresses all pdf creator, producer, dates, and pdfTeX meta-data. Standard document properties such as title, author, subject, and keywords are still kept. The pdftrailerid is kept as well by default.

9

First of all, PDF is not like DOC or XLS – I have never encountered an path names or other "hidden" information in it that reveals details about my computer or environment. Apparently I was wrong, pdftex und luatex do write extra information into the PDF's object catalog! See answer of Martin for details.

Nevertheless, at times we all face a bit of paranoia. A simple, albeit brute-force approach in this case is to just rasterize the complete PDF (here using ImageMagick):

convert -density 300 report.pdf report-anonymized.pdf

The disadvantage is, of course, that the resulting PDF can become fairly big and that it is no longer possible to select text in it.

A bit less drastic is the conversion PS and back to PDF, as suggested by Mariano (here using Ghostscript):

pdf2ps report.pdf - | ps2pdf - report-anonymized.pdf

This also leads to a complete recoding of the PDF. (I use this approach frequently to "sanitze" PDF with transparencies generated by OpenOffice, on which pdflatex often chokes).

  • 1
    One can also covert to PS and back to PDF, which is less drastic and I think should kill most private information, f there is any to kill. – Mariano Suárez-Álvarez Jan 23 '13 at 21:12
  • @MarianoSuárez-Alvarez: Good point, thanks. I have edited the answer accordingly. – Daniel Jan 23 '13 at 21:53
  • 1
    IIRC ps2pdf also accepts pdf as input (it's just a frontend to GhostScript), so you could try with only one step. – Martin Schröder Jan 24 '13 at 11:21
2

I can think of two possibilities, none unfortunately pdfLaTeX-based. First, I can add to the reply by @daniel by mentioning PStill with its PDF to raster plugin PDF2R. This converts the pdf to a raster pdf similarly to what was mentioned for ImageMagick. A second option would be to generate a PS-file and then use ps2pdf to generate the PDF.

0

From (web)security perspective this is an information leak. Imagine if you're using pdflatex to create PDF documents on your server. If you're using pdflatex with the flag --output-directory and include e.g. other PDF documents in your latex template which are loaded into your working directory, then this path will be also inside your PDF. Note: You need just to include e.g. another PDF document inside your document and it will already leak your path (--output-directory is not necessary for the leak, it allows to specify absolute paths).

enter image description here

Also you leak your pdflatex version and this needs to be fixed too, because again if you know which version of pdflatex is installed on your server, someone might use known exploits to attack you.

Examples: CVE-2018-17407, CVE-2017-17513, CVE-2016-10243

enter image description here

It doesn't matter if you installed pdflatex on a public server on a private PC, such informations should never be leaked.

You don't need some special tools like Adobe Acrobat Pro to investigate you PDF document - you can open it with a regular editor (or hexeditor) and search for paths & for strings latex, tex and filename. But don't edit PDF document in simple text editor (PDF format specifies a programming language (it is similar to postscript) where you can use indeed a simple text editor to create PDF documents), but PDF documents contain also binary data and you might break them if you edit complex PDF documents containing images and other resources. So hexeditor would be a better choice.


The best solution would be to remove info about pdflatex version etc. when hyperref package is used would be to add this line to you latex document (credit to NVaughan):

\hypersetup{
  pdfinfo={
  pdfproducer={},
  Title={},
  Subject={},
  Author={},
  }
}

To remove paths you could simply open PDF document in hexeditor and remove paths (keeping only the filename) from the PDF:

enter image description here

You can just grep your PDF document for those paths and then remove them with a script. I tested it and it worked - after editing the path I got a still valid PDF document.

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.