Hi,
I am facing issue in setting and getting page margin of existing PDF file. Whenever i try to extract page margin, I got (72.0,72.0,90.0,90.0) for top,bottom, left and right receptively.
After setting margin of PDF, I again got same dimension.
Please find the below implemented code and sample file for the reference.
Document document=new Document("C:\\Users\\saurav.saxena\\Documents\\Original File.pdf");
//Extract page margin pdf page
for(Page pdfPage:document.getPages())
{
System.out.println(pdfPage.getPageInfo().getMargin().getTop()+","
+pdfPage.getPageInfo().getMargin().getBottom()+","+
pdfPage.getPageInfo().getMargin().getLeft()+","+
pdfPage.getPageInfo().getMargin().getRight());
}
//Set margin with below values
for(Page pdfPage:document.getPages())
{
pdfPage.getPageInfo().setMargin(new MarginInfo(18, 36, 54, 72));
}
//document.save("C:\\Users\\saurav.saxena\\Documents\\Processed File.pdf");
Please check the issue and let me know.
Thanks and Regards
Saurav Saxena
pdf.pdf (423.8 KB)
Processed File.pdf (424.1 KB)