Spire.PDF is a professional PDF library applied to creating, writing, editing, handling and reading PDF files without any external dependencies. Get free and professional technical support for Spire.PDF for .NET, Java, Android, C++, Python.

Wed Oct 24, 2018 12:07 am

Hi Team,

Hope you guys are doing great.

Currently we are using Spire.PDF Pro Edition and would like to know following.

Can we progrmatically find the orientration of text/image in page which have gone wrong , so that we can auto rotate pages (90/180/270 degrees) which are disoriented.

Business case -> we have many pdf files which manually has to be rotated because their orientation is wrong.

Thanks,

vishy
 
Posts: 1
Joined: Tue Oct 23, 2018 11:50 pm

Wed Oct 24, 2018 3:07 am

Hi,

Thanks for your inquiry.
Sorry we can not fulfil your requirement now for we can not get original orientation of image/text in PDF page. But, if your PDF page and its image/text keep the same orientation, you could directly rotate pages by using the following code. If there is any question, welcome to write back and share us a sample PDF file.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Sample1.pdf");
foreach (PdfPageBase page in doc.Pages)
{
    int rotation = (int)page.Rotation;
    if (page.Rotation == PdfPageRotateAngle.RotateAngle90)
    {
        rotation += (int)PdfPageRotateAngle.RotateAngle270;
        page.Rotation = (PdfPageRotateAngle)rotation;
    }
    if (page.Rotation == PdfPageRotateAngle.RotateAngle180)
    {
        rotation += (int)PdfPageRotateAngle.RotateAngle180;
        page.Rotation = (PdfPageRotateAngle)rotation;
    }
    if (page.Rotation == PdfPageRotateAngle.RotateAngle270)
    {
        rotation += (int)PdfPageRotateAngle.RotateAngle90;
        page.Rotation = (PdfPageRotateAngle)rotation;
    }
}
doc.SaveToFile("result.pdf", FileFormat.PDF);

Sincerely,
Nina
E-iceblue support team
User avatar

Nina.Tang
 
Posts: 1385
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.PDF