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





In This Topic
RemovePageLinks Method (GdPicturePDF)
In This Topic
Removes all links embedded within the currently selected page of the loaded PDF document.
Syntax
'Declaration
 
Public Function RemovePageLinks() As GdPictureStatus
public GdPictureStatus RemovePageLinks()
public function RemovePageLinks(): GdPictureStatus; 
public function RemovePageLinks() : GdPictureStatus;
public: GdPictureStatus RemovePageLinks(); 
public:
GdPictureStatus RemovePageLinks(); 

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.

Also, be sure that you have selected the correct page to work with. If the selected page doesn't contain any links, this method always returns the value of GdPictureStatus.OK.

Example
How to successfully remove all links embedded within the first page of the PDF document.
Dim caption As String = "Example: RemovePageLinks"
Dim gdpicturePDF As New GdPicturePDF()
Dim status As GdPictureStatus = gdpicturePDF.LoadFromFile("links.pdf", False)
If status = GdPictureStatus.OK Then
    status = gdpicturePDF.SelectPage(1)
    If status = GdPictureStatus.OK Then
        Dim linksCount As Integer = gdpicturePDF.GetPageLinksCount()
        If gdpicturePDF.GetStat() = GdPictureStatus.OK Then
            If linksCount > 0 Then
                status = gdpicturePDF.RemovePageLinks()
                If status = GdPictureStatus.OK Then
                    MessageBox.Show("All links on the first page have been removed successfully.", caption)
                    If gdpicturePDF.SaveToFile("links.pdf") = GdPictureStatus.OK Then
                        MessageBox.Show("The file has been saved successfully.", caption)
                    Else
                        MessageBox.Show("The file can't be saved.", caption)
                    End If
                Else
                    MessageBox.Show("The RemovePageLinks() method has failed with the status: " + status.ToString(), caption)
                End If
            Else
                MessageBox.Show("This page has no links.", caption)
            End If
        Else
            MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption)
        End If
    Else
        MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption)
    End If
Else
    MessageBox.Show("The file can't be loaded.", caption)
End If
gdpicturePDF.Dispose()
string caption = "Example: RemovePageLinks";
GdPicturePDF gdpicturePDF = new GdPicturePDF();
GdPictureStatus status = gdpicturePDF.LoadFromFile("links.pdf", false);
if (status == GdPictureStatus.OK)
{
    status = gdpicturePDF.SelectPage(1);
    if (status == GdPictureStatus.OK)
    {
        int linksCount = gdpicturePDF.GetPageLinksCount();
        if (gdpicturePDF.GetStat() == GdPictureStatus.OK)
        {
            if (linksCount > 0)
            {
                status = gdpicturePDF.RemovePageLinks();
                if (status == GdPictureStatus.OK)
                {
                    MessageBox.Show("All links on the first page have been removed successfully.", caption);
                    if (gdpicturePDF.SaveToFile("links.pdf") == GdPictureStatus.OK)
                    {
                        MessageBox.Show("The file has been saved successfully.", caption);
                    }
                    else
                    {
                        MessageBox.Show("The file can't be saved.", caption);
                    }
                }
                else
                {
                    MessageBox.Show("The RemovePageLinks() method has failed with the status: " + status.ToString(), caption);
                }
            }
            else
            {
                MessageBox.Show("This page has no links.", caption);
            }
        }
        else
        {
            MessageBox.Show("The GetPageLinksCount() method has failed with the status: " + status.ToString(), caption);
        }
    }
    else
    {
        MessageBox.Show("The SelectPage() method has failed with the status: " + status.ToString(), caption);
    }
}
else
{
    MessageBox.Show("The file can't be loaded.", caption);
}
gdpicturePDF.Dispose();
See Also