GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / FlattenVisibleOCGs Method
Example





In This Topic
FlattenVisibleOCGs Method (GdPicturePDF)
In This Topic
Flattens all visible optional content group entries and removes content of all hidden ones in the currently loaded PDF document. That means content of all visible layers is flattened into the document and content of all hidden layers is removed.
Syntax
'Declaration
 
Public Function FlattenVisibleOCGs() As GdPictureStatus
public GdPictureStatus FlattenVisibleOCGs()
public function FlattenVisibleOCGs(): GdPictureStatus; 
public function FlattenVisibleOCGs() : GdPictureStatus;
public: GdPictureStatus FlattenVisibleOCGs(); 
public:
GdPictureStatus FlattenVisibleOCGs(); 

Return Value

A member of the GdPictureStatus enumeration. If the method has been successfully followed, then the return value is GdPictureStatus.OK.

We strongly recommend always checking this status first.

Remarks
This method is only allowed for use with non-encrypted documents.
Example
Flattening all visible layers and removing all hidden ones included in the current document.
Using gdpicturePdf As GdPicturePDF = New GdPicturePDF()
    gdpicturePDF.LoadFromFile("document.pdf", False)
    gdpicturePDF.FlattenVisibleOCGs()
    MessageBox.Show("The number of layers available: " + gdpicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information)
    gdpicturePDF.SaveToFile("output.pdf")
End Using
using (GdPicturePDF gdpicturePdf = new GdPicturePDF())
{
    gdpicturePDF.LoadFromFile("document.pdf", false);
    gdpicturePDF.FlattenVisibleOCGs();
    MessageBox.Show("The number of layers available: " + gdpicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
    gdpicturePDF.SaveToFile("output.pdf");
}
See Also