Quantcast
Channel: Aspose.Pdf Product Family
Viewing all articles
Browse latest Browse all 3131

Detect page rotations in PDF

$
0
0
Hi there,

I'm using Aspose.Pdf for .NET version 10.4. I have the next scenario. There are two stages.
At first stage I'm opening a PDF document, rotate some pages to specific angle (90, 180 or 270 degrees), and save this document as PDF.
At second stage I'm opening the previously saved PDF with rotated pages and want to detect, which pages were rotated at 1st stage, and on what angle. And the problem is - I cannot detect this, Aspose.Pdf detects all page rotations as 0.

My source code is below, it represents previously described 2 stages. This issue can be reproduced on different PDFs, so I decided not to attach them.

//1st stage - rotationg
String full_path = SharedData.FilesFolder + DocumentName;
FileStream fs = File.OpenRead(full_path);
using (Aspose.Pdf.Document document = new Document(fs))
{
     using (PdfPageEditor pdfPageEditor = new PdfPageEditor())
      {
           pdfPageEditor.BindPdf(document);
           pdfPageEditor.PageRotations[1] = 180;
           pdfPageEditor.PageRotations[2] = 90;
           pdfPageEditor.Save(SharedData.FilesOutputFolder + DocumentName + "_output.pdf");
      }
}

//2nd stage - checking existing rotations
using (Aspose.Pdf.Document document2 = new Document(SharedData.FilesOutputFolder + DocumentName + "_output.pdf"))
{
      using (PdfPageEditor pdfPageEditor2 = new PdfPageEditor())
      {
           pdfPageEditor2.BindPdf(document2);
           Console.WriteLine("Rotations. 1st page: " + pdfPageEditor2.GetPageRotation(1).ToString() +
"; 2nd page: " + pdfPageEditor2.GetPageRotation(2).ToString());
      }
}

From this code it can be seen, that I'm using "PdfPageEditor" for rotating and for detecting rotations, as it is described here: Working with Page Rotation .

Maybe, there is another way of adding and/or obtaining rotation angle, and this way can give me what I want - in that case please tell me what I need to do.


Thanks a lot.
With best wishes,
Denis Gvardionov

Viewing all articles
Browse latest Browse all 3131

Trending Articles