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 "Add Attachment To PDF" operation allows users to add one or more file attachments to an existing PDF document. This node is useful in scenarios where you want to bundle supplementary files (such as text documents, images, or other PDFs) inside a PDF container for distribution or archiving purposes. For example, attaching a user manual or related documentation directly into a product specification PDF.

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. Similarly, attachments can be supplied in these formats. The node processes the input PDF and embeds the specified attachments, outputting a new PDF file with the attachments included.

Properties

Name Meaning
Input Data Type How the source PDF is provided. Options: Binary Data (from previous node), Base64 String (base64 encoded content), URL (link to PDF file).
Input Binary Field Name of the binary property containing the PDF file when using Binary Data input type (default: "data").
Base64 PDF Content Base64 encoded content of the PDF document when using Base64 String input type.
PDF URL URL to the PDF file when using URL input type.
Output File Name Desired filename for the resulting PDF with attachments (default: "document_with_attachments.pdf").
Document Name Reference name for the source PDF file (default: "document.pdf").
Attachments Collection of files to attach to the PDF. Each attachment includes:
- Attachment Content Type: How the attachment content is provided (Binary Data, Base64 String, or URL).
- Attachment Name: Filename for the attachment (required).
- Base64 Content: Base64 encoded attachment content.
- Binary Field Name: Binary property name containing the attachment file.
- File URL: URL to the attachment file.
Advanced Options Additional settings:
- Custom Profiles: JSON string to customize API call properties.
- Use Async Processing: Boolean to enable asynchronous processing (recommended for large files or high volume).
Debug Options Debugging controls:
- Enable Debug Mode: Turn on detailed logging.
- Debug Log Level: Choose between Basic or Detailed logs.
- Log to Console: Whether to output debug logs to console.

Output

The node outputs a JSON object containing the processed PDF file with the added attachments. The main output field is:

  • binary: Contains the resulting PDF file data, typically under a binary property named according to the node's configuration.
  • json: Metadata about the operation result may be included but primarily the binary data holds the updated PDF.

If debug mode is enabled, additional logging information may be available in the output or console.

Dependencies

  • Requires access to an external PDF processing service API that supports adding attachments to PDFs.
  • Needs proper API authentication credentials configured in n8n (e.g., an API key or token).
  • Network access to fetch PDFs or attachments if URLs are used.
  • Optional: JSON profiles for advanced customization of the API calls.

Troubleshooting

  • Common Issues:

    • Incorrect binary property names leading to missing input files.
    • Invalid base64 strings causing decoding errors.
    • Unreachable URLs or network issues when fetching PDFs or attachments.
    • Missing required fields such as attachment names.
    • Large files causing timeouts or memory issues if async processing is disabled.
  • Error Messages:

    • Errors related to invalid input format usually indicate mismatched inputDataType and provided data.
    • API errors might mention authentication failures; ensure API credentials are valid.
    • Timeout or server errors suggest enabling async processing or reducing file sizes.
  • Resolutions:

    • Verify all required fields are correctly set.
    • Use async processing for large files.
    • Check network connectivity for URL inputs.
    • Enable debug mode to get detailed logs for troubleshooting.

Links and References

Discussion