I have a lot of scanned pdf files that are portrait-oriented but nonetheless PdfPageBase.Rotation results in a non-zero angle to rotate.
Sample code:
- Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(filePath);
foreach (PdfPageBase page in doc.Pages)
{
int rotation = (int)page.Rotation;
if (page.Rotation == PdfPageRotateAngle.RotateAngle90)
{
rotation += (int)PdfPageRotateAngle.RotateAngle270;
page.Rotation = (PdfPageRotateAngle)rotation;
isRotateSave = true;
}
if (page.Rotation == PdfPageRotateAngle.RotateAngle180)
{
rotation += (int)PdfPageRotateAngle.RotateAngle180;
page.Rotation = (PdfPageRotateAngle)rotation;
isRotateSave = true;
}
if (page.Rotation == PdfPageRotateAngle.RotateAngle270)
{
rotation += (int)PdfPageRotateAngle.RotateAngle90;
page.Rotation = (PdfPageRotateAngle)rotation;
isRotateSave = true;
}
}
Thanks in advance'
Assaf