I have a html content which is taking the complete width of page but in PDF it is taking only 50% width

@subratamettle

You need to set bottom margins in original PDF in order to make enough space at the bottom of the page for footer. Please use following values for HtmlLoadOptions:

htmloptions.getPageInfo().setMargin(new MarginInfo(10,150,10,10));

and following for Footer:

footer.setMargin(new MarginInfo(0,0,0,-20));

Yes @asad.ali I also tried with below configuration for fitting footer value.

htmloptions.getPageInfo().setMargin(new MarginInfo(20,50,20,20));
footer.setMargin(new MarginInfo(5,0,5,5));

trying for Proper Width and height setting for looking good in pdf, somehow it’s not giving that wow factor , if text is less or more then alignment not looking properly.

@subratamettle

Thanks for your feedback.

Would you kindly provide sample PDF documents (one which is being generated at the moment at your side and other which is desired output). We will further investigate the scenario as per your requirements and share our feedback with you.

Hi @asad.ali
Currently i am using below line of code for generating the PDF…

++++++++++++++

HtmlLoadOptions htmloptions = new HtmlLoadOptions(basePath);
// set MarginInfo for margin details
htmloptions.getPageInfo().setWidth(1100); // in points 72pt = 1 inch
htmloptions.getPageInfo().setHeight(1500); // in points 72pt = 1 inch
// Commented below for now
htmloptions.getPageInfo().setMargin(new MarginInfo(20,50,20,20));

	// Load HTML file
	// Load HTML file
	Document doc = new Document(basePath + "Financial-Statement-Audit-Withoutfooter.html", htmloptions);

	// Save HTML file
	doc.save(basePath+"Financial-Statement-Audit-Withoutfooter1100-1500_mr20.pdf");

	Document document = new Document(basePath + "Financial-Statement-Audit-Withoutfooter1100-1500_mr20.pdf");
	HtmlFragment htmlContent =
	                new HtmlFragment("<html><body style=\"font-family: Arial, Helvetica, sans-serif; color: #333399; width: 100%;\">\n"+
	                		"<div style=\"position: relative;\">\n" +
	                        "        <div id='footerimage' style=\"position: absolute; top: 20px;\">\n" +
	                        "            <img src='content/dam/KPMG-service-guide/pdfIcons/klogo.png' style=\"width: 50px;\" />\n" +
	                        "        </div>\n" +
	                        "        <div id='footerDiv' style=\"font-size: 12px; position: absolute; left: 5%; top: 0;\">\n" +
	                        "            <p style=\"text-align: left !important;\">© 2018 KPMG International Cooperative (&quot;KPMG\n" +
	                        "                International&quot;), a Swiss entity. Member firms of the KPMG network of independent firms are\n" +
	                        "                affiliated with KPMG International. KPMG International provides no client services. No member firm has\n" +
	                        "                any authority to obligate or bind KPMG International or any other member firm vis-à-vis third parties,\n" +
	                        "                nor does KPMG International have any such authority to obligate or bind any member firm. All rights\n" +
	                        "                reserved. Use of this system is governed by <a\n" +
	                        "                    href=\"google.com\" title=\"KPMG\">KPMG's\n" +
	                        "                    Intranet Usage Policy</a>.</p>\n" +
	                        "            <p style=\"text-align: left !important;\">The Services Site does not include a comprehensive listing of all\n" +
	                        "                firm services. Therefore, other services, not listed, may be appropriate for certain client issues.\n" +
	                        "                    <b style=\"color: #00338d;\">The Services Site content is for internal use only and cannot be distributed\n" +
	                        "                    outside of the firm</b>.</p>\n" +
	                        "        </div>\n" +
	                        "        </div>\n"+
	                        "        </body></html>");
	htmlContent.setHtmlLoadOptions(new HtmlLoadOptions(basePath));
	HeaderFooter footer = null;
	for (Page page : document.getPages())
	{
	  footer = new HeaderFooter();
	  footer.getParagraphs().add(htmlContent);
	  //Commented below for now
	  footer.setMargin(new MarginInfo(5,0,5,5));
	  
	  page.setFooter(footer);
	}
	document.save(basePath + "Financial-Statement-Audit-Withfooter1100-1500_mr20.pdf");

++++++++++++

Summary

12-05-2020.zip (360.5 KB)

in zip one lone file name is generated with above code from html to pdf and other file is generated with other tool

@subratamettle

Thanks for providing requested details.

We have logged an investigation ticket as PDFJAVA-39406 in our issue tracking system for this scenario. We will further investigate to implement the functionality in the API to produce better results as you shared in your desired PDF document. We will inform you as soon as the logged ticket is resolved. Please be patient and spare us some time.

We are sorry for the inconvenience.