Making an anonymous PDF file using PDFLaTeX

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)

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
• +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
• 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
• @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

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 when examining the file with Adobe Acrobat Pro. (In this sense, PDFs produced with `PDFLaTeX` and `XeLaTeX` are more anonymous than those produced by, say, MS Word.)

However, if you wish to erase even 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).

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

``````\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`.

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).

• 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
• 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

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.

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.