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

Free Support Forum - aspose.com

Aspose.pdf.pageInfo incorrect

I’m trying to retrieve things like height, width, isLandscape, and rotation but it seems that when I load a document all these values are at a set value. No matter what PDF I load, it seems that pageinfo shows the height as 842 and the width as 595. I believe this is in points which would convert to an A4 size piece of paper. isLandscape is always false and rotation is always none.


Here is roughly how I’m loading the PDF

Aspose.Pdf.Document pdfdoc = new Aspose.Pdf.Document(stream);

and I have tried to access the data items directly like

double height = pdfdoc.PageInfo.Height;

as well as trying to get a specific page and then check properties such as

Aspose.Pdf.Page pdfPage = pdfdoc.Pages[1];
double height = pdfPage.PageInfo.Height;

I have searched and don’t see this report anywhere else which makes me think I am doing something wrong but I’m just not sure

Thanks for any help you can provide.

Rick

Hi Rick,


Thanks for your inquiry. I’ve noticed that PageInfo object is not being returning correct pate info and logged an issue as PDFNEWNET-35879 for further investigation and resolution. We will update you as soon as it’s resolved.

Meanwhile, you may get page dimensions from rectangle of page as following. To consider rotation parameter in calculation use GetPageRect(bool considerRotaion) method.

Document pdfDocument
= new Document(myDir

  • “TestLandscape.pdf”);<o:p></o:p>

//get page collection

PageCollection pageCollection = pdfDocument.Pages;

//get particular page

Page pdfPage = pageCollection[1];

//To considering rotation in page width and height info

Aspose.Pdf.Rectangle rect = pdfPage.GetPageRect(true);

//get page properties

Console.WriteLine("Page {0} width is {1} and heigth is {2}, rotation: {3}, size considering rotation: widht {4} : height {5}",

pdfPage.Number, pdfPage.Rect.Width, pdfPage.Rect.Height, pdfPage.Rotate.ToString(), rect.Width, rect.Height);

Console.ReadLine();


We are sorry for the inconvenience caused.

Best Regards,

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


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

Hi,

I can reproduce the original problem in PDFNEWNET-35879, that should be fixed in .Net 8.7.0 in Version 19.4.0.
Maybe regression.

@johndoe0001

Thank you for contacting support.

Please try using below code snippet to read width and height of pages:

Document document = new Document(dataDir + "Test.pdf");
PdfFileInfo info = new PdfFileInfo(document);
Console.WriteLine("Width: " + info.GetPageWidth(document.Pages[1].Number));
Console.WriteLine("Height: " + info.GetPageHeight(document.Pages[1].Number));
OR
Console.WriteLine("Height: " + info.GetPageHeight(1));

We hope this will be helpful. If you still notice any problem then please share narrowed down code snippet along with source document so that we may investigate further and help you out.