MuPDFCore icon indicating copy to clipboard operation
MuPDFCore copied to clipboard

Do you support deleting pages

Open azbo opened this issue 10 months ago • 1 comments

Do you support deleting pages

azbo avatar Apr 10 '24 13:04 azbo

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());

arklumpus avatar Apr 10 '24 13:04 arklumpus