We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How can I Resize a Pdf Page

Hi!

I have to work with PdfPageSize.A1 size (Mapping PDF to WPF screen), and I use the code below to resize the page; however it just captures a part of the original pdf (Note: the original is in PdfPageSize.A0)

How can I change the size of the PDF page without loosing any part of the page (same width and height ratio) when reducing the size, or without any white space when enlarging the page?

Thanks!

private void ConvertPdfToA0Size()
{
PdfDocument document1 = new PdfDocument();

PdfPage page = document1.Pages.Add();
PdfGraphics g = page.Graphics;

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(this.pdfPath1);
PdfPageBase lpage = loadedDocument.Pages[0];
PdfTemplate template = lpage.CreateTemplate();


//SizeF size = page.GetClientSize();
//SizeF size1 = lpage.Size;
//g.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());
g.DrawPdfTemplate(template, PointF.Empty,PdfPageSize.A1);


document1.Save(this.outPdfPath1);

document1.Close(true);
loadedDocument.Close(true);
System.Diagnostics.Process.Start(this.outPdfPath1);
}


2 Replies

KI kim September 17, 2010 03:37 PM UTC

Hi!

I got it working.

Thanks anyway!

Below is working code:

private void ConvertPdfToA1Size()
{
PdfDocument document1 = new PdfDocument();
//NEED TO SET THE PAGE SIZE HERE, IF NOT IT WILL USE DEFAULT SIZE WHICH IS CLIENT SIZE
document1.PageSettings.Size = PdfPageSize.A1;

PdfPage page = document1.Pages.Add();
PdfGraphics g = page.Graphics;

PdfLoadedDocument loadedDocument = new PdfLoadedDocument(this.pdfPath1);
PdfPageBase lpage = loadedDocument.Pages[0];
PdfTemplate template = lpage.CreateTemplate();


//SizeF size = page.GetClientSize();
//SizeF size1 = lpage.Size;
//g.DrawPdfTemplate(template, PointF.Empty, page.GetClientSize());
g.DrawPdfTemplate(template, PointF.Empty,PdfPageSize.A1);


document1.Save(this.outPdfPath1);

document1.Close(true);
loadedDocument.Close(true);
System.Diagnostics.Process.Start(this.outPdfPath1);
}



AG Angappan G Syncfusion Team September 17, 2010 03:44 PM UTC

Hi Kim,

Thanks for the update.

Please let us know if you have any queries.

Regards,
Angappan.


Loader.
Live Chat Icon For mobile
Up arrow icon