GdPicture.NET.14
GdPicture14 Namespace / GdPicturePDF Class / MapStructureType Method
The new name of the structure type, that will be mapped to the existing structure type.
The name of the already existing structure type, to which the new one is to be mapped.

This name must be either one of the standard structure type names (see PDF Reference, Section "Standard Structure Types"), or other previously defined structure type name.

Example





In This Topic
MapStructureType Method (GdPicturePDF)
In This Topic
Maps your custom (newly defined) structure type name to the already existing structure type name. Structure type names are identified and mapped through the so-called RoleMap entry in the structure tree root element, that should be a part of the document's tag structure tree related to the currently loaded PDF document.

All standard structure type names (tag's names) (see PDF Reference, Section "Standard Structure Types") may be used in the PDF/UA-1 conformed documents. If other names are used, a mapping of those custom names to the standard type names must be provided in the document's RoleMap entry. This way a structure tree element (tag) name is always mapped to its corresponding name in the role map, if there is one defined.

Syntax
'Declaration
 
Public Function MapStructureType( _
   ByVal NewStructType As String, _
   ByVal ExistingStructType As String _
) As GdPictureStatus
public GdPictureStatus MapStructureType( 
   string NewStructType,
   string ExistingStructType
)
public function MapStructureType( 
    NewStructType: String;
    ExistingStructType: String
): GdPictureStatus; 
public function MapStructureType( 
   NewStructType : String,
   ExistingStructType : String
) : GdPictureStatus;
public: GdPictureStatus MapStructureType( 
   string* NewStructType,
   string* ExistingStructType
) 
public:
GdPictureStatus MapStructureType( 
   String^ NewStructType,
   String^ ExistingStructType
) 

Parameters

NewStructType
The new name of the structure type, that will be mapped to the existing structure type.
ExistingStructType
The name of the already existing structure type, to which the new one is to be mapped.

This name must be either one of the standard structure type names (see PDF Reference, Section "Standard Structure Types"), or other previously defined structure type name.

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.

Be aware that you can only map the new custom structure type name to already existing structure type name in the document's RoleMap entry.

Example
How to map the standard structure type to your custom type.
Dim caption As String = "Example: MapStructureType"
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
                'Mapping the standard structure type named P to your custom type named TextElement.
                If gdpicturePDF.MapStructureType("TextElement", "P") = GdPictureStatus.OK Then
                    Dim tagTextElement As Integer = gdpicturePDF.NewTag(tagRootID, "TextElement")
                    If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
                        If (gdpicturePDF.BeginMarkedContentSequence(tagTextElement, "TextElement") = GdPictureStatus.OK) AndAlso
                           (gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as TextElement!") = 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("Mapping structure type 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: MapStructureType";
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)
            {
                //Mapping the standard structure type named P to your custom type named TextElement.
                if (gdpicturePDF.MapStructureType("TextElement", "P") == GdPictureStatus.OK)
                {
                    int tagTextElement = gdpicturePDF.NewTag(tagRootID, "TextElement");
                    if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
                    {
                        if ((gdpicturePDF.BeginMarkedContentSequence(tagTextElement, "TextElement") == GdPictureStatus.OK) &&
                            (gdpicturePDF.DrawText(fontResName, 50, 50, "This is text that is tagged as TextElement!") == 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("Mapping structure type 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