GdPicture.NET.14.API
GdPicture14 Namespace / GdPicturePDF Class / SetPagePrivateTag Method
The name of the private tag for the currrent page. It can be a name you prefer, for example "Origin".
The content of the private tag for the currrent page, for example "Application-Xapp".
Example





In This Topic
SetPagePrivateTag Method (GdPicturePDF)
In This Topic
Defines a private tag linked with the currently selected page in the loaded PDF document, specified by its name and value.

Tags provide an additional information that allow page content to be extracted and reused for other purposes.

Syntax
'Declaration
 
Public Function SetPagePrivateTag( _
   ByVal Tag As String, _
   ByVal Content As String _
) As GdPictureStatus
public GdPictureStatus SetPagePrivateTag( 
   string Tag,
   string Content
)
public function SetPagePrivateTag( 
    Tag: String;
    Content: String
): GdPictureStatus; 
public function SetPagePrivateTag( 
   Tag : String,
   Content : String
) : GdPictureStatus;
public: GdPictureStatus SetPagePrivateTag( 
   string* Tag,
   string* Content
) 
public:
GdPictureStatus SetPagePrivateTag( 
   String^ Tag,
   String^ Content
) 

Parameters

Tag
The name of the private tag for the currrent page. It can be a name you prefer, for example "Origin".
Content
The content of the private tag for the currrent page, for example "Application-Xapp".

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.

The currently stored tag value will be overwritten according to the new value you have specified.

Example
How to define the private tag named MyTag with the specified 'page number' value and link it with each page of your document.
Dim gdpicturePDF As New GdPicturePDF()
If gdpicturePDF.LoadFromFile("test.pdf", False) = GdPictureStatus.OK Then
    Dim count As Integer = gdpicturePDF.GetPageCount()
    Dim status As GdPictureStatus = gdpicturePDF.GetStat()
    If status = GdPictureStatus.OK Then
        Dim message As String = "", content As String = ""
        For i As Integer = 1 To count
            status = gdpicturePDF.SelectPage(i)
            If status = GdPictureStatus.OK Then
                content = "My Value " + i.ToString()
                status = gdpicturePDF.SetPagePrivateTag("MyTag", content)
                If status = GdPictureStatus.OK Then
                    message = message + "The private tag for the page nr." + i.ToString() + " has been set successfully." + vbCrLf
                Else
                    message = message + "The SetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
                End If
            Else
                message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + vbCrLf
            End If
        Next
        If gdpicturePDF.SaveToFile("test_SetPagePrivateTag.pdf") = GdPictureStatus.OK Then
            message = message + "The file has been saved."
        Else
            message = message + "The file can't be saved."
        End If
            
        MessageBox.Show(message, "Example: SetPagePrivateTag")
    Else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPagePrivateTag")
    End If
Else
    MessageBox.Show("The file can't be loaded.", "Example: SetPagePrivateTag")
End If
gdpicturePDF.Dispose()
GdPicturePDF gdpicturePDF = new GdPicturePDF();
if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)
{
    int count = gdpicturePDF.GetPageCount();
    GdPictureStatus status = gdpicturePDF.GetStat();
    if (status == GdPictureStatus.OK)
    {
        string message = "", content = "";
        for (int i = 1; i <= count; i++)
        {
            status = gdpicturePDF.SelectPage(i);
            if (status == GdPictureStatus.OK)
            {
                content = "My Value " + i.ToString();
                status = gdpicturePDF.SetPagePrivateTag("MyTag", content);
                if (status == GdPictureStatus.OK)
                    message = message + "The private tag for the page nr." + i.ToString() + " has been set successfully.\n";
                else
                    message = message + "The SetPagePrivateTag() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
            }
            else
                message = message + "The SelectPage() method has failed for the page nr." + i.ToString() + " with the status: " + status.ToString() + "\n";
        }
        if (gdpicturePDF.SaveToFile("test_SetPagePrivateTag.pdf") == GdPictureStatus.OK)
            message = message + "The file has been saved.";
        else
            message = message + "The file can't be saved.";
        MessageBox.Show(message, "Example: SetPagePrivateTag");
            
    }
    else
        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), "Example: SetPagePrivateTag");
}
else
    MessageBox.Show("The file can't be loaded.", "Example: SetPagePrivateTag");
gdpicturePDF.Dispose();
See Also