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

The node provides functionality to add margins to PDF documents. It supports multiple input methods for the source PDF, including binary data from a previous node, base64-encoded strings, or a URL pointing to the PDF file. Users can specify custom margin sizes for all four sides (left, right, top, bottom) in millimeters. This operation is useful when you need to adjust the whitespace around the content of a PDF, for example, to prepare documents for printing with specific margin requirements or to ensure consistent layout across different PDFs.

Practical examples:

  • Adding uniform margins to scanned PDFs before printing.
  • Increasing margins on digital reports to improve readability.
  • Preparing PDFs for binding by adding extra space on one side.

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 (directly provide base64 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 name 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 in millimeters. Accepts values between 0 and 100. Default is 20 mm.
Right Margin (Mm) Size of the right margin in millimeters. Accepts values between 0 and 100. Default is 20 mm.
Top Margin (Mm) Size of the top margin in millimeters. Accepts values between 0 and 100. Default is 25 mm.
Bottom Margin (Mm) Size of the bottom margin in millimeters. Accepts values between 0 and 100. Default is 25 mm.
Advanced Options Collection for additional settings. Currently supports "Custom Profiles" where users can provide JSON to adjust extra properties for the API call, such as output data format.
Binary Data Output Name Custom name for the binary data field in the node's output. Defaults to "data".

Output

The node outputs the processed PDF file with the specified margins added. The output includes:

  • A JSON object containing metadata about the operation.
  • A binary data field containing the resulting PDF file with margins applied. The binary field name can be customized via the "Binary Data Output Name" property.

If the input was binary or base64, the output will be a binary PDF file ready for further processing or saving. If the input was a URL, the node downloads the PDF, adds margins, and outputs the modified PDF similarly.

Dependencies

  • Requires access to an external PDF processing service or API that performs the margin addition operation.
  • Needs proper API authentication configured in n8n (e.g., an API key credential).
  • Network access is required if using URL input type or calling the external API.

Troubleshooting

  • Common issues:

    • Invalid or inaccessible PDF URL: Ensure the URL is reachable and points directly to a valid PDF file.
    • Incorrect base64 content: Verify the base64 string is correctly encoded and represents a valid PDF.
    • Margin values out of range: Margins must be between 0 and 100 mm; values outside this range may cause errors.
    • Missing or invalid API credentials: Confirm that the API key or authentication token is properly set up in n8n.
  • Error messages:

    • "Failed to fetch PDF from URL": Check network connectivity and URL correctness.
    • "Invalid PDF content": Validate the input PDF data or base64 string.
    • "API authentication failed": Recheck API credentials and permissions.
    • "Margin value out of bounds": Adjust margin inputs to allowed ranges.

Resolving these typically involves verifying input data formats, ensuring correct configuration of credentials, and confirming network accessibility.

Links and References

  • PDF4me API Documentation — For advanced options and custom profiles.
  • General information on PDF margin adjustments and use cases can be found in PDF editing tool documentation or printing guidelines.

Discussion