Skip to main content

Add Attachment to PDF using n8n action

PDF4me Add Attachment to PDF embeds various file types directly into PDF documents through n8n automation workflows. Process PDFs via n8n triggers, binary data, base64 strings, or public URLs to attach documents, images, spreadsheets, archives, and other files with preserved file integrity, metadata handling, and multi-format support (PDF, DOC, XLS, images, ZIP, etc.). This solution is ideal for document bundling, supporting material inclusion, file archiving, contract packaging, evidence attachment, and comprehensive document packages that require reliable file embedding with seamless integration.

Setup

Add the PDF4me "Add Attachment to PDF" node to your n8n workflow and configure the required parameters. For initial setup instructions, see our n8n Integration Guide.

Prerequisites:

  • PDF4me API credentials
  • n8n workflow access

Configuration:

  1. Add PDF4me node to workflow
  2. Select "Add Attachment to PDF" action
  3. Configure input parameters (see below)
Add Attachment to PDF

Parameters

Complete list of parameters for the Add Attachment to PDF action. Configure these parameters to control file attachment.

Important: Parameters marked with an asterisk (***) are required and must be provided for the action to function correctly.

ParameterTypeDescriptionExample
Input Data Type***StringPDF Input Format Selection
• Choose the format of your PDF data input
• PDF4me supports multiple input types
• Options: Binary Data, Base64 String, or URL
Binary Data
Input Binary FieldBinaryBinary PDF File Input (Required if Binary Data)
• Reference PDF file from previous n8n node or file upload
• PDF4me processes binary PDF files with automatic format detection
• Required when Input Data Type is "Binary Data"
{{ $binary.data }}
Base64 Document ContentStringBase64 Encoded PDF Input (Required if Base64 String)
• Provide PDF data as base64 encoded string
• PDF4me automatically decodes and processes the PDF content
• Required when Input Data Type is "Base64 String"
UEsDBBQABgAI...
File URLStringPublic PDF URL Input (Required if URL)
• Provide a public/open permission URL to the PDF file
• PDF4me downloads and processes the file from URL
• Required when Input Data Type is "URL"
https://abc.com/sample.pdf
Output File Name***StringEnhanced PDF Output Filename
• Specify the name for the generated PDF file
• Must include .pdf extension
• PDF4me ensures unique naming and format validation
document_with_attachments.pdf
Document Name***StringSource PDF Reference
• Specify the name of the source PDF file
• For reference and tracking purposes
• Helps with processing tracking
document.pdf
Attachments***ArrayAttachment Configuration
• Array of attachment objects containing file data and metadata
• Each object must include fileName, fileContent, and optional description
• Supports multiple file types and formats
• Essential for file embedding
[{"fileName": "doc.pdf", "fileContent": "{{ $binary.doc }}"}]
Binary Data Output Name***StringBinary Data Output Mapping
• Define the variable name for accessing generated PDF binary data
• Used in subsequent workflow actions
• Essential for workflow automation
data

Attachment Object Structure

FieldTypeRequiredDescriptionExample
Attachment Content TypeStringYesPDF4me attachment input format - Choose how the attachment file is provided (Binary Data, Base64 Content, or File URL)Binary Data
Attachment NameStringYesPDF4me attachment filename - Name of the file to be attached to the PDF document. Must include proper file extension for format identificationdocument.txt
Base64 ContentStringYes (If Base64)PDF4me base64 encoded attachment - Base64 encoded content of the attachment file. Required when Attachment Content Type is "Base64 Content"SGVsbG8gV29ybGQ=
Binary Field NameStringYes (If Binary Data)PDF4me binary attachment reference - Name of the binary field containing the attachment file. Required when Attachment Content Type is "Binary Data"data
File URLStringYes (If URL)PDF4me attachment URL - Public URL to the attachment file. Required when Attachment Content Type is "File URL"https://example.com/files/document.txt

Supported File Types

CategoryFile TypesDescription
DocumentsPDF, DOC, DOCX, TXT, RTF, ODTText documents and office files
ImagesJPG, JPEG, PNG, GIF, BMP, TIFF, SVGImage files and graphics
SpreadsheetsXLS, XLSX, CSV, ODSData files and spreadsheets
PresentationsPPT, PPTX, ODPPresentation files
ArchivesZIP, RAR, 7Z, TARCompressed file archives
OtherJSON, XML, HTML, CSSWeb and data files

Output

Output Parameters

ParameterTypeDescriptionExample
fileNameStringPDF4me generated PDF filename - The complete filename of the successfully generated PDF document with proper .pdf extension. PDF4me ensures unique naming and validates file format compliance for seamless integration with downstream processesdocument_with_attachments.pdf
fileSizeNumberPDF4me PDF file size in bytes - The exact size of the generated PDF file in bytes, provided by PDF4me for storage planning, bandwidth optimization, and file transfer monitoring. Essential for enterprise document management and workflow automation101714
successBooleanPDF4me attachment status indicator - Boolean flag indicating the success or failure of the PDF attachment process. PDF4me returns true for successful attachments and false for any errors, enabling robust error handling in automated workflowstrue
mimeTypeStringPDF4me output MIME type - MIME type of the generated PDF file, always "application/pdf" for PDF documents. Useful for content type validation and proper file handling in web applicationsapplication/pdf
attachmentCountNumberPDF4me attachment count - Number of attachments successfully added to the PDF document. Provides verification of successful file embedding and helps track document enhancement progress1
messageStringPDF4me attachment status message - Human-readable status message providing details about the attachment process result. Includes success confirmation or error details for troubleshootingPDF with attachments created successfully

N8N Action Response

The PDF4me Add Attachment to PDF API returns a response that can be viewed in multiple formats. Choose the view that best fits your needs:

JSON Response Format

The raw JSON response from the API:

[
{
"success": true,
"message": "PDF with attachments created successfully",
"fileName": "document_with_attachments.pdf",
"mimeType": "application/pdf",
"fileSize": 101714,
"attachmentCount": 1
}
]

Use Cases

Document Bundling and Information Management

  • Add supporting documents, reference materials, and supplementary files as attachments to PDF documents for comprehensive information management and document bundling
  • Process business proposals, project documentation, and client deliverables by adding relevant attachments for complete information delivery and stakeholder communication
  • Transform legal documents, contracts, and official records by adding supporting evidence, certificates, and reference materials for complete documentation and legal compliance

Business Process and Workflow Integration

  • Add supporting documents, forms, and reference materials as attachments to PDF documents for streamlined business processes and workflow integration
  • Process invoices, purchase orders, and financial documents by adding supporting receipts, contracts, and approval documents for complete financial documentation
  • Transform project reports, deliverables, and business communications by adding supporting data, charts, and reference materials for comprehensive project documentation

Compliance and Regulatory Documentation

  • Add compliance certificates, audit reports, and regulatory documents as attachments to PDF documents for regulatory compliance and audit trail documentation
  • Process quality control documents, inspection reports, and certification materials by adding supporting evidence, test results, and compliance certificates
  • Transform official documents, permits, and regulatory filings by adding supporting documentation, evidence, and reference materials for complete regulatory compliance

Get Help