How can I embed information in an existing PDF document and keep it private?
Estimated Reading Time: 2 MinutesYou might want to add content to the metadata of a PDF document that remains hidden from most viewers, and is only available to a client who knows to look for that content. This would not necessarily need to be encrypted; you simply want to add content that doesn’t show up when the PDF document is opened in Adobe Acrobat or Adobe Reader, or some other viewing tool.
For example, you might want to add a tag to a document so that you can track its movement. Or maybe you want to want to pass information about a PDF document to another party, such as the office or department that created the PDF document, or an expiration date for the content in the PDF document and when the PDF will be replaced with more current information.
You can add information like this to the Comments within the PDF metadata. The percent sign, outside of a string or stream, is the comment indicator in PDF, just as it is with PostScript. Note that except for these entries:
%PDF?1.x %%EOF
PDF comments have no syntax. So you can format comments in a PDF document however you like, and the PDF format offers no equivalent of the PostScript Document Structuring Conventions (DSC). Keep in mind, however, that applications that edit PDF documents do not necessarily preserve comments added to a PDF document. When the PDF document is saved again, the comments may be removed.
It is also possible to store information in unused keys of a dictionary object. You can embed a value or stream into a dictionary object but not make use of the object in the PDF. Adobe Acrobat or Reader or other conforming viewing tools will ignore the unused dictionary object. If, however, an application reads the PDF and saves it to a new file, the unused dictionary entry could be removed.
The recommended approach is to add information to a page-piece dictionary, which is specifically designed to hold private data. The data may be associated with a page or XObject via an optional PieceInfo entry or with the document by means of a PieceInfo entry in the document catalog. For example, Adobe Illustrator uses content posted to a PieceInfo entry in a page or XObject to assign information to a document that only Illustrator can read.
To learn more, see Section 14.5, “Page-Piece Dictionaries,” in the ISO 32000 Reference.