Available Now: Explore our latest release with enhanced accessibility and powerful IDP features
By Roger Dunham | 2024 Mar 06
8 min
Tags
pdf layers
webviewer
cad
PDF layers, also known as Optional Content Groups (OCGs), are a great addition to PDF functionality and have been around for almost 20 years. When used in conjunction with a PDF viewer, layers allow for the creation of customizable views within PDF documents.They allow content to be broken into separate parts so the user is able to 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.
But not all PDF viewers work in the same way, and PDF layer support is patchy, to say the least.
In this article we will look at how a range of PDF readers handle a PDF that contains layers, and how the Apryse WebViewer is a standout solution.
In the next article in this series, we will look at nested layers and the handling of layers in multipage documents. The third article will cover multipage nested layers. Then, we'll look at how to create a single PDF from each layer.
Start with our intro to PDF layers in WebViewer.
For this article, a PDF has been created that has five layers, each of which relates to a functionality layer within an architectural CAD drawing.
Two of the layers are shown by default, and three hidden. One of the visible layers, HVAC, has been locked, so that the user cannot hide it, and one of the hidden layers, Electrical, has been locked so that the user cannot show it. The intention is that the user can choose which other layers to show or hide.
The data is similar to, but slightly different from, that used in the Apryse CAD support showcase demo.
If that seems a bit confusing, it will all become clear when we start to look at the data. Each of the layers is a different color – so for example, if we are looking at just the Architecture (brown), and the HVAC (pink), we will see something like this:
Figure 1 – The test PDF with just two layers visible
However, if the Pipework (green and blue) and Equipment (gray) are also enabled, the same PDF will look different, and potentially rather cluttered.
Figure 2 – The same PDF with more layers enabled. The Electrical layer is locked, so the user cannot make it visible.
As we look at a range of PDF Viewers, we will see that not all of them behave the same way.
The following browsers were tested:
Seven 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 were assessed to test how well a PDF viewer works with layers:
The sample file contains a mix of visible and hidden layers. Only the visible ones should be shown when the PDF is first displayed. A good result would consist of just those layers being visible.
Figure 3 – A correct result when verifying that only the layers specified as visible are shown
A bad result, on the other hand, is when different layers are visible when the PDF is opened – either layers that should be hidden are shown, or ones that should be visible are hidden.
Figure 4 – An incorrect result with all the layers visible. This occurs with PDF.JS Express, PDFSimpli and Allinpdf.
Irrespective of what layers are shown when the PDF opens, is it possible to show or hide specific layers?
Since some of the layers are locked within the PDF, it should not be possible to toggle either HVAC or Electrical layers, but we will look at those in the next section.
Figure 5 – Some viewers like Apryse WebViewer allow you to see which layers are visible and to work with them.
Some simple viewers don’t have any method for working with layers. Chrome, for example, displays the default layers, but it is not possible to see or hide specific layers.
Figure 6 – Some viewers like Chrome do not allow the user to work with layers.
The PDF was deliberately created to have some layers that were locked so that the visibility cannot be changed. The Electrical layer should never be visible, and the HVAC layer should always be visible.
With some of the tools it is obvious that this is the case, and testing confirms this.
Figure 7 – Apryse WebViewer makes it clear that some layers are locked, and this is correctly enforced.
Some other tools, however, allow the user to toggle layers, even though they are specified as being locked.
Figure 8 – PSPDFKit allows users to enable or disable any layer, even ones where this should not be possible. In this case, the Electrical layer (blue) has been incorrectly enabled.
This is, of course, a subjective question. The test here is whether it is clear which layers are visible, which are hidden, and which are locked.
The layers panel in WebViewer (which is also used within Xodo.com) makes it clear which layers are locked, which can be toggled, and at the same time makes it obvious which layers are visible and which are not.
Figure 9 – The WebViewer UI clearly shows whether layers are locked and whether they are visible.
The panel in Qoppa PDF Studio Pro uses gray text to show that a layer is locked. However, locked layers that are visible are still marked as hidden, so although the functionality is correct, the UI is confusing.
Figure 10 – In PDF Studio Pro, the HVAC layer, although locked, is actually visible, but the UI suggests that it is hidden.
PSPDFKit appears to follow the idea that gray text means that the layer is locked. However, in PSPDFKit, gray text actually means that the layer is hidden.
In fact, layer locking, as specified within the PDF, is not correctly supported.
In addition, the UI is confusing – it is possible to “lock” a layer within the UI, but that appears only to prevent inadvertent toggling of visibility for the layer.
Figure 11 – The UI in PSPDFKit is confusing. Gray text suggests that options are disabled, but they are not. And the lock suggests that the layer is locked. While it is, that is a UI lock, not one specified from the PDF.
Adobe Acrobat Reader usually has a great UI, but in this case it is confusing. The check box that indicates layer visibility by displaying an eye has been reused to also show whether the layer is locked.
As such, it is not possible, without hovering a mouse over the checkbox, to tell whether a locked layer is or is not visible. At some point, that confusion could result in a lot of wasted time.
Figure 12 – The Adobe Acrobat Reader UI shows that Electrical and HVAC layers are locked, but there is nothing obvious to indicate that HVAC is visible, while Electrical is not.
Unlock the Best Viewing Experience - Discover How Apryse Tools Can Seamlessly Convert PDFs to HTML
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.
PDF Layers can make complex PDFs simpler to understand, but only if the correct PDF viewer is used. With some viewers, the user may see information that the creator did not intend them to see, while also being unable to delve into the layers of information in the way that was intended.
While Firefox supports layers in a rudimentary way, the other browsers have very limited built-in support.
In-browser and desktop tools, like Apryse WebViewer and PDF Studio Pro, offer much greater support. But even with such tools, not all are equal. Some, like PSPDFKit, have confusing UIs or do not correctly support locked layers.
Apryse WebViewer, however, 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 get started, see the documentation for the SDK 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
cad
Roger Dunham
Share this post
PRODUCTS
Enterprise
Small Business
Popular Content