Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.
SOLVED

htmlFileToPdf method failing to generate PDF

Avatar

Level 4

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

 

@component(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();
		}
} 

}

 

 

 

1 Accepted Solution

Avatar

Correct answer by
Level 4
3 Replies

Avatar

Level 4

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.

Avatar

Correct answer by
Level 4

closing this thread as I have moved the question to AEM forms community

https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-forms/generatepdfservice-h...