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