Back to Devexpress

PdfDocumentFacade.OptionalContentVisibility Property

officefileapi-devexpress-dot-pdf-dot-pdfdocumentfacade-92f4e43a.md

latest3.7 KB
Original Source

PdfDocumentFacade.OptionalContentVisibility Property

Provides access to visibility settings of optional content (layers).

Namespace : DevExpress.Pdf

Assembly : DevExpress.Pdf.v25.2.Core.dll

NuGet Package : DevExpress.Pdf.Core

Declaration

csharp
public PdfOptionalContentVisibility OptionalContentVisibility { get; }
vb
Public ReadOnly Property OptionalContentVisibility As PdfOptionalContentVisibility

Property Value

TypeDescription
PdfOptionalContentVisibility

A PdfOptionalContentVisibility object that allows you to manage layers visibility.

|

Remarks

Use the PdfDocumentFacade.OptionalContentVisibility.Groups property to access PdfOptionalContentGroupVisibility objects and manage visibility settings of individual layers.

Important

A PDF document stores only default optional content configuration. This means that layer visibility is not preserved when you save the document. Visibility settings are applicable only when you preview the document in a PDF Viewer component, or print the document, or export it to an image.

The following code snippet hides two layers in the “PdfLayers.pdf” document and displays the third layer:

csharp
using DevExpress.Pdf;
using System;
using System.Linq;
using DevExpress.Drawing;

using (PdfDocumentProcessor processor = new PdfDocumentProcessor()) {
    processor.LoadDocument("PdfLayers.pdf");

    // Set visibility settings for each layer contained in a document.
    processor.DocumentFacade.OptionalContentVisibility.Groups[0].Visible = false;
    processor.DocumentFacade.OptionalContentVisibility.Groups[1].Visible = false;
    processor.DocumentFacade.OptionalContentVisibility.Groups[2].Visible = true;

    // Print the document.
    DXBitmap bitmap = processor.CreateDXBitmap(1, 1000);
    PdfPrinterSettings pdfPrinterSettings = new PdfPrinterSettings();
    processor.Print(pdfPrinterSettings);
}
vb
Imports DevExpress.Pdf
Imports System
Imports System.Linq
Imports DevExpress.Drawing

Using processor As New PdfDocumentProcessor()
    processor.LoadDocument("PdfLayers.pdf")

    ' Set visibility settings for each layer contained in a document.
    processor.DocumentFacade.OptionalContentVisibility.Groups(0).Visible = False
    processor.DocumentFacade.OptionalContentVisibility.Groups(1).Visible = False
    processor.DocumentFacade.OptionalContentVisibility.Groups(2).Visible = True

    ' Print the document.
    Dim bitmap As DXBitmap = processor.CreateDXBitmap(1, 1000)
    Dim pdfPrinterSettings As New PdfPrinterSettings()
    processor.Print(pdfPrinterSettings)
End Using

Refer to the following topic for more information on how to control layer visibility: Manage Visibility of Layers (Optional Content Groups).

See Also

PdfDocumentFacade Class

PdfDocumentFacade Members

DevExpress.Pdf Namespace