GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / GetTagRootID Method
Example





In This Topic
GetTagRootID Method (GdPicturePDF)
In This Topic
Returns a unique identifier of the root (top-level element) in the the document's logical structure hierarchy, so-called tag's structure tree, in the currently loaded PDF document. If the root element does not exist yet, the toolkit will create a new structure element at the very top of the forming structure tree.

At this time, the toolkit only identifies and supports the standard structure type, so-called tag type, named Document as the root element of the document's tag structure tree.

Syntax
'Declaration
 
Public Function GetTagRootID() As Integer
public int GetTagRootID()
public function GetTagRootID(): Integer; 
public function GetTagRootID() : int;
public: int GetTagRootID(); 
public:
int GetTagRootID(); 

Return Value

The unique tag identifier of the existing or the newly created tag's tree root element, that is of the standard structure type Document. The GetStat method can be subsequently used to determine if this method has been successful.
Remarks
This method is only allowed for use with non-encrypted documents.

It is recommend to use the GetStat method to identify the specific reason for the method's failure, if any.

Be aware that currently the toolkit only supports the tag type Document as the root of the document's tag structure tree.

Example
How to create the root element of the document's tag tree to produce the new tagged PDF document.
Dim caption As String = "Example: GetTagRootID"
Using gdpicturePDF As GdPicturePDF = New GdPicturePDF()
    If (gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) = GdPictureStatus.OK) AndAlso
       (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) = GdPictureStatus.OK) Then
        '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(30) = GdPictureStatus.OK) AndAlso
           (gdpicturePDF.DrawText(fontResName, 200, 250, "Hello Word") = GdPictureStatus.OK) Then
            Dim tagRootID As Integer = gdpicturePDF.GetTagRootID()
            If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                'You can continue to build the tagged content here.
                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("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption)
            End If
        Else
            MessageBox.Show("Setting text properties has failed. 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: GetTagRootID";
using (GdPicturePDF gdpicturePDF = new GdPicturePDF())
{
    if ((gdpicturePDF.NewPDF(PdfConformance.PDF_UA_1) == GdPictureStatus.OK) &&
        (gdpicturePDF.NewPage(PdfPageSizes.PdfPageSizeA4) == GdPictureStatus.OK))
    {
        //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(30) == GdPictureStatus.OK) &&
            (gdpicturePDF.DrawText(fontResName, 200, 250, "Hello World") == GdPictureStatus.OK))
        {
            int tagRootID = gdpicturePDF.GetTagRootID();
            if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
            {
                //You can continue to build the tagged content here.
                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("The GetTagRootID() method has failed with the status: " + gdpicturePDF.GetStat().ToString(), caption);
        }
        else
            MessageBox.Show("Setting text properties has failed. Status: " + gdpicturePDF.GetStat().ToString(), caption);
        gdpicturePDF.CloseDocument();
    }
    else
        MessageBox.Show("The new document can't be created. Status: " + gdpicturePDF.GetStat().ToString(), caption);
}
See Also