Physically Delete PDF Pages

I’m trying to delete some pages from a PDF file but the resulting file still has the contents inside even if the pages are now hidden.

I have tried with 2 methods:

1 - new PdfFileEditor().Delete(stream, int[], stream)
2 - new Aspose.Pdf.Document(stream).Pages.Delete(int[]) + Save() (like is shown here: Delete PDF Pages programmatically C#|Aspose.PDF for .NET)

I have also looked up the PdfSaveOptions definition to find an option to skip hidden pages but without luck.

Did I do something wrong? If not, isn’t the documentation (and the method name) a little bit misleading?
How can I achieve the expected result?

For reference I’m attaching the resulting file with the first page supposedly “deleted”.

sample.removed-page.1-ASPOSE.pdf (3.1 KB)



Please share the respective source PDF document as well so that we can further investigate the issue.

sample.pdf (3.0 KB)

Here it is.

I have tried with the online demo and I got the same results so I think that is not related to my setup.

RemovePages_sample.pdf (3.1 KB)


Can you please also share how you are checking the PDF document for the content of deleted pages?

since it is text, you can open it with your favourite text editor and see that the text of the first page is still there.

Anyway I’m using this code:
image.png (39.5 KB)


We have logged an issue as PDFNET-51771 in our issue tracking system to further investigate this case. We will look into its details and keep you posted with the status of its rectification. Please be patient and spare us some time.

We are sorry for the inconvenience.