How to add footer per page in GeneratePDFService htmlFileToPdf
How to add footer per page in GeneratePDFService htmlFileToPdf
I have a long html file that results into a multi page pdf file, I would like to put a footer per page, is there something I can add to this to make that happen?
This is my code:
BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
ServiceReference < ? > serviceRef = bundleContext.getServiceReference(GeneratePDFService.class.getName());
GeneratePDFService pdfService = (GeneratePDFService) bundleContext.getService(serviceRef);
XMPMeta xmpData = new XMPMeta();
xmpData.
// temporary files names
String randomAlphaNum = randomAlphaNumeric(7);
String tempHTMLFileName = randomAlphaNum + "convert.html";
// Create zip file of the HTML as the pdf service only accepts zip file
StringBuilder sb = new StringBuilder();
sb.append(htmlText);
ByteArrayOutputStream zipbaos = new ByteArrayOutputStream();
ZipOutputStream zipper = new ZipOutputStream(zipbaos);
ZipEntry e = new ZipEntry(tempHTMLFileName);
zipper.putNextEntry(e);
zipper.write(htmlText.getBytes(StandardCharsets.UTF_8));
zipper.closeEntry();
zipper.close();
// Create Document to convert from zip file bytearray
java.io.InputStream docIS = new ByteArrayInputStream(zipbaos.toByteArray());
com.adobe.aemfd.docmanager.Document uploadedDocument = new com.adobe.aemfd.docmanager.Document(docIS);
// For HTML to PDF conversion using HTML File jsp version:
com.adobe.pdfg.result.HtmlToPdfResult result = pdfServiceice.htmlFileToPdf(uploadedDocument, null, null, null, null);
com.adobe.aemfd.docmanager.Document convertedDoc = result.getCreatedDocument();
convertedDoc.setMaxInlineSize(1000000000);
zipbaos.flush();
zipbaos.close();
// return pdf document
return convertedDoc;