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.

Mon Nov 04, 2024 9:50 am

Hi,
How can I resize all pages of an existing file to A4 keeping page direcetion and content?
I write the following code (based on your example), but the content is cutted :(
Thanks!

public static byte[] PdfToA4(byte[] source)
{
//Load your original Pdf
PdfDocument pdf = new PdfDocument(source);
//Create a new Pdf
PdfDocument newPdf = new PdfDocument();

foreach (PdfPageBase page in pdf.Pages)
{
//Set the new page size to A4
PdfPageBase newPage = newPdf.Pages.Add(PdfPageSize.A4, new PdfMargins(0));

//Draw the original Pdf page to the new page
page.CreateTemplate().Draw(newPage, new PointF(0, 0));
}
//Save the Pdf file
var ms = new MemoryStream();
newPdf.SaveToStream(ms, FileFormat.PDF);

newPdf.Close();
return ms.ToArray();
}

rivphill
 
Posts: 4
Joined: Wed Jul 22, 2020 6:12 am

Mon Nov 04, 2024 10:01 am

Hi,

Thank you for your message.
Our latest Spire.PDF version is 10.10.5. If you're not using this new version I first suggest you downloading it from the link below to test as it contains more fixes than the old version. If the issue persists after using new version, please provide your test PDF file for our further investigation. Thanks in advance.

https://www.e-iceblue.com/Download/download-pdf-for-net-now.html

Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Mon Nov 25, 2024 2:21 am

Hello,

I hope you're doing well.
Have you tested with the latest version? Is the issue of pages being cropped still present? If so, please provide your test document so that we can investigate and test it further to better resolve the problem for you.
We would greatly appreciate it if you could reply.

Sincerely,
Doris
E-iceblue support team
User avatar

Doris.Liu
 
Posts: 460
Joined: Mon Nov 07, 2022 8:10 am

Return to Spire.PDF

cron