We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Wrong PageInfo for landscape?

The pages of my Pdf actually are in landscape mode…
But how can I detect this.
My goal is simply to initialize a PngDevice in order to export Pages with their original ratio.

Below is the PageInfo I obtain…
According to http://stackoverflow.com/questions/12050743/how-to-find-whether-pdf-has-landscape-orientation-or-portrait, the IsLandscape
property (and IMO the PageInfo.Width/Height) seems not to be correctly infered by Aspose…
I understand that all those Rects are not simple to “integrate” into one “simple final Rect for the Page”. I thought that the PageInfo SHOULD hold the result of this subtle computation…

PageInfo:
Height 842.0
IsLandscape false
Margin {Aspose.Pdf.MarginInfo}
Width 595.0

Rect: {0,0,841,595}
TrimBox: {0,0,841,595}
MediaBox: {0,0,841,595}
ArtBox: {0,0,841,595}
BleedBox: {0,0,841,595}
CropBox: {0,0,841,595}

Which properties should I consider to correctly obtain the Rect to use to configure the PngDevice?

Regards,

Olivier

Hi Olivier,


Thanks for contacting support.

In order to determine if the source PDF file is in Landscape orientation or Portrait, you need to get the page dimensions and compare the values. If Page width is greater than page height, it indicates that page is in Landscape mode. The following code snippet can be used to get the page dimensions.

The default unit is point and in order to convert the values to inches, we need to divide the values by 72.

[C#]

Document doc = new Document(“c:/pdftest/Paysage.pdf”);<o:p></o:p>

double pageHeight = doc.PageInfo.Height;

double pageWidth = doc.PageInfo.Width;

Console.WriteLine("Height = "+ pageHeight/72 + " Width "+ pageWidth/72);

Console.WriteLine(doc.Pages[1].GetPageRect(false).Width/72 + "----" + doc.Pages[1].GetPageRect(false).Height/72);


But I am afraid the current version of Aspose.Pdf for .NET has some issues while returning page dimensions information. For the sake of correction, I have logged it in our issue tracking system as PDFNEWNET-36818. We will investigate this issue in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

The issues you have found earlier (filed as PDFNEWNET-36818) have been fixed in Aspose.Pdf for .NET 9.5.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.
(11)