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;
Solved! Go to Solution.
Views
Replies
Total Likes
PDFG Web Capture uses Acrobat for the conversion and to enable the header and footer, you need to follow the below-mentioned steps on Acrobat installed on the Forms server.
1. File > Create > Create PDF from any format.
2. Select "Web Page" and then advanced settings.
3. The Web Page Conversion Settings dialog displays.
4. Tick "Place headers and footers on a new page".
Let me know in case you're stuck.
I think the configuration for headers and footers needs to be set on the Acrobat (Web Capture service) instead of the PDFG service.
There is an option “Place Headers And Footers On New Page” as mentioned in https://helpx.adobe.com/acrobat/using/converting-web-pages-pdf.html. By default, you'll see the web page title in the header and the URL/path in the footer.
Hope this helps.
Sorry what I am doing is combining different experience fragments based on tags to combine them in one html then convert that html to pdf. I don't think I can use that. As it is not actually a web page I am converting.
I don't think that input documents should be a concern as you're able to convert this HTML page into a PDF. Can you try to update the Acrobat settings on the Forms server to enable the header/footer and check if that serves the purpose?
How do I do that?
PDFG Web Capture uses Acrobat for the conversion and to enable the header and footer, you need to follow the below-mentioned steps on Acrobat installed on the Forms server.
1. File > Create > Create PDF from any format.
2. Select "Web Page" and then advanced settings.
3. The Web Page Conversion Settings dialog displays.
4. Tick "Place headers and footers on a new page".
Let me know in case you're stuck.
I need a way using com.adobe.pdfg as this is my use case, the webpage is dynamically built
Views
Replies
Total Likes
As mentioned previously, PDFG internally uses Acrobat (Web Capture service) for conversion, and the settings for header/footer are exposed via Acrobat configurations.
If there is a gap in understanding of the use case, feel free to reach out to us via a support ticket and we can connect over a quick call to discuss further.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies