MuPDFCore
MuPDFCore copied to clipboard
Do you support deleting pages
Do you support deleting pages
Hi! Sure, you can use the MuPDFDocument.CreateDocument
static method to create a new PDF file using only some pages from another document:
// Create a new context.
using MuPDFContext ctx = new MuPDFContext();
// Open a PDF document.
using MuPDFDocument doc = new MuPDFDocument(ctx, "path/to/inputFile.pdf");
// Create a list with all the pages in the document.
List<MuPDFPage> pagesToKeep = new List<MuPDFPage>(doc.Pages);
// Remove some pages.
pagesToKeep.Remove(doc.Pages[2]);
pagesToKeep.Remove(doc.Pages[4]);
// Create a new document with the specified pages.
MuPDFDocument.CreateDocument(ctx, "path/to/outputFile.pdf", DocumentOutputFileTypes.PDF, pages: pagesToKeep.ToArray());