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

-
I don't think any original path names are included in the PDF. You might want to clear all PDF info fields, so that the reader doesn't even know that the PDF got created by pdftex. –  Martin Scharrer Jan 23 '13 at 21:09
Please have a look at this question: Are comments safely hidden once the document is compiled? and especially at that answer: Are comments safely hidden once the document is compiled? –  Keks Dose Jan 23 '13 at 21:18
Usually no, except maybe the PDF metadata as already mentioned. One way to demonstrate this is to uncompress the PDF and then examine it, either manually (for small test documents) or using eg grep for known directory names etc. –  cyberSingularity Jan 24 '13 at 0:58
See this blog post to see how to use pdftk to strip metadata from PDF files. –  Aditya Jan 27 '13 at 23:00
Since you have some responses below that seem to answer your question, please consider marking one of them as ‘Accepted’ by clicking on the tickmark below their vote count (see How do you accept an answer?). This shows which answer helped you most, and it assigns reputation points to the author of the answer (and to you!). It's part of this site's idea to identify good questions and answers through upvotes and acceptance of answers. –  Martin Schröder Feb 27 at 14:13

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.

There is currently no way to disable the writing of these keys.

If you want to remove these keys from a PDF, the easiest way is probably a conversion to PostScript followed by a conversion to PDF.

-
Is there a flag to turn this off somewhere? This is one way to leak personal information, I guess. –  Mariano Suárez-Alvarez 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
@MarianoSuárez-Alvarez: Not yet. –  Martin Schröder Jan 24 '13 at 7:30
@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).

-
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

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

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.

-

For ConTeXt the answer, which is not implemented at time of writing, will be:

\disabledirective[backend.ptex]

See the mailing list thread for details.

-