Change page size from A4 to Letter

Hi, actually i have a problem, in my code. I’m trying to change from A4 to Letter Size using the following code



Aspose.Pdf.Document pdf = new Aspose.Pdf.Document(pdfInput);
foreach (Aspose.Pdf.Page pdfPage in pdf.Pages)
{
pdfPage.SetPageSize(610.997, 790.702);
}
pdf.Save(pdfOutput);

Finaly, the file have for every page, a letter size, but, the content, of the pages, is not correct, because (too large, or too small).

so, i think, i need resize, the content,
How can i do this?

Thanks in advance
Luis

Hi Luis,


Thanks for contacting support.

As per my understanding, when the page orientation is changed, you need to change the zoom factor for contents inside PDF file. If so is the case, then please try using following code snippet to accomplish your requirements. In case you encounter any issue or you have any further query, please feel free to contact.

[C#]
// Load source PDF file
Document doc = new Document(“PdfWithText.pdf”);
// Get rectangular region of first page of PDF
Aspose.Pdf.Rectangle rect = doc.Pages[1].Rect;
// Instantiate PdfPageEditor instance
PdfPageEditor ppe = new PdfPageEditor();
// Bind source PDF
ppe.BindPdf(“PdfWithText.pdf”);
// Set zoom coefficient
ppe.Zoom = (float)(rect.Width / rect.Height);
// Update page size
ppe.PageSize = new Aspose.Pdf.PageSize((float)rect.Height, (float)rect.Width);
// Save resultant PDF
ppe.Save(“36115-1.pdf”);

Hello. thanks for your answer . I was doing some tests with the instructions, and working properly. thanks for u time
best regards

Hi Luis,


Thanks for the acknowledgement.

We are glad to hear that your problem is resolved. Please continue using our API and in the event of any further query, please feel free to contact.