Available Now: Explore our latest release with enhanced accessibility and powerful IDP features
By Roger Dunham | 2024 Mar 08
7 min
Tags
pdf layers
webviewer
pdf viewer
PDF layers, also known as Optional Content Groups (OCGs), are a part of PDF functionality and have been around for almost 20 years. They allow content to be broken into separate parts so the user can view just a subset of those parts. This can be extremely useful with CAD drawings, for example, since it allows the user to focus on those aspects of the drawing that they are interested in, without being distracted by things that are not currently important.
Their possibilities, however, go much further. For example, you could add multi-language text into the same PDF, or have labels that relate to an image that can be shown, or hidden, as required.
In the previous article in this series, we looked at how simple layers were supported in a range of PDF viewers. In this article, we look at the handling of nested layers (layer groups) within PDFs. The next article will cover multipage nested layers.
Nesting is great because it allows a group of layers to be shown or hidden together as a set, while still allowing the individual items to be controlled separately if preferred.
This adds a layer of complexity (pun intended) that not all viewers handle well.
Read on to learn how a range of PDF readers handle a PDF that contains nested layers, and why the Apryse WebViewer is a standout solution.
The sample PDF was created using ArcGIS from ESRI and contains mapping data for parts of the western USA.
For this article, the primary interest is the scale bar, since that is composed of nested layers.
You can see the entire scale bar including the ratio and units in both miles and kilometers.
Figure 1 – The scale bar with all layers visible
By clicking on the layers, it is possible to hide the kilometer scale bar.
Figure 2 – The scale bar can be modified within the PDF by hiding the kilometer scale bar.
Alternatively, the mile scale bar can be hidden.
Figure 3 – The same PDF, but with the miles scale bar hidden so that only kilometers are visible
If you want, you can click on the Scale Bar group to hide all the nested layers.
Figure 4 – The same PDF with all of the nested layers that comprise the scale bar hidden
In the previous article, we saw that Chrome, Edge, PDF.js Express, Aspose, PDFSimpli, and Allinpdf do not support layers, so we will not look at them again. As such, the tools used in this test are those that successfully worked with simple layers.
The following browsers were evaluated:
Three within-browser (Chrome) options were reviewed:
Two standalone desktop tools were reviewed:
Explore how to effectively manage headers and footers in your PDF to DOCX transformations.
The following features were used to assess how well a PDF viewer works with layers:
The Scale Bar and WEBMAP_MAP_FRAME layers both contain nested layers. It should be possible to show or hide any individual layer independently of other layers in the same group.
For example, in the Scale Bar group, it should be possible to show none, some, or all of the Scale text, Scale Line (miles) and Scale Line 1 (kilometers) layers in any arbitrary way.
Xodo makes this a breeze.
Figure 5 – A correct result in Xodo: Any individual layer can be shown or hidden. In this case, “Scale Line 1” is hidden but the other layers are shown.
A bad result, on the other hand, is when hiding one layer affects another, even though they should be independent, or when some layers are not shown in the Layers Panel.
PDF Studio Pro, for example, has several layers missing from the Layers Panel. For example, the Scale Bar Text is not selectable, nor are the individual layers within the WEBMAP_MAP_FRAME layer group.
Figure 6 – PDF Studio Pro allows some layers to be shown/hidden, but layer groups are not supported. Additionally, some layers are not available for selection like “Text.”
PSPDFKit also has some kind of problem. It looks great when the PDF is first loaded, with layer groups being correctly shown.
Figure 7 – the PSPDFKit demo page showing the PDF with layer groups
However, any attempt to toggle one of the scale bars results in the entire map becoming invisible, without any obvious way to re-enable it.
Figure 8 – Making the kilometer scale line invisible also made the map disappear in PSPDFKit.
This test checks that when a layer group is hidden, all the nested layers are hidden. All of the PDF readers passed this test.
The test checks that if a nested layer is hidden, the entire group is hidden. It also checks that when the group is made visible again, no previously hidden layers have become visible.
Apryse WebViewer and Xodo do a great job of this. If a layer is hidden (e.g. Scale Line 1), the entire Scale Bar is hidden. When the Scale Bar is made visible again, Scale Line 1 is still hidden. Exactly what you would expect.
Figure 9 – Apryse WebViewer and Xodo set the standard. After hiding and reshowing a layer group, layers that were previously hidden are still hidden.
On the other hand, if the same test is done in PSPDFKit, when Scale Bar is made visible again, Scale Line 1 (kilometers) has incorrectly become visible, even though previously it was hidden.
Figure 10 – PSPDFKit with the entire scale bar correctly hidden
Figure 11 – All of the nested layers are incorrectly visible, even if they had been hidden before the group was hidden.
That would be immensely annoying if you had carefully selected some layers to be visible, and others hidden, in a complex PDF, and then inadvertently toggled the layer group.
This is, of course, a subjective question. The test in this case is whether it is obvious which layers are visible, which are hidden, and which are grouped.
The layers panel in WebViewer (which is also used within Xodo.com) makes it clear which layers are grouped as well as which are visible.
Figure 12 – The WebViewer UI clearly shows whether layers are grouped and whether they are visible.
Firefox supports nested layers – sort of. It is not clear which layers are layer groups, or which layers are in which group. Furthermore, when a parent layer group is hidden the nested layers are correctly hidden (great!), but the UI does not reflect this (bad). This can be extremely confusing.
Figure 13 – In Firefox, the nested layers are shown as “Additional Layers.” it is not obvious that “Scale Line” and “Scale Line 1” belong to “Scale Bar,” which is currently hidden.
Qoppa PDF Studio Pro doesn’t support nested layers, so it was not included in this part of the review.
The following table summarizes the test results. If layers matter to you, you’ll want to choose a PDF viewer that has as many green cells as possible.
Check out our blog post if you'd like to learn how to create new PDFs from each layer.
PDF nested layers offer one way to make complex PDFs simpler to understand, but only if the correct PDF viewer is used. While Firefox supports layers in a rudimentary way, it is difficult to identify the relationships between layers.
In-browser and desktop tools, such Apryse WebViewer and Acrobat, offer much greater support. But even these tools aren’t equal. PSPDFKit, for example, has a confusing UI and some issues with how it supports nested layers – incorrectly hiding data – which can lead to confusion and wasted time.
Apryse WebViewer stands out as a powerful, highly functional product that is easy to add to your own apps.
But don’t just take our word for it, try out the functionality at the Apryse showcase and then have a look at the many samples that illustrate how to get started.
Alternatively, you can try out the SaaS option at Xodo.com.
When you are ready to start, check out the SDK documentation to get going quickly. Don’t forget, you can also reach out to us on Discord if you have any issues.
Tags
pdf layers
webviewer
pdf viewer
Roger Dunham
Share this post
PRODUCTS
Enterprise
Small Business
Popular Content