PdfOptionalContentGroup Class
Provides information about an optional content group (layer) of PDF document.
Optional content group (layer) is a collection of graphics that can be made visible or invisible dynamically.
Here is an example that shows how to render the PDF pages with the optional content groups:
''' <summary>
''' Renders PDF page with the optional content group.
''' </summary>
''' <param name="page">The page of PDF document.</param>
Public Shared Function RenderPdfPageWithOptionalContentGroup(page As Vintasoft.Imaging.Pdf.Tree.PdfPage) As Vintasoft.Imaging.VintasoftImage
' get PDF document of page
Dim document As Vintasoft.Imaging.Pdf.PdfDocument = page.Document
' if document has optional content groups then
If document.OptionalContentProperties IsNot Nothing AndAlso document.OptionalContentProperties.OptionalContentGroups IsNot Nothing Then
' get a list of optional content groups of PDF document
Dim allGroups As System.Collections.Generic.IList(Of Vintasoft.Imaging.Pdf.Tree.OptionalContent.PdfOptionalContentGroup) = document.OptionalContentProperties.OptionalContentGroups
' for each optional content group
For Each group As Vintasoft.Imaging.Pdf.Tree.OptionalContent.PdfOptionalContentGroup In allGroups
' set the optional content group as invisible
document.OptionalContentConfiguration.SetGroupVisibility(group, False)
Next
End If
' render PDF page
Dim image As Vintasoft.Imaging.VintasoftImage = page.Render()
' return the image of PDF page
Return image
End Function
/// <summary>
/// Renders PDF page with the optional content group.
/// </summary>
/// <param name="page">The page of PDF document.</param>
public static Vintasoft.Imaging.VintasoftImage RenderPdfPageWithOptionalContentGroup(
Vintasoft.Imaging.Pdf.Tree.PdfPage page)
{
// get PDF document of page
Vintasoft.Imaging.Pdf.PdfDocument document = page.Document;
// if document has optional content groups then
if (document.OptionalContentProperties != null &&
document.OptionalContentProperties.OptionalContentGroups != null)
{
// get a list of optional content groups of PDF document
System.Collections.Generic.IList<Vintasoft.Imaging.Pdf.Tree.OptionalContent.PdfOptionalContentGroup> allGroups =
document.OptionalContentProperties.OptionalContentGroups;
// for each optional content group
foreach (Vintasoft.Imaging.Pdf.Tree.OptionalContent.PdfOptionalContentGroup group in allGroups)
// set the optional content group as invisible
document.OptionalContentConfiguration.SetGroupVisibility(group, false);
}
// render PDF page
Vintasoft.Imaging.VintasoftImage image = page.Render();
// return the image of PDF page
return image;
}
Target Platforms: .NET9; .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5