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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I Resize a Pdf Page

Thread ID:

Created:

Updated:

Platform:

Replies:

96500 Sep 16,2010 07:03 PM UTC Sep 17,2010 03:44 PM UTC ASP.NET Web Forms (Classic) 2
loading
Tags: PDF
kim
Asked On September 16, 2010 07:03 PM UTC

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);
}


kim
Replied On 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);
}


Angappan G [Syncfusion]
Replied On September 17, 2010 03:44 PM UTC

Hi Kim,

Thanks for the update.

Please let us know if you have any queries.

Regards,
Angappan.


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;