htmlFileToPdf method failing to generate PDF | Community
Skip to main content
manu-gupta
Level 4
March 14, 2022
Solved

htmlFileToPdf method failing to generate PDF

  • March 14, 2022
  • 2 replies
  • 1165 views

HI folks

we are trying to create a Servlet using Component and ask is to generate PDF from HTML File using following code but it is throwing an exception

 

com.adobe.pdfg.exception.ConversionException: ALC-PDG-080-019-Input file File.zip does not contain the index html file.

The HTML file I am using is basic one and converting to aemfd doc before passing to conversion method.

Pl help share inputs where things are wrong

AEM 6.5.8 OSGI AEM Forms on Linux

 

@8220494(service = Servlet.class, property = { Constants.SERVICE_DESCRIPTION + "=Testing Report Generation","sling.servlet.paths=" + "/bin/test-automation-report",}) public class HTMLtoPDFServlet extends SlingSafeMethodsServlet { @Reference GeneratePDFService pdfGenService ; protected void doGet(final SlingHttpServletRequest request, final SlingHttpServletResponse response) throws ServletException, IOException { String inputFileName = "C://Users//manu.gupta//Downloads//testing//Test-Automation.html"; InputStream is = new FileInputStream(inputFileName); Document returnDoc = new com.adobe.aemfd.docmanager.Document(is); String securitySettings = "No Security"; String fileTypeSettings = "Standard"; com.adobe.pdfg.result.HtmlToPdfResult result; try { result = pdfGenService.htmlFileToPdf(returnDoc, securitySettings, fileTypeSettings, null, null); //Get the newly created document com.adobe.aemfd.docmanager.Document createdDocument = result.getCreatedDocument(); } catch (ConversionException | InvalidParameterException | FileFormatNotSupportedException e) { e.printStackTrace(); } } }

 

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

2 replies

Anish-Sinha
Adobe Employee
Adobe Employee
March 14, 2022

Hi @manu-gupta ,

This is a working example. I used this a while ago and was able to convert to pdf successfully. - https://labs.tadigital.com/index.php/2018/04/23/generating-pdf-from-html-in-adobe-experience-manager-6-1/

 

manu-gupta
Level 4
March 15, 2022

HI Anish

I dont need a iTextRenderer or any other API solution. My ask is for AEM forms Services method on why it is not working.

manu-gupta
manu-guptaAuthorAccepted solution
Level 4
March 15, 2022