Dim caption As String = "Example: BeginOCGMarkedContent"
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: BeginOCGMarkedContent";
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();