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.

Fri May 25, 2018 6:22 pm

I'm having trouble trying to properly rotate serveral pages in a PDF document. Some are upside down or sideways (left or right). For some reason the starting rotation is always RotateAngle270 and when I attempt to apply the following logic it does not change the rotation.

int rotation = (int)p.Rotation;
rotation += (int)PdfPageRotateAngle.RotateAngle270;
p.Rotation = (PdfPageRotateAngle)rotation;

Any insight into what I am doing wrong?

Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile(pdfFile);
foreach (PdfPageBase p in doc.Pages)
{
    int rotation = (int)p.Rotation;
    rotation += (int)PdfPageRotateAngle.RotateAngle270;
    p.Rotation = (PdfPageRotateAngle)rotation;
}
doc.SaveToFile(currentFolder + "\\cleaned.pdf");
doc.Close();


Regards,
Adam

Adam.Gilmore
 
Posts: 5
Joined: Tue May 22, 2018 8:46 pm

Mon May 28, 2018 6:06 am

Hello,

Thanks for your post.
Sorry that I don't reproduce the issue. To help us look into it, could you please share your sample document?

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Thu May 31, 2018 12:43 pm

Hi Jane,

Please see attached PDF.

How do I determine programatically what rotation the picture is facing (left, right, upside-down) and then rotate it so it looks like the image on page 2? If the image is currently rotate properly, there is no need to apply any rotation logic since it is already correct.

Regards,
Adam

Adam.Gilmore
 
Posts: 5
Joined: Tue May 22, 2018 8:46 pm

Fri Jun 01, 2018 4:01 am

Hello,

Thanks for your document.
Sorry that there's no way to judge as well as manipulate the rotation of an image.
Only rotating the whole page is available.
Regarding your case, the only solution is to make the page rotation the same as the image rotation, then rotate the page.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Sat Jun 16, 2018 4:17 pm

Thanks! I haven't tested this yet, but wouldn't rotating the page also rotate the image with it? This would still leave the image facing the wrong direction?

Adam.Gilmore
 
Posts: 5
Joined: Tue May 22, 2018 8:46 pm

Mon Jun 18, 2018 1:39 am

Hello Adam.Gilmore,

Yes, rotating the page would also rotating all the content in this page, so I suggest put the image in the same rotation as the page manually first and then rotate the page.

Sincerely,
Jane
E-iceblue support team
User avatar

Jane.Bai
 
Posts: 1156
Joined: Tue Nov 29, 2016 1:47 am

Return to Spire.PDF