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





In This Topic
EndOCGMarkedContent Method (GdPicturePDF)
In This Topic
Ends the marked content, that has been previously defined by using the GdPicturePDF.BeginOCGMarkedContent method.
Syntax
'Declaration
 
Public Function EndOCGMarkedContent() As GdPictureStatus
public GdPictureStatus EndOCGMarkedContent()
public function EndOCGMarkedContent(): GdPictureStatus; 
public function EndOCGMarkedContent() : GdPictureStatus;
public: GdPictureStatus EndOCGMarkedContent(); 
public:
GdPictureStatus EndOCGMarkedContent(); 

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
How to associate a graphical marked content with an optional content group.
Dim caption As String = "Example: EndOCGMarkedContent"
Dim gdpicturePDF As New GdPicturePDF()
If (gdpicturePDF.NewPDF() = GdPictureStatus.OK) AndAlso
   (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
    Dim ocgID As Integer = gdpicturePDF.NewOCG("Marked Content Layer")
    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter)
        gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
        Dim fontName As String = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold)
        If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetLineColor(0, 0, 255) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetLineWidth(2) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetTextSize(30) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.SetFillColor(138, 43, 226) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.BeginOCGMarkedContent(ocgID) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, False, True) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", True) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.EndOCGMarkedContent() = GdPictureStatus.OK) Then
            If gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") = GdPictureStatus.OK Then
                MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption)
            Else
                MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption)
        End If
    Else
        MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
    End If
Else
    MessageBox.Show("The document can't be created.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: EndOCGMarkedContent";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if ((gdpicturePDF.NewPDF() == GdPictureStatus.OK) &&
    (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
    int ocgID = gdpicturePDF.NewOCG("Marked Content Layer");
    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
    {
        gdpicturePDF.SetMeasurementUnit(PdfMeasurementUnit.PdfMeasurementUnitMillimeter);
        gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
        string fontName = gdpicturePDF.AddStandardFont(PdfStandardFont.PdfStandardFontTimesBold);
        if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
            (gdpicturePDF.SetLineColor(0, 0, 255) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetLineWidth(2) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetTextSize(30) == GdPictureStatus.OK) &&
            (gdpicturePDF.SetFillColor(138, 43, 226) == GdPictureStatus.OK) &&
            (gdpicturePDF.BeginOCGMarkedContent(ocgID) == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawRoundedRectangle(20, 20, 100, 50, 5, false, true) == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawTextBox(fontName, 20, 20, 120, 72, TextAlignment.TextAlignmentCenter, TextAlignment.TextAlignmentCenter, "GdPicture.NET", true) == GdPictureStatus.OK) &&
            (gdpicturePDF.EndOCGMarkedContent() == GdPictureStatus.OK))
        {
            if (gdpicturePDF.SaveToFile("test_MarkedContentLayer.pdf") == GdPictureStatus.OK)
            {
                MessageBox.Show("The example HAS been followed successfully and the file has been saved.", caption);
            }
            else
            {
                MessageBox.Show("The example HAS been followed successfully, but the file can't be saved. Status: " + gdpicturePDF.GetStat().ToString(), caption);
            }
        }
        else
        {
            MessageBox.Show("Error occurred when creating the marked content. Status: " + gdpicturePDF.GetStat().ToString(), caption);
        }
    }
    else
    {
        MessageBox.Show("The NewOCG() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
    }
}
else
{
    MessageBox.Show("The document can't be created.", caption);
}
gdpicturePDF.Dispose();
See Also