BeginMarkedContent Method (GdPicturePDF)
In This Topic
Begins a marked content of operations in the page content associated to a structure element of the required structure type
related to the document's tag structure tree of the currently loaded PDF document.
Syntax
Parameters
- StructType
- A name of the structure type for the newly created marked content element.
Please refer to the PDF Reference, Section "Standard Structure Types", for the names of the standard structure types.
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.
Example
How to create a marked content structure element of the Artifact category containing some graphics.
Dim caption As String = "Example: BeginMarkedContent"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContent("Artifact") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(50, 55, 330, 55) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: BeginMarkedContent";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContent("Artifact") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(50, 55, 330, 55) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
Example
How to create a marked content structure element of the Artifact category containing some graphics.
Dim caption As String = "Example: BeginMarkedContent"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft)
'This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document")
Dim fontResName As String = gdpicturePDF.AddTrueTypeFontU("Arial", False, False, True)
If (gdpicturePDF.GetStat() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetFillColor(Color.Blue) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.SetTextSize(16) = GdPictureStatus.OK) Then
Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
Dim tagParagraph As Integer = gdpicturePDF.NewTag(tagRootID, "P")
If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
If (gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) AndAlso
(gdpicturePDF.BeginMarkedContent("Artifact") = GdPictureStatus.OK) AndAlso
(gdpicturePDF.DrawLine(50, 55, 330, 55) = GdPictureStatus.OK) AndAlso
(gdpicturePDF.EndMarkedContent() = GdPictureStatus.OK) Then
Dim status As GdPictureStatus = gdpicturePDF.SaveToFile("test_tagged.pdf")
If status = GdPictureStatus.OK Then
MessageBox.Show("Your tagged PDF document has been successfully created.", caption)
Else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption)
End If
Else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
Else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
gdpicturePDF.CloseDocument()
Else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption)
End If
End Using
string caption = "Example: BeginMarkedContent";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
(gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
{
gdpicturePDF.SetOrigin(PdfOrigin.PdfOriginTopLeft);
//This is required to have a valid PDF_UA document.
gdpicturePDF.SetTitle("My first PDF/UA document");
string fontResName = gdpicturePDF.AddTrueTypeFontU("Arial", false, false, true);
if ((gdpicturePDF.GetStat() == GdPictureStatus.OK) &&
(gdpicturePDF.SetFillColor(Color.Blue) == GdPictureStatus.OK) &&
(gdpicturePDF.SetTextSize(16) == GdPictureStatus.OK))
{
int tagRootID = gdpicturePDF.GetTagRootID();
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
int tagParagraph = gdpicturePDF.NewTag(tagRootID, "P");
if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
{
if ((gdpicturePDF.BeginMarkedContentSequence(tagParagraph, "P") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as paragraph!") == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK) &&
(gdpicturePDF.BeginMarkedContent("Artifact") == GdPictureStatus.OK) &&
(gdpicturePDF.DrawLine(50, 55, 330, 55) == GdPictureStatus.OK) &&
(gdpicturePDF.EndMarkedContent() == GdPictureStatus.OK))
{
GdPictureStatus status = gdpicturePDF.SaveToFile("test_tagged.pdf");
if (status == GdPictureStatus.OK)
MessageBox.Show("Your tagged PDF document has been successfully created.", caption);
else
MessageBox.Show("The file can't be saved. Status: " + status.ToString(), caption);
}
else
MessageBox.Show("Tagging of the paragraph has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The NewTag() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
}
else
MessageBox.Show("Setting text properties has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
gdpicturePDF.CloseDocument();
}
else
MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
See Also