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

Free Support Forum - aspose.com

How do I get the *actual* page size (height & width) of a PDF

Aspose tells me a different size than what *actually comes out when I convert to a Jpeg or print*
var document = new Document("blah.pdf");
int width = document.Pages[1].Rect.Width // <-- this is a lie!!!
Every single "width" property on about 100 different fields that claim to tell me the size of the page is off by about 200 pixels...

Example, the result that comes from this code is about 200 px wider.
var jpegDevice = new JpegDevice(new Resolution(96), 90);

jpegDevice.Process(page, string.Format(@"{0}{1}.{2}.jpeg",
directory, Path.GetFileNameWithoutExtension(pdf), page.Number));

So, how do I get the real page size (height and width)?

Hi Timothy,

Thank you for the sample code. I tried using your code to test your issue but unable to replicate exact issue at my end. However, during my testing I did not find any issue with page width and height, for more detail please visit: Get Page Properties. If you still facing problem, We would appreciate if you create a sample application to show the issue. This will help us to figure out the issue and reply back to you soon.

We apologize for your inconvenience.

Thanks & Regards,

I believe I found the issue… the page size that comes from the API is in “Points”… but I’m looking for “Pixels”.

Is there a way to know the exact points-to-pixels in Aspose?

Hi Timothy,

Aspose.Pdf.Document allow you to set page size by taking width and height as parameter as below:

document.Pages[1].SetPageSize(816, 1056);

If you get the properties of a page after setting the above width and height, Aspose return the same size as you set.

However, There are 72 points per inch; if it is sufficient to assume 96 pixels per inch, the formula is rather simple:

pixels = points * 96 / 72

Moreover, please visit: Microsoft has a guide called “[Developing DPI-Aware Applications]”, look for the section “Creating DPI-Aware Fonts”.

Please feel free to contact support in case you need any further assistance.

Thanks & Regards,