PDF Layers in PDF files
PDF Layers (or optional content) is a feature which allows some content to be made visible or invisible in the PDF. Its uses include PDF overlays, having alternate languages appear and adding details to diagrams.
How do PDF Layers work
PDF Layers include a set of ‘lables’ in the PDF data and a status for each PDF layer (visible or invisible). This can be changed and the page decoded again so the PDF Layer appears.
There is documented java code showing how to do this in org.jpedal.examples.viewer.gui.SwingGUI. This is a good starting point for experimenting with this feature and also creates a display panel in the Java PDF Viewer to switch PDF Layers on/off.
How to access PDF Layers in your java code
Two methods in org.jpedal.objects.layers.PdfLayerList provide finer control
public String getNames() returns a list of PDF Layer names.
public void setVisibleLayers(String layerNames) allows a user to pass in a set of names and only those will be displayed (must be called before page decoded/printed). Passing in null makes them all disappear.