Skip to Content

How can I embed information in an existing PDF document and keep it private?

Estimated Reading Time: 2 Minutes

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

We demonstrate how to add attachments to a PDF document with the sample program AddAttachment provided with Adobe PDF Library.

If you don’t care if the information or document you append to a PDF is displayed in a viewing tool when opening the PDF document, that makes the process somewhat easier. You can simply embed the 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, and that application specifies garbage collection, the unused dictionary could be removed.

You may also decide to add information to a page-piece dictionary, a dictionary for your own use within a PDF document. 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, page 551.

How can I embed information in an existing PDF document and keep it private?
  • COMMENT

  • Get notified when new articles are added to the knowledge base.