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 Margin To PDF" allows users to add custom margins around an existing PDF document. It is useful when you want to increase the whitespace around the content of a PDF, for example, to prepare documents for printing with specific margin requirements or to create space for annotations.

Typical use cases include:

  • Adding consistent margins to PDFs generated from other sources.
  • Preparing PDFs for binding or physical filing where extra margin space is needed.
  • Adjusting layout for better readability or compliance with formatting standards.

Users can provide the source PDF in multiple ways: as binary data from a previous node, as a base64 encoded string, or via a URL pointing to the PDF file.

Properties

Name Meaning
Input Data Type Choose how to provide the PDF file to add margins to. Options: Binary Data (from previous node), Base64 String (encoded PDF content), URL (link to PDF file).
Input Binary Field Name of the binary property containing the PDF file (used only if Input Data Type is Binary Data).
Base64 PDF Content Base64 encoded string representing the PDF document content (used only if Input Data Type is Base64 String).
PDF URL URL to the PDF file to add margins to (used only if Input Data Type is URL).
Output File Name Desired filename for the output PDF file with added margins. Defaults to "document_with_margins.pdf".
Document Name Name of the source PDF file for reference purposes. Defaults to "document.pdf".
Left Margin (Mm) Size of the left margin to add, in millimeters. Accepts values from 0 to 100. Default is 20 mm.
Right Margin (Mm) Size of the right margin to add, in millimeters. Accepts values from 0 to 100. Default is 20 mm.
Top Margin (Mm) Size of the top margin to add, in millimeters. Accepts values from 0 to 100. Default is 25 mm.
Bottom Margin (Mm) Size of the bottom margin to add, in millimeters. Accepts values from 0 to 100. Default is 25 mm.
Advanced Options Optional JSON string to specify custom profiles and additional API options for advanced margin adjustments. Users can refer to external API documentation for supported profile settings.

Output

The node outputs the modified PDF file with the specified margins added. The output is provided as binary data suitable for further processing or saving.

The main output field is:

  • json: Contains metadata about the processed file.
  • binary: Contains the actual PDF file data with the new margins applied, accessible under the configured binary property name.

Dependencies

  • Requires access to an external PDF processing API service that supports adding margins to PDF files.
  • Needs proper API authentication credentials configured in n8n to communicate with the PDF processing service.
  • Internet access is required if the input PDF is provided via URL.

Troubleshooting

  • Common Issues:

    • Providing an invalid or inaccessible URL will cause the node to fail fetching the PDF.
    • Incorrect base64 encoding or corrupted binary data may result in processing errors.
    • Specifying margin values outside the allowed range (0-100 mm) might cause validation errors.
    • Missing or incorrect API credentials will prevent successful communication with the PDF processing service.
  • Error Messages:

    • "Failed to fetch PDF from URL": Check the URL accessibility and correctness.
    • "Invalid PDF content": Verify the input data format and integrity.
    • "Margin value out of range": Ensure margin values are between 0 and 100 mm.
    • "Authentication failed": Confirm API credentials are correctly set up in n8n.

Links and References

Discussion