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

Free Support Forum - aspose.com

Finding Margin size of the PDF

HI ,

I have to find out the margin size of PDF. can you share me the sample code to open a pdf and find out the left and right margin size of a pdf.

Thanks and Regards,

Saran Raj.

HI ,

I have to find out the margin size of Existing PDF. can you share me the sample code to open a pdf and find out the left and right margin size of a pdf.

Thanks and Regards,

Saran Raj.

Hi Saran,


Thanks
for using our products.

I am afraid the requested feature is
currently not supported but for the sake of implementation, I have logged this
requirement in our issue tracking system under New Features list as
<span style=“font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:SimSun;mso-fareast-language:ZH-CN”>PDFNEWJAVA-33206
. We will further investigate this requirement
in details and will keep you updated on the status of a correction.

We apologize for your inconvenience.

Hi Saran,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.Pdf

I am afraid the requested feature is currently not supported. A new feature request has been registered in our issue tracking system as PDFNEWJAVA-33206. We will further investigate this requirement in details and will keep you informed regarding any updates.

Sorry for the inconvenience.<?xml:namespace prefix = u1 />

Hi Saran,


Thanks for your patience.

In order to get Left and Right Margins, please try using the following Code Snippet with latest release of Aspose.Pdf for Java 9.0.0.

[Java]

Document doc = new Document(path+“temp.pdf”);<o:p></o:p>

System.out.println(doc.getPages().get_Item(1).getPageInfo().getMargin().getLeft());

System.out.println(doc.getPages().get_Item(1).getPageInfo().getMargin().getRight());

//Also, you can get some more page config information:

System.out.println(doc.getPages().get_Item(1).getPageInfo().getWidth());

System.out.println(doc.getPages().get_Item(1).getPageInfo().getHeight());

System.out.println(doc.getPages().get_Item(1).getMediaBox().toString());

System.out.println(doc.getPages().get_Item(1).getCropBox().toString());

doc.close();

Most of the code does not work. I have 2 PDF documents.
One document page size is 11x16 and another document
page size is 10x7. Both width/height and margin info print out the
exact same information.

Hi Saran,


Thanks for sharing the feedback.

I have tested the scenario using some of my sample PDF files and have managed to reproduce the same issue (same height/width and margin information is being returned). However, can you please share the PDF files which you are using as it will further help us in investigating this problem at our end. We are sorry for this inconvenience.