How to Customize Headers and Footers in Adobe HTML-to-PDF Java API
Question details
Users want to know how to insert custom content into headers and footers instead of using the default values when converting documents with the Adobe HTML-to-PDF Java API.

- Product
- Adobe PDF Services API
- Device & OS
- not provided
- Scenario
- Converting HTML files to PDF documents programmatically using Java.
- Observed behavior
- The includeHeaderFooter(false) method only toggles the standard headers and footers on or off, but does not provide a native way to pass custom text or templates within the builder itself.
Verify your current version of the Adobe PDF Services SDK for Java, as native support for custom header and footer templates may vary by release.
Embed Custom Headers and Footers in the Source HTML
The most effective way to include custom headers and footers during the HTML-to-PDF conversion is to build them directly into your source HTML using CSS.
Since the basic Java builder does not accept custom strings for headers and footers, you can leverage standard HTML and CSS features to force elements to repeat on printed pages.
Open your source HTML file and add dedicated <div> containers with your custom header and footer text or images.
Style these containers using CSS with 'position: fixed'. Set the header to 'top: 0;' and the footer to 'bottom: 0;' so they repeat on every printed page.
In your Java code, configure the HTMLtoPDFOptions builder with 'includeHeaderFooter(false)' to prevent the default Adobe tags from overlapping your custom HTML design.
Post-process the Generated PDF with a Library
If you cannot modify the source HTML, you can stamp custom headers and footers onto the document after the initial PDF generation.
Easily Customize PDF Headers and Footers with WPS Office
If programmatic solutions are too complex for a one-off task, you can visually edit your generated PDFs to include custom headers, footers, and page numbers using the intuitive WPS Office PDF Editor.
- 1. Open Your PDF: Launch WPS Office and open the PDF document you generated from your HTML files.
- 2. Navigate to the Insert Tab: Click on the 'Insert' tab located in the top ribbon and select 'Header and Footer'.
- 3. Input Custom Content: Choose 'Add Header and Footer', then type your custom text, set up automatic page numbering, and adjust the margins to fit your design.
- 4. Apply and Save: Preview your changes, click 'Apply' to embed the content across all pages, and save your updated PDF file.

Frequently Asked Questions
Why does includeHeaderFooter(true) only show standard text?
In the Adobe HTML-to-PDF Java API, the includeHeaderFooter option is a simple toggle. When set to true, it applies a default template that includes the page URL, title, and standard numbering, but it does not natively accept custom string parameters.
Can I use CSS to add headers and footers during the HTML-to-PDF conversion?
Yes, utilizing standard CSS properties like fixed positioning (position: fixed) or @page margin rules in your source HTML is a highly effective way to render custom repeating headers and footers in the final PDF.
Is it possible to completely remove the default Adobe footer?
Absolutely. You can remove the default header and footer entirely by setting includeHeaderFooter(false) in your API options, which clears the margins for your own custom elements.




