We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Split PDF Page Size Issue

Hello -

I have a PDF that is 768264 bytes. I am trying to split this into individuals pages using the following logic:

var pageStreams = pdfEditor.SplitToPages(ms);

I then take each stream and save it, however each page has the same size of 33660054 bytes, which is much larger “per page” then the entire PDF itself.

Any thoughts on why this would occur and how to prevent it?

Thanks!

I found this old thread which is very similar to the problem I am having:

https://forum.aspose.com/t/how-can-i-split-a-pdf-into-multiple-pdfs/105998

Was this ever resolved?

@bmahloch

Can you please try to split the PDF file with same code as in Split PDF programmatically. If you still face the issue then share your source and output PDF files.

I changed to using the “Document” and “Pages” based approach you recommended. Initially the results were the same. But I then discovered the optimization options. Once I added the following prior to saving the page to a stream I got the size (and performance) I was looking for.

Here is what I added:

pageDoc.Pages.Add(page);

pageDoc.OptimizeSize = true;
pageDoc.Optimize();
pageDoc.OptimizeResources();

using (var pageStream = new MemoryStream())
{
      pageDoc.Save(pageStream);

Thanks for the direction!

@bmahloch

It’s good to know that it has proved to be working on your end.