I use the LaTeX typesetting system to compose e-books that I intend to sell on my website. I would like to be able to know which customer has leaked the file if it is ever available for free on the net. But I don't want to use DRM (people won't be able to easily copy and paste the file onto their e-readers, which is an important feature for me to have) and I don't want to use watermarks (it would alter the visible part of the file).

So I thought the best idea was to hide some information (like an unique identifier) in the output binary.

I don't know if it's possible but ideally I'd like it to:

  • not be obvious if someone quickly inspect the binary of the file (which excludes PDF keywords and comments),
  • be preserved by compression and format conversion (e.g., pdf -> djvu -> ps -> pdf).

Any help, even partial, would be greatly appreciated.

EDIT Steganography in Latex This question is really close to what I am trying to achieve but I don't want to introduce typos.

  • Welcome to TeX.SE, This is to general question and answer be used in your commercial activity ..., Please, be more specific, what is your problem, i.e. where you stuck in your effort.
    – Zarko
    Nov 17, 2022 at 12:35
  • @Zarko Is it a problem for this site that it is for commercial use? I don't plan to copy any of the answers, but just to be inspired by them. And I gave in my question the reason why the solutions I had thought of (comment, keyword, voluntary typos) don't follow my needs. Is there anything precise I forgot to mention? Thanks.
    – WQPub
    Nov 17, 2022 at 12:38
  • Maybe put some transparent number in a box somewhere outside the body text. It would not be visible and I guess upon inspecting the PDF, if placed in a sensible way, not directly detectable. If you dont want text, because it can be selected and this way discovered, you could place some transpartent pattern that is unique and, which would only be detectable if you inspect the PDF using some vector graphics software. But this is just an idée fixe, maybe not suitable in your case. Of course, if the PDF is converted into some JPG, these things would be gone. Nov 17, 2022 at 13:04
  • Alternatively randomly shift some characters/words by one pixel. As long as the text is not copy pasted it will persist.
    – user202729
    Nov 17, 2022 at 14:13
  • Note, that if you would not like to alter any visible part of the file, all information you hide will be disappeared after the format conversion pdf -> djvu -> pdf or pdf -> image -> pdf. In this regard, your requirements are contradictory.
    – Andrey L.
    Nov 18, 2022 at 10:31

1 Answer 1


One way to do this is to add metadata to the output pdf. Package hyperref allows you to do this using the command \hypersetup{} by passing it the pdfauthor={Bob Smith} option, for example. However, this method has the disadvantage of the metadata being visible, and thus modifiable, by anyone who cares to look at the file properties.

A better option would be to hide the data within the PDF file itself. PDFs, I believe, are very much like XML files, in that they have a sequence of fields and values. You can even embed entire files within the PDF file. So you should be able to fairly easily add an encrypted text file containing the customer's name or an order number, or some other kind of reference. Try googling for how to embed hidden data in a pdf to first figure out how it's done, then that should help you do some more targeted searches on CTAN or other package repositories.

Here are a couple possibly useful links:

Link 1

Link 2

Link 3

Finally this one might be what you're looking for.

  • 2
    You can (and should) put two UUID codes in metadata. The "documentID" is a unique identifier for the document (in the sense of title and author). The "instanceID" is per-copy. Do you have the technology to dynamically alter the instanceID each time the file is downloaded, and record the visitor's address (UTL or Email) somehow? Most folks do not have that technology, but if you have your own site on a commercial server, it is possible. Outside the realm of TeX.
    – user287367
    Mar 9, 2023 at 17:57

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .