The page number of a page you want to delete. It must be a value from 1 to GetPageCount.
Example





In This Topic

DeletePage Method (GdPicturePDF)

In This Topic
Deletes a page specified by its page number in the currently loaded PDF document.
Syntax
'Declaration

 

Public Function DeletePage( _

   ByVal PageNo As Integer _

) As GdPictureStatus
public GdPictureStatus DeletePage( 

   int PageNo

)
public function DeletePage( 

    PageNo: Integer

): GdPictureStatus; 
public function DeletePage( 

   PageNo : int

) : GdPictureStatus;
public: GdPictureStatus DeletePage( 

   int PageNo

) 
public:

GdPictureStatus DeletePage( 

   int PageNo

) 

Parameters

PageNo
The page number of a page you want to delete. It must be a value from 1 to GetPageCount.

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.

This method requires the Document Editor component to run.

Example
How to delete the first page of your document. The page has been previously cloned.
Dim caption As String = "Example: DeletePage"

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

        If count > 0 Then

            status = gdpicturePDF.ClonePage(1)

            If status = GdPictureStatus.OK Then

                status = gdpicturePDF.DeletePage(1)

                If status = GdPictureStatus.OK Then

                    If gdpicturePDF.SaveToFile("test_DeletePage.pdf") = GdPictureStatus.OK Then

                        MessageBox.Show("The page has been deleted successfully and the file has been saved.", caption)

                    Else

                        MessageBox.Show("The page has been deleted successfully, but the file can't be saved.", caption)

                    End If

                Else

                    MessageBox.Show("The DeletePage() method has failed with the status: " + status.ToString(), caption)

                End If

            Else

                MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption)

            End If

        End If

    Else

        MessageBox.Show("The GetPageCount() 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: DeletePage";

GdPicturePDF gdpicturePDF = new GdPicturePDF();

if (gdpicturePDF.LoadFromFile("test.pdf", false) == GdPictureStatus.OK)

{

    int count = gdpicturePDF.GetPageCount();

    GdPictureStatus status = gdpicturePDF.GetStat();

    if (status == GdPictureStatus.OK)

    {

        if (count > 0)

        {

            status = gdpicturePDF.ClonePage(1);

            if (status == GdPictureStatus.OK)

            {

                status = gdpicturePDF.DeletePage(1);

                if (status == GdPictureStatus.OK)

                {

                    if (gdpicturePDF.SaveToFile("test_DeletePage.pdf") == GdPictureStatus.OK)

                        MessageBox.Show("The page has been deleted successfully and the file has been saved.", caption);

                    else

                        MessageBox.Show("The page has been deleted successfully, but the file can't be saved.", caption);

                }

                else

                    MessageBox.Show("The DeletePage() method has failed with the status: " + status.ToString(), caption);

            }

            else

                MessageBox.Show("The ClonePage() method has failed with the status: " + status.ToString(), caption);

        }

    }

    else

        MessageBox.Show("The GetPageCount() method has failed with the status: " + status.ToString(), caption);

}

else

    MessageBox.Show("The file can't be loaded.", caption);

gdpicturePDF.Dispose();
See Also