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, a base64 encoded string, 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 archiving.
  • Adjusting margins on dynamically generated reports to fit printing templates.
  • Preparing PDFs for binding by increasing left or right margins.

Properties

Name Meaning
Input Data Type Method to provide the PDF: "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 (used if Input Data Type is "Binary Data").
Base64 PDF Content Base64 encoded string representing the PDF document (used if Input Data Type is "Base64 String").
PDF URL URL to the PDF file to add margins to (used if Input Data Type is "URL").
Output File Name Desired filename for the output PDF with added margins.
Document Name Reference name for the source PDF file.
Left Margin (Mm) Size of the left margin in millimeters (0-100).
Right Margin (Mm) Size of the right margin in millimeters (0-100).
Top Margin (Mm) Size of the top margin in millimeters (0-100).
Bottom Margin (Mm) Size of the bottom margin in millimeters (0-100).
Advanced Options Optional JSON string to specify custom profiles and additional API options for advanced margin adjustments.
Binary Data Output Name Custom name for the binary data field in the node's output.

Output

The node outputs the modified PDF file with the specified margins applied. The output includes:

  • A JSON object containing metadata about the processed file.
  • A binary data field containing the PDF file with the new margins applied. The name of this binary field 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, applies margins, and outputs the resulting PDF similarly.

Dependencies

  • Requires access to an external PDF processing service or API capable of adding margins to PDF files.
  • Needs proper API authentication configured in n8n (e.g., an API key credential).
  • Network access is required if using URL input type to fetch the PDF.

Troubleshooting

  • Common issues:

    • Invalid or inaccessible PDF URL leading to download failures.
    • Incorrect base64 string format causing decoding errors.
    • Margins set too large may cause layout issues or errors in processing.
    • Missing or incorrect binary property name when using binary input.
  • Error messages and resolutions:

    • "Failed to fetch PDF from URL": Check the URL validity and network connectivity.
    • "Invalid base64 content": Verify that the base64 string is correctly encoded and complete.
    • "Margin values out of range": Ensure margin values are between 0 and 100 mm.
    • "Binary property not found": Confirm the binary property name matches the actual input data.

Links and References

Discussion