Suppose I want to generate 100 apparently identical PDF files, where I hide some kind of key, in order to distribute them among 100 different people. Now I detect an online shared copy of the document and I need to track who of that 100 people uploaded it.

My first approach would be to compile them in some way (maybe passing parameters through command line?) to, for example, include among its hyperref PDF keywords some "UserNr001", "UserNr002", ... tags.

What I'm asking for is a more subtle way to mark a PDF from the .tex file.

Maybe related: Digital signature and How do I create a PDF file that can be digitally signed?.

  • If you fear that something is going to leak, PDF is certainly not the proper medium to protect your information. So this is a futile attempt to mark the leak source. – percusse Oct 6 '14 at 22:39
  • Could you add some reasons, @percusse ? – Andrestand Oct 7 '14 at 8:52
  • 1
    An example; if the other side of the game is aware of this confidentiality concern of yours, they can simply take the screenshot of the pages and include the PDF as an image. Metadata is almost impossible to maintain with PDF document format. There are hacks for almost everything. Alternatively we can export the PDF without the metadata as a clean copy. – percusse Oct 7 '14 at 9:08

PDF information entries

Additional entries can be set by hyperref, e.g.:

    User={John Doe},
    % ...

Some PDF viewers are not able to show non-standard entries, but others do (AFAIK newer AR/Win versions).

Adding data to the PDF data structures

A key value pair can be put into a dictionary, e.g.:

\pdfcatalog{/User (John Doe)}

Or even an object can be made:

\immediate\pdfobj{(John Doe)}
\pdfcatalog{/User \the\pdflastobj\space 0 R}

Important issues are:

  • It should be valid PDF code, otherwise PDF viewers might complain. The example used a name object for the key '/User' and a PDF string (John Doe) for the value.
  • The data should be linked to an existing used object. The latter example links the object, created by \pdfobj to the Catalog. Otherwise unused object could be removed by post-processing.

Using/modifying existing data

The creation date of the document could be changed via \pdfcreationdate to assign different seconds for the users.

Changing the output

The previous methods would not survive a print of the PDF document into a new PDF document. Therefore the output could be slightly changed, e.g. by making inter-word spaces larger/smaller at some places for the different versions.

Data protection

Instead of plain code as in the examples above (for simplicity) I would use some kind of MD5/SHA/... or encrypted versions of the data and add them safely as hex dump.

Then, if you find an online copy, you can verify, that the embedded data are correct and not altered by the uploader. Otherwise an uploader could maliciously alter the data to claim someone else.

P.S.: Example code is given for pdfTeX, the other driver need other commands/specials, if they support the same feature.


If you want to do this in a discreete and hard to alter fashion, I would suggest having an image in your PDF, in which you hide the information you want using steganography (which uses low order bits in the image pixels).

You can then extract said image again when given a distributed version and look at the pixel values to decode the information hidden.

Not the answer you're looking for? Browse other questions tagged or ask your own question.