PdfDocumentProcessor.DeletePage(Int32) Method
Deletes the specified page from the current document.
Namespace: DevExpress.Pdf
Assembly: DevExpress.Docs.v19.2.dll
Declaration
Parameters
Name | Type | Description |
---|---|---|
pageNumber | Int32 | The page number(starting from 1). |
Example
This example illustrates how to use the PDF Document API component for deleting pages from a document.
In this example, the PdfDocumentProcessor.DeletePage
method is called 55 times to delete each odd numbered page in the TextDelete document (contains 109 pages), starting from the last odd numbered page.
The result is saved to the Deleted document, which contains only even pages, by calling the PdfDocumentProcessor.SaveDocument method.
Note
A complete sample project is available at https://github.com/DevExpress-Examples/how-to-delete-pages-from-pdf-t114310
using DevExpress.Pdf;
// ...
class Program {
static void Main(string[] args) {
using (PdfDocumentProcessor pdfDocumentProcessor = new PdfDocumentProcessor()) {
pdfDocumentProcessor.LoadDocument("..\\..\\docs\\TextDelete.pdf");
for (int i = pdfDocumentProcessor.Document.Pages.Count / 2; i >= 0; i--)
pdfDocumentProcessor.DeletePage(i * 2 + 1);
pdfDocumentProcessor.SaveDocument("..\\..\\docs\\Deleted.pdf");
}
}
}
Related GitHub Examples
The following code snippet (auto-collected from DevExpress Examples) contains a reference to the DeletePage(Int32) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.