Why doesn't saving with "remove_unused" result in a smaller file after deleting pages?


I have ran into an issue performing page removal.

Your webpage states that “The page and its resources are still available until the document is saved in ‘full save mode’ with the ‘remove unused objects’ flag”.

So I use doc.PageRemove(it) and then save the document using
doc.Save(targetFile, SDFDoc.SaveOptions.e_remove_unused)

PDFNet’s output is only few kilobytes smaller than the input.


The document isn’t reducing in size because the pages are still being referenced by parts of the document, namely the bookmarks and logical structure. You can remove these references by erasing them from the document:


With these values removed, saving the document with “remove unused” set results in significantly smaller output.