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.

Tue Aug 07, 2018 2:38 am

How to resize source file (e.g F4 or other size) to A4 with C#. Thank you.

lls
 
Posts: 1
Joined: Tue Aug 07, 2018 2:23 am

Tue Aug 07, 2018 7:51 am

Hello,

Thanks for your inquiry.
Below code can fulfill your demand. Please have a try, if there is any question, please attach your sample Pdf file here or send it to [email protected] for further investigation.
Code: Select all
//Load your original Pdf
PdfDocument pdf = new PdfDocument();
pdf.LoadFromFile("Sample.pdf");
//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
newPdf.SaveToFile("Result.pdf", FileFormat.PDF);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Wed Aug 15, 2018 6:33 am

Hello,

Greetings from E-iceblue.
Has your issue been fixed?
Your feedback will be highly appreciated.

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF

cron