Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Sun Dec 26, 2021 2:23 pm

When I copy 1 page from a large pdf with multiple pages to a new PDF, the new PDF has the same file size as the original PDF even though it only has 1 page. By way of example, if I have a PDF with 1000 pages and a file size of 25meg and I copy page 1 to a new pdf file, the new 1 page PDF file will also be 25 meg. This is problematic if I want to take like 150 pages from the original file and create 150 individual PDFs.

Here's the code - pretty much copied from the example code on the site:

PdfDocument origDoc = new PdfDocument(@"c:\temp\someLargeDoc.pdf");
PdfDocument newDoc = new PdfDocument();
PdfPageBase newPage;

newPage = newDoc.Pages.Add(origDoc.Pages[0].Size, new Spire.Pdf.Graphics.PdfMargins(0));
origDoc.Pages[0].CreateTemplate().Draw(newPage, new System.Drawing.PointF(0, 0));

newDoc.SaveToFile(@"c:\temp\new1PageDoc.pdf");

patrick555
 
Posts: 1
Joined: Sun Dec 26, 2021 2:15 pm

Mon Dec 27, 2021 2:06 am

Hi,

Thank you for your inquiry.
I simulated a PDF file to test your code, but did not reproduce your issue. The version I used is the latest version(Spire.PDF Pack(Hot Fix) Version:7.12.1). If you were not using the latest version, please first give it a try. If the issue still exists after trying, please provide the following information for our reference. You could attach them here or send them to us via email ([email protected]). Thanks in advance.
1) Your input PDF file.
2) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).
3) Your application type, such as Console app (. Net Framework 4.5).

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1657
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF