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.

Thu Jan 11, 2018 3:31 pm

Is there a way to programmatically determine if a page needs to be rotated 90, 180, or 270 degrees based on the text content of the page?

I have a huge population of PDFs that need to be "fixed" by rotating the incorrectly oriented pages, and I really don't want to have to do it manually.

Thanks.

MatthewPierce
 
Posts: 22
Joined: Thu Jul 16, 2015 4:45 pm

Fri Jan 12, 2018 2:57 am

Hello,

Thanks for your inquiry. I am sorry Spire.Pdf doesn't support to do so. But If the PDF files have been rotated before and result in the wrong orientation, you could recover it like below.
Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"test.pdf");
            foreach (PdfPageBase p in doc.Pages)
            {
                if (p.Rotation != PdfPageRotateAngle.RotateAngle0)
                {
                    p.Rotation = PdfPageRotateAngle.RotateAngle0;
                }
            }
            doc.SaveToFile("testR.pdf");


Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Tue Jan 16, 2018 6:57 am

Hello,

Greeting from E-iceblue.
How is the issue going? Is the code snippet helpful to you?
Your feedback will be greatly appreciated.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Thu Jan 18, 2018 1:52 pm

Unfortunately, this does not solve my problem, but that bit of code may be useful for future projects. Thanks for that.

Currently I'm relying on the Adobe Acrobat Optimization feature with text recognition turned on. This achieves the goal of page rotation, but it takes a lot of processor time. When working with large document populations (100k pages or more) it is causing a bit of a bottleneck.

Thank you for your time.

~Matthew

MatthewPierce
 
Posts: 22
Joined: Thu Jul 16, 2015 4:45 pm

Fri Jan 19, 2018 1:39 am

Hello Matthew,

Thanks for your reply. If there is any other question, welcome to contact us.

Best regards,
Simon
E-iceblue support team
User avatar

Simon.yang
 
Posts: 620
Joined: Wed Jan 11, 2017 2:03 am

Return to Spire.PDF

cron