Which is the best way to create a PDF document with optional content groups or "Layers"?
Estimated Reading Time: 1 MinutesOptional Content is a feature that permits content to be made visible or invisible, based on switch set when being viewed in Adobe Acrobat or other viewing tool.
Optional Content, or “layers,” are a useful way to present information when opening a PDF file. For example, you could create a brochure with multiple layers offering the same content but in different languages. The first layer would be the blank background page. The resulting PDF file could be set up, with some extra program code, to select the appropriate layer with French or Spanish or English, depending on the language of the reader, and then display that language in the PDF file.
For more information see Section 8.11, “Optional Content,” in the ISO 32000 Reference, page 222.
Basically, it consists of an Optional Content Properties Dictionary added to the document root. This dictionary contains an array of Optional Content Groups (OCGs), each describing a set of information and each of which may be individually displayed or suppressed, plus a set of Optional Content Configuration Dictionaries, which give the status (Displayed or Suppressed) of the given OCGs. Finally, within any content stream, marking operators may in turn be surrounded by a new set of operators, declaring them to be content of a given Optional Content Group.
Within the viewer, optional content may be base-selected or ignored by group or by configuration.
There is complete support for Optional Content groups in APDFL at the PDFEdit level. DLI does not support Optional Content.