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

Free Support Forum - aspose.com

Wrong page size when reading

Hi,


I’m using Aspose.Pdf 9.1.0, and I’m creating a document with a page size of 64x64. I’ve checked the document with Mac Preview and Acrobat Pro, it looks ok.

When reloading the document using the following code, the page size is always 842x595. I’ve also tried with other documents created with other software, with different page sizes, and Aspose always returns the same size, no matter the page ratio or size.

Am I doing something wrong, or is this a bug?

Code:
Document pdfDoc = new Document(file);
final Page page = pdfDoc.getPages().get_Item(1);
System.out.println(page.getPageInfo().getWidth() + page.getPageInfo().getHeight());

Hi Edu,


Thanks for using our API’s.

I have tried viewing the PDF file in Adobe Reader 9.2.0 and as per my observations, the dimensions of PDF file being displayed are 8.26 X 11.69 in (which are 8.26 x 72 = 594.72 and 11.69 x 72 = 841.68). The information being returned by Aspose.Pdf for Java seems to be correct.

However, recently we have observed that similar page dimensions are being returned when using PDF files with various dimensions. The problem is already logged in our issue tracking system as PDFNEWJAVA-34178. The development team will further look into this matter and will keep you posted on the status of correction.

However, can you please double check the dimensions information of mini.pdf and in case you have any other sample PDF files, please share the resource files and we will definitely consider these scenarios during the resolution of this problem. We are sorry for this inconvenience.

Hi Nayyer,


I’m sorry, I sent you the wrong file. I’ve attached the correct one.

Do you know if there is any workaround to get the actual size of the document instead of a made up dimension?

Thanks

Hi Edu,


Thanks for sharing the resource file.

I have tested the scenario and have observed that incorrect page dimensions are being returned. The file has been associated with earlier reported PDFNEWJAVA-34178 and the development team will definitely consider this scenario during the resolution of this issue. Please be patient and wait for the resolution.

Hi Edu,


As a workaround, please try using following code lines to get page dimensions.

[Java]

com.aspose.pdf.facades.PdfFileInfo info = new com.aspose.pdf.facades.PdfFileInfo();<o:p></o:p>

info.bindPdf(“c:/pdftest/square.pdf”);<o:p></o:p>

System.out.println("Height = "+ info.getPageHeight(1));<o:p></o:p>

System.out.println("Width = "+ info.getPageWidth(1));