Spire.PDFViewer is a powerful PDF Viewer component for .NET. It allows developers to load PDF document from stream, file and byte array.

Tue Nov 15, 2022 1:14 pm

Hello,

I have to view PDF-Drawings which are often incorrectly created (portrait instead of landscape). I want the user to rotate them if he wants. The problem is that Rotate(90) doesn't do anything (I think the PDF already has a rotation of 90°).

My question:
is it possible to find out the current rotation
or
is it possible to find out the current size of PDF
or
is it possible to rotate relatively? It seems the paramater of Rotate() works absolutely.

Kind regards

nlaschet

NLaschet
 
Posts: 4
Joined: Thu Nov 10, 2022 7:13 am

Wed Nov 16, 2022 7:24 am

Hello,

Thanks for your inquiry.
is it possible to find out the current rotation? is it possible to find out the current size of PDF?
Yes, you can do this with Spire.Pdf. I put the relevant code below for your reference.
Code: Select all
        // Create a pdf document
            PdfDocument doc = new PdfDocument();

            //Load an existing pdf from disk
            doc.LoadFromFile(@"..\..\data\input.pdf");

            //Get the first page of the loaded PDF file
            PdfPageBase page = doc.Pages[0];

            //Get the original rotation angle
            int rotation = (int)page.Rotation;

            //Get the width of page based on "point"
            float pointWidth = page.Size.Width;

            //Get the height of page
            float pointHeight = page.Size.Height;

//If the Page is rotated 90, set the PdfPageRotateAngle to 0.
     if (page.Rotation== PdfPageRotateAngle.RotateAngle90)
           {
               page.Rotation = PdfPageRotateAngle.RotateAngle0;
         }

is it possible to rotate relatively? It seems the paramater of Rotate() works absolutely.
Do you mean that only rotating the page direction but not rotating the content of Pdf file direction?

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 989
Joined: Tue Mar 08, 2022 2:02 am

Wed Nov 16, 2022 8:14 am

Thank you for your quick answer!

Yes, you can do this with Spire.Pdf.
OK thanks, so I have to install this module, too.

Do you mean that only rotating the page direction but not rotating the content of Pdf file direction?

No.
Please have a look into the attachment: I have a PDF which looks like icon 1. I want to see it correctly (like icon 2, so I would rotate it 90° clockwise. But when I use Rotate (90) I get icon 3. Doing again Rotate(90) doesn't change anything.

Kind regards
nlaschet

NLaschet
 
Posts: 4
Joined: Thu Nov 10, 2022 7:13 am

Wed Nov 16, 2022 9:01 am

Hello,

Thanks for your feedback.
OK thanks, so I have to install this module, too.
You don’t have to install a separate Spire.Pdf, due to the Spire.Pdf.dll is installed automatically (as shown in the screenshot below)when installing Spire.PdfViewer through Nuget.

Please have a look into the attachment: I have a PDF which looks like icon 1. I want to see it correctly (like icon 2, so I would rotate it 90° clockwise. But when I use Rotate (90) I get icon 3. Doing again Rotate(90) doesn't change anything.
For this scenario, I have some information to confirm with you:
1) Is your project a winform project with NET Framework4.8?
2) Are you using the latest version of Spire.PdfViewer 7.10?
3) Your test environment, such as OS info (E.g. Windows 7, 64-bit) and region setting (E.g. China, Chinese).

If possible, please provide a simple test project to help us reproduce your issue and work out a solution for you. If the project is a big file, you could upload the file to the DropBox or OneDrive and then share the download link with us. Thanks for your assistance in advance.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 989
Joined: Tue Mar 08, 2022 2:02 am

Wed Nov 16, 2022 11:44 am

Abel.He wrote:You don’t have to install a separate Spire.Pdf, due to the Spire.Pdf.dll is installed automatically (as shown in the screenshot below)when installing Spire.PdfViewer through Nuget.

OK fine, I missed that.

Abel.He wrote:If possible, please provide a simple test project to help us reproduce your issue and work out a solution for you. If the project is a big file, you could upload the file to the DropBox or OneDrive and then share the download link with us. Thanks for your assistance in advance.


Building a small test project I found out that instead of using
Code: Select all
Rotate(90)
I have to use
Code: Select all
Rotate(Math.Pi/4)
. This works like expected. So easy.
Sorry for confusion and thanks a lot!

Kind regards
nlaschet

NLaschet
 
Posts: 4
Joined: Thu Nov 10, 2022 7:13 am

Thu Nov 17, 2022 1:20 am

Hello,

Thanks for your feedback.
I'm glad to hear that your issue has been solved. If you have any issue in the future, just feel free to contact us.


Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 989
Joined: Tue Mar 08, 2022 2:02 am

Thu Nov 17, 2022 9:35 am

I have to correct this: the parameter of Rotate() is neither DEG nor RAD, it's RotateAngle.RotateAngle90, RotateAngle.RotateAngle180, RotateAngle.RotateAngle270.

NLaschet
 
Posts: 4
Joined: Thu Nov 10, 2022 7:13 am

Thu Nov 17, 2022 9:47 am

Hello,

Thanks for your correcting.

Sincerely
Abel
E-iceblue support team
User avatar

Abel.He
 
Posts: 989
Joined: Tue Mar 08, 2022 2:02 am

Return to Spire.PDFViewer