PDF layers (or “optional content”) are sections of content that can
be selectively viewed or hidden. Layers are used for items such
as CAD drawings, layered artwork, maps, and multi-language documents.
The layers of a document are shown in the Layers
navigation
panel of Adobe Acrobat (View > Navigation Panels > Layers
).
Each layer has a name and a default state (ON or OFF).
“pdfinfo” shows all layers and the default states.
$ pdfinfo -o layer itto.pdf # pdfinfo 4.0.0 Layer: Name=English, ObjNo=59, DefaultState=Off Layer: Name=Spanish, ObjNo=63, DefaultState=Off Layer: Name=French, ObjNo=55, DefaultState=Off Layer: Name=German, ObjNo=57, DefaultState=On Layer: Name=Italian, ObjNo=61, DefaultState=Off Layer: Name=Diagram, ObjNo=53, DefaultState=On
Some resources (such as images) are not shown by “pdfinfo” if they belong
to a layer that is hidden by default. The option -l <layerSelection>
can be used to modify the layer states, see 17.3 “Layer selection” below.
The PDF HandShake Acrobat plug-in always uses the currently selected layer states and therefore prints the same layers that Acrobat would print.
A layer selection can be used with
pdfinfo -l <LayerSelection> pdfprint -o layer=<LayerSelection>
to override the default states of the layers in a PDF document.
<LayerSelection>
is a string consisting of one ore
more directives separated by a colon (“:”). Each directive is
one of the following:
None: |
Set all layers to OFF. |
All: |
Set all layers to ON. |
name or +name: |
Set the layer named “name” to ON. |
-name: |
Set the layer named “name” to OFF. |
number or +number: |
Set the layer with object number “number” to ON. |
-number: |
Set the layer with object number “number” to OFF. |
Layer names are not unique. If multiple layers have the same
name, they are all modified by the name
directive.
By default, optional content is printed or omitted according to the
default layer states. The states can be overridden with the option
-o layer=<layerSelection>
.
$ pdfprint -P ppv -p pdf itto.pdf $ pdfprint -P ppv -p pdf -olayer=French:-German itto.pdf $ pdfprint -P ppv -p pdf -olayer=None:French:Diagram itto.pdf
The first command prints the German version of the document (layer “German” and “Diagram” are ON by default, see 17.1 “pdfinfo” example above). The second command prints the French version of the document by activating the layer “French” and deactivating the layer “German”. The third command also prints the French version, now by deactivating all layers and then activating “French” and “Diagram”.
See 17.3 “Layer selection” for the syntax of <LayerSelection>
.
By default, “layout” shows or hides optional content according to the default layer states. The states can be overridden with the “PDFLayer” attribute.
$ layout -l -oPrintColor=RGB -T PNGf itto.pdf itto-german.png $ layout -l -aPDFLayer=None:French:Diagram -oPrintColor=RGB -T PNGf itto.pdf itto-french.png
The first command creates an image of the German version of the document (layer “German” and “Diagram” are ON by default, see the 17.1 “pdfinfo” example above). The second command creates an image of the French version of the document.