Removing pages does not decrease size of PDF

WebViewer Version: 8.11

Can you reproduce using one of our samples or online demos? No
Are you using the WebViewer server? No

Please give a brief summary of your issue:
When removing pages from a PDF, the PDF does not seem to decrease in size

Please describe your issue and provide steps to reproduce it:
We are using the options to manipulate a PDF (i.e. moving, adding, deleting, etc).
When adding pages, the final PDF gains in size because pages were added, but when removing those pages from the PDF, the size remains the same, so we understand that they are not being deleted.

We do the following:
Using the buttons from the Left Panel:
When a page is edited the listener for the instance.Core.DocumentViewer.Events.PAGES_UPDATED event is triggered and we enable a custom flag to know that we need to update the PDF contents on the server side.
When saving the document we do the following:

    const PDFNet = instance.Core.PDFNet;
    const doc = await documentViewer.getDocument().getPDFDoc();
    const docbuf = await doc.saveMemoryBuffer(PDFNet.SDFDoc.SaveOptions.e_remove_unused);
    const blob = new Blob([docbuf], { type: "application/pdf" });

    const data = new FormData();
    data.append('file', blob, "Name goes here");
    data.append('other', 'example');
    // Send the form data to the server
    // We save only the annotations into a separate file, no problem here

Any idea on why the file remains the same and the pages are actually not removed? We think the remove_unused flag doesn’t do anything and that the pages are still in the document even though they are not visible.

Hi there,

Thank you for contacting WebViewer forums,

In the WebViewer 8.12 sample, I deleted the first page then downloaded the document and see the file size differences:

From the code above, calling blob.size does seem to be reduced as pages are removed.

One odd thing is that calling getFileSize does not seem to be reduced.

Best regards,
Kevin Kim

hi how can i apply delete rotate insert split pages of an thumbnailControlMenu complete and save it
and also want to know that is save in anotation or as a blob file
basicaly i want to implenet these thing in my web viewer so i didnt find a proper way to implement it

Hi there,

To delete/rotate/insert/split pages, please follow the below guide:

For the above with thumbnail controls, please follow this guide:

To save annotations, please follow this guide:

Best regards,
Kevin Kim