Reference Guide
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()
        oGdPicturePDF.LoadFromFile("document.pdf", False)
        oGdPicturePDF.FlattenVisibleOCGs()
        MessageBox.Show("The number of layers available: " + oGdPicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information)
        oGdPicturePDF.SaveToFile("output.pdf")
    End Using
    using (GdPicturePDF gdpicturePdf = new GdPicturePDF())
    {
        oGdPicturePDF.LoadFromFile("document.pdf", false);
        oGdPicturePDF.FlattenVisibleOCGs();
        MessageBox.Show("The number of layers available: " + oGdPicturePDF.GetOCGCount(), "Flattening visible layers", MessageBoxButtons.OK, MessageBoxIcon.Information);
        oGdPicturePDF.SaveToFile("output.pdf");
    }
    See Also