GdPicture.NET Reference Guide
BeginMarkedContent Method (GdPicturePDF)
Example 





GdPicture14 Namespace > GdPicturePDF Class : BeginMarkedContent Method
The ID (unique identifier) of the required OCG entry, that you want to associate the marked-content with.
Begins a marked content sequence of operations associated to an optional content group specified by its unique identifier (ID).
Syntax
'Declaration
 
Public Function BeginMarkedContent( _
   ByVal OCGId As Integer _
) As GdPictureStatus
public GdPictureStatus BeginMarkedContent( 
   int OCGId
)
public function BeginMarkedContent( 
    OCGId: Integer
): GdPictureStatus; 
public function BeginMarkedContent( 
   OCGId : int
) : GdPictureStatus;
public: GdPictureStatus BeginMarkedContent( 
   int OCGId
) 
public:
GdPictureStatus BeginMarkedContent( 
   int OCGId
) 

Parameters

OCGId
The ID (unique identifier) of the required OCG entry, that you want to associate the marked-content with.

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
Please note that this method is only allowed for use with non-encrypted documents.

You also need to be aware that the newly created layer is not presented in any user interface since we do not support this functionality yet.

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

Reference

GdPicturePDF Class
GdPicturePDF Members
EndMarkedContent Method
NewOCG Method
DeleteOCG Method
GetOCGCount Method
GetOCG Method
SetImageOptional Method
SetFormFieldOptional Method