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 23, 2025 8:16 am

HI..

I know that origin in SPIRE is located on the top left corner
I would to know how works rotation angle

If I investigate te pdf file, I know that size is Widht=2384 height=3370 and rotation is 90°
so the file is vertical.
Wich scheme in the image is correct?
and the red dot (origin) is correct?

hantrax1
 
Posts: 2
Joined: Thu Jan 23, 2025 7:55 am

Thu Jan 23, 2025 10:19 am

Hello,

Thank you for your message. Your document is similar to the screenshot 2. Do you need to draw content on this document subsequently? If so, for your document, you can refer to the following code to rotate the canvas first and then draw new content to ensure the correct orientation of the content.

Code: Select all
            PdfDocument doc = new PdfDocument();
            doc.LoadFromFile(@"RC4800EZZP9IN2500001C_signed_signed.pdf");
            foreach (PdfPageBase page in doc.Pages)
            {
                if (page.Rotation == PdfPageRotateAngle.RotateAngle90 || page.Rotation == PdfPageRotateAngle.RotateAngle270)
                {
                    PdfGraphicsState state = page.Canvas.Save();
                    page.Canvas.RotateTransform(-90);
                    page.Canvas.TranslateTransform(-page.Size.Height, 0);
                    page.Canvas.DrawString("Hello, World!", new PdfFont(PdfFontFamily.Helvetica, 30f), new PdfSolidBrush(Color.Black), 0, 0);
                    page.Canvas.Restore(state);
                }
            }
            doc.SaveToFile(@"result_out.pdf", Spire.Pdf.FileFormat.PDF);

If you have any other questions, please feel free to contact me.

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1533
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.PDF