Hello,
Thanks for your inquiry.
After a check, we found the oritation of the first page in your file is potrit rather than landscape. Since it has already rotated 90 degree, it looks like "landscape". As for your requirement of getting the orientation of individual pages and rotate the first page. You could refer to the following code.
- Code: Select all
PdfDocument pdfDoc = new PdfDocument();
pdfDoc.LoadFromFile(path);
foreach (PdfPageBase page in pdfDoc.Pages)
{
// Determine the orientation of a certain page
//PdfPageOrientation direction = page.Section.PageSettings.Orientation;
//Since your first page has rotated 90 degree, if you want to turn it to be potrit- looked-like,
// just set the rotate to 180 degree, that is, rotate 90 degree again.
if (page.Rotation == PdfPageRotateAngle.RotateAngle90)
page.Rotation = PdfPageRotateAngle.RotateAngle180;
}
pdfDoc.SaveToFile("11351.pdf");
Also, you could justify the page size mannually to let the content keep landscape.
- Code: Select all
PdfDocument newDoc = new PdfDocument();
PdfPageBase newPage;
//Expected width and height
float width = doc.Pages[1].ActualSize.Width;
float height = doc.Pages[1].ActualSize.Height;
foreach (PdfPageBase page in doc.Pages)
{
newPage = newDoc.Pages.Add(new SizeF(width, height), new PdfMargins(0));
if (page.Rotation == PdfPageRotateAngle.RotateAngle90)
{
page.CreateTemplate().Draw(newPage, -360, -80);
}
else
{
page.CreateTemplate().Draw(newPage, 0, 0);
}
}
newDoc.SaveToFile("resut1.pdf");
System.Diagnostics.Process.Start("resut1.pdf");
Just choose the solution you need.
Let me know if I have made it clear.
Sincerely,
Jane
E-iceblue support team