DsPdfViewer supports viewing different PDF elements such as layers, structured content or XFA content.
PDF documents can contain content in different layers (also known as optional content) and a particular layer can be made visible or invisible as required. DsPdf allows you to work with layers and set their properties, refer Layers for more information.
In DsPdfViewer, you can examine these layers and show or hide content associated with each layer by using the 'Layers' panel, provided in its sidebar. The viewer also saves visibility state of the layers on pressing the 'Save' button.
The Layers panel can be displayed by enabling the addLayersPanel in the viewer using below code:
Index.cshtml |
Copy Code
|
---|---|
viewer.addLayersPanel(); |
The below GIF shows a PDF document containing 'English' and 'Russian' language layers and how they can be made visible or invisible using the DsPdfViewer Layers panel.
According to the PDF specifications 2.0, groups of optional content layers in a PDF can be associated with specific ranges of magnification (zoom values) at which they should be made visible in a compliant viewer. DsPdfViewer supports loading of such zoom-dependent layers in a PDF, and the layers will be automatically shown or hidden depending on the current zoom factor.
The visibility flags in the viewer reflect the zoom factor changes applied to the zoom-dependent layers by checking or unchecking the checkbox for visible or not visible layers, respectively, depending on the current zoom value of the viewer. DsPdfViewer implements the said behavior based on PDF specifications 2.0, which state that zoom is a dictionary specifying a range of magnifications at which the content in this optional content group is best viewed. Zoom contains one or both of the following:
min: The minimum recommended magnification factor at which the group shall be ON. The default value is 0.
max: The maximum magnification factor below which the group shall be ON. The default value is infinity.
The max zoom factor value is excluded, which means that if the max zoom factor for a layer is 2 (200%), and the view zoom is 200%, then the layer will not be visible. The following table demonstrates relationships between view zoom value and layer visibility:
Layer min and max Values | View Zoom Value | Result Layer Visibility |
---|---|---|
min: 1 (100%) max: 2 (200%) |
99% | Not Visible |
min: 1 (100%) max: 2 (200%) |
100% | Visible |
min: 1 (100%) max: 2 (200%) |
150% | Visible |
min: 1 (100%) max: 2 (200%) |
199% | Visible |
min: 1 (100%) max: 2 (200%) |
200% | Not Visible |
min: 1 (100%) max: 2 (200%) |
201% | Not Visible |
The below GIF image depicts the visibility of optional zoom-dependent layers in a PDF document depending on the zoom value of the viewer:
Limitation
The editing of the layers is not supported, i.e., you cannot change the visibility of a layer using the Layers panel if the visibility of the layer depends on the zoom factor.
DsPdf allows you to create or modify tagged PDF documents. Refer Tagged PDF to know more. You can use the Structure Tree panel of DsPdfViewer to load a tagged PDF and navigate between the available structured elements such as heading, table, paragraph etc.
The below image shows the Structure Tree panel when a tagged PDF is opened in DsPdfViewer. The number in the page header indicates the total number of items in the structure tree on that page (excluding the root element).
The below code example shows how to enable the Structure Tree panel by using the addStructureTreePanel method.
Index.cshtml |
Copy Code
|
---|---|
var viewer = new DsPdfViewer(selector); viewer.addStructureTreePanel(); viewer.open("read-tags.pdf"); |
XFA stands for XML Forms Architecture and can be used to enhance the processing of web forms. Refer XFA to know more.
DsPdfViewer supports displaying PDF documents containing XFA content, by default. It also allows you to select and copy the content from XFA forms. Moreover, DsPdfViewer lets you use links, reset, submit and print the XFA form if these JavaScript actions are included in the form. To disable the rendering of XFA content in PDF, you can use the enableXfa option as shown in the below code example:
Index.cshtml |
Copy Code
|
---|---|
// Turn off XFA forms rendering. var viewer = new DsPdfViewer(selector, { enableXfa: false }); |
Limitation