PDF4me icon

PDF4me

Comprehensive PDF and document processing: generate barcodes, convert files, extract data, manipulate images, and automate workflows with the PDF4ME API

Actions80

Overview

This node operation "Add HTML Header Footer" allows users to add custom HTML content as a header, footer, or both to an existing PDF document. It supports multiple input methods for the source PDF, including binary data from a previous node, a base64 encoded string, or a URL pointing to the PDF file.

Common scenarios where this node is beneficial include:

  • Adding company branding or legal disclaimers as headers or footers on official PDF documents.
  • Inserting page numbers, dates, or other dynamic information formatted in HTML.
  • Enhancing PDFs with styled text or images in the header/footer areas without modifying the original content.

Practical example:

  • A user receives invoices as PDFs and wants to add a red-colored centered header with the company name on every page except the first. They can provide the PDF as binary data, specify the HTML content for the header, set margins, and choose to skip the first page.

Properties

Name Meaning
Input Data Type Choose how to provide the PDF file: "Binary Data" (from previous node), "Base64 String" (base64 encoded PDF content), or "URL" (link to PDF file).
Input Binary Field Name of the binary property containing the PDF file when using "Binary Data" input type (default is usually "data").
Base64 PDF Content Base64 encoded string of the PDF document content, used if "Base64 String" input type is selected.
PDF URL URL to the PDF file, used if "URL" input type is selected.
HTML Content The HTML markup to be added as header/footer. This is plain HTML (not base64) and can include styling such as fonts, colors, and alignment.
Location Where to add the HTML content: "Header", "Footer", or "Both".
Pages Specify which pages to process by indices or ranges (e.g., "1,3,5", "2-5", "1,3,7-10", or "2-"). Leave empty to apply to all pages.
Skip First Page Boolean flag to skip adding the header/footer on the first page.
Margin Left (Px) Left margin in pixels for the header/footer area.
Margin Right (Px) Right margin in pixels for the header/footer area.
Margin Top (Px) Top margin in pixels for the header/footer area.
Margin Bottom (Px) Bottom margin in pixels for the header/footer area.
Output File Name Desired filename for the output PDF with the added HTML header/footer.
Document Name Name of the source PDF file for reference purposes.
Use Async Processing Whether to use asynchronous processing mode, recommended for large files to improve performance.
Debug Mode Enable debug logging to assist troubleshooting.

Output

The node outputs the modified PDF document with the specified HTML header/footer applied. The output is typically provided as binary data representing the updated PDF file. The output also includes metadata such as the output file name.

If the input was binary data, the output will be binary data suitable for further processing or saving. If the input was base64 or URL, the output will similarly be the processed PDF content in binary form.

Dependencies

  • Requires access to an external PDF processing service or API capable of rendering HTML into PDF headers/footers and merging it with the original PDF.
  • Needs appropriate API credentials or authentication tokens configured in n8n to interact with the PDF processing backend.
  • Network access is required if providing the PDF via URL or if the processing service is cloud-based.

Troubleshooting

  • Common issues:

    • Invalid or inaccessible PDF URL: Ensure the URL is publicly accessible or reachable by the service.
    • Incorrect base64 content: Verify that the base64 string represents a valid PDF document.
    • Large PDF files may cause timeouts or slow processing; enable asynchronous processing to mitigate.
    • Malformed HTML content might not render correctly; validate HTML syntax and supported styles.
  • Error messages:

    • "Failed to load PDF": Check input PDF source and format.
    • "HTML content invalid": Review the HTML content for errors or unsupported tags.
    • "Timeout during processing": Enable async processing or reduce PDF size.
    • Authentication errors: Confirm API keys or credentials are correctly set up.

Links and References

Discussion