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 adds page numbers to a PDF document. It is useful when you need to paginate existing PDF files for easier navigation, referencing, or printing purposes. Common scenarios include preparing reports, contracts, or multi-page documents where page numbering is required.

The node supports multiple input methods for the source PDF: binary data from a previous node, a base64 encoded string, or a URL pointing to the PDF file. Users can customize the appearance and placement of the page numbers, including font size, style (bold/italic), alignment, margins, and whether to skip numbering on the first page.

Practical examples:

  • Adding page numbers to a scanned contract PDF fetched via URL before sending it out.
  • Numbering pages in a dynamically generated PDF received as base64 content.
  • Processing PDFs uploaded in a workflow and adding page numbers aligned at the bottom-right corner with custom margins.

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 the PDF file).
Input Binary Field Name of the binary property containing the PDF file (used if Input Data Type is "Binary Data").
Base64 PDF Content Base64 encoded string of the PDF document (used if Input Data Type is "Base64 String").
PDF URL URL to the PDF file to add page numbers to (used if Input Data Type is "URL").
Output File Name Desired name for the output PDF file with page numbers added.
Document Name Name of the source PDF file for reference purposes.
Horizontal Alignment Horizontal position of the page numbers on the page: Left, Center, or Right.
Vertical Alignment Vertical position of the page numbers on the page: Top, Middle, or Bottom.
Horizontal Margin (Mm) Horizontal margin in millimeters (0-100) from the chosen horizontal alignment edge.
Vertical Margin (Mm) Vertical margin in millimeters (0-100) from the chosen vertical alignment edge.
Font Size Font size for the page numbering text, ranging from 8 to 72 points.
Set Bold Whether the page numbering text should be bold.
Set Italic Whether the page numbering text should be italicized.
Skip First Page Option to skip numbering on the first page of the document.
Advanced Options Custom JSON profiles to adjust extra properties for the API call, allowing advanced customization beyond standard options.

Output

The node outputs the processed PDF file with page numbers added. The output is typically provided as binary data representing the new PDF document. The output includes:

  • A JSON field containing metadata or references.
  • The binary data of the updated PDF file, which can be saved or passed to subsequent nodes.

If the input was binary or base64, the output will be binary data representing the modified PDF. If the input was a URL, the output similarly contains the updated PDF content.

Dependencies

  • Requires access to an external PDF processing service or API capable of adding page numbers to PDF documents.
  • Needs proper API authentication configured in n8n (e.g., an API key credential).
  • Internet access may be necessary if using the URL input option to fetch the PDF.

Troubleshooting

  • Common Issues:

    • Invalid or inaccessible PDF URL: Ensure the URL is reachable and points directly to a valid PDF file.
    • Incorrect binary property name: Verify that the binary field name matches the actual property containing the PDF data.
    • Malformed base64 content: Confirm the base64 string is correctly encoded and complete.
    • Font size or margin values out of allowed range: Use values within specified limits (font size 8-72, margins 0-100 mm).
  • Error Messages:

    • Errors related to fetching the PDF from URL usually indicate network issues or invalid URLs.
    • API errors might occur if authentication credentials are missing or incorrect.
    • Validation errors if input parameters are outside allowed ranges or missing required fields.
  • Resolutions:

    • Double-check all input parameters and ensure they conform to expected formats.
    • Validate connectivity and permissions for URL-based inputs.
    • Configure and verify API credentials in n8n settings.
    • Enable "Continue On Fail" in the node settings to handle errors gracefully during batch processing.

Links and References

Discussion