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 Apr 29, 2022 2:19 am

Hello,

In testing Spire PDF outputs, I've noticed that with a particular document Spire seems to read the document with an incorrect orientation, as though the document was rotated 180 degrees.
When trying to draw strings on the Spire loaded PDF, the output appears to be upside down in both position and text orientation.


I've attached the original document and a version of the document that was loaded into an unlicensed version of Spire to this post.

As you'll notice with the unlicensed Spire read document, the Spire Watermark appears to print at the bottom of the page and upside down.

Please let me know if you can reproduce this issue and what steps I can take (if any) to alleviate the problem.

Thank you,
Zac

ZCliff92
 
Posts: 28
Joined: Thu Jan 20, 2022 1:58 am

Fri Apr 29, 2022 6:45 am

Hello,

Thank you for your inquiry.
After investigation, I found that all pages of the input file you provided are rotated by 180 degrees. Please use the following code to turn the PDF page back to the source location.
Code: Select all
PdfDocument doc = new PdfDocument();
doc.LoadFromFile("Original-PDF.pdf");
PdfDocument pdfDocument = new PdfDocument();
foreach (PdfPageBase pages in doc.Pages)
{
    Console.WriteLine(pages.Rotation);
    float width = pages.Size.Width;
    float height = pages.Size.Height;
    //Add new page with expected width and height
    PdfPageBase page = null;
    if (pages.Rotation == PdfPageRotateAngle.RotateAngle90 || pages.Rotation == PdfPageRotateAngle.RotateAngle270)
    {
        page = pdfDocument.Pages.Add(new SizeF(height, width), new PdfMargins(0));
    }
    else
    {
        page = pdfDocument.Pages.Add(new SizeF(width, height), new PdfMargins(0));
    }
    page.Canvas.DrawTemplate(pages.CreateTemplate(), PointF.Empty);
}
pdfDocument.SaveToFile("result.pdf", FileFormat.PDF);
Console.ReadLine();

Sincerely,
Annika
E-iceblue support team
User avatar

Annika.Zhou
 
Posts: 1643
Joined: Wed Apr 07, 2021 2:50 am

Return to Spire.PDF