Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you support deleting pages #30

Open
azbo opened this issue Apr 10, 2024 · 1 comment
Open

Do you support deleting pages #30

azbo opened this issue Apr 10, 2024 · 1 comment

Comments

@azbo
Copy link

azbo commented Apr 10, 2024

Do you support deleting pages

@arklumpus
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants