Skip to main content

Extract Attachment From PDF using n8n action

PDF4me Extract Attachment From PDF extracts embedded files from PDF documents through n8n automation workflows. Process PDFs via n8n triggers, binary data, base64 strings, or public URLs to automatically detect and extract attached documents, images, spreadsheets, data files, and other embedded content with preserved file integrity, metadata retention, and multi-format support (PDF, DOC, XLS, images, etc.). This solution is ideal for document analysis, file recovery, evidence extraction, attachment management, data extraction workflows, and comprehensive document processing that require reliable embedded file extraction with seamless integration.

Related Blog Posts
No blog post yet for this feature — coming soon.
In the meantime, browse the PDF4me blog for tutorials and workflows across every platform.
Visit the blog →

Setup​

Add the PDF4me "Extract Attachment From 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 "Extract Attachment From PDF" action
  3. Configure input parameters (see below)
Extract Attachment From PDF

Parameters​

Complete list of parameters for the Extract Attachment From PDF action. Configure these parameters to control attachment extraction.

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

ParameterRequiredWhat it doesExample
Input Data TypeRequiredChoose how to provide the PDF file to extract attachments from. Options: Binary Data, Base64 String, URL. Default is `Binary Data`.Binary Data
Input Binary FieldConditionalName of the binary property that contains the PDF file (usually "data" for file uploads). Shown when Input Data Type is Binary Data. Default is `data`.data
Base64 PDF ContentConditionalBase64 encoded PDF document content. Shown when Input Data Type is Base64 String.UEsDBBQABgAI...
PDF URLConditionalURL to the PDF file to extract attachments from. Shown when Input Data Type is URL.
Document NameOptionalName of the document (used for processing). Default is `document.pdf`.document.pdf
Binary Data Output NameOptionalCustom name for the binary data in n8n output. Default is `data`.data
Advanced OptionsOptionalOptional settings, collapsed behind Add Option.Add Option
Custom ProfilesOptionalUse 'JSON' to adjust custom properties. Review Profiles at https://dev.pdf4me.com/apiv2/documentation/ to set extra options for API calls and may be specific to certain APIs.{"outputDataFormat": "json", "extractMetadata": true}

Output​

Output Parameters​

FieldTypeWhat it contains
successBooleanTrue when the operation succeeded.
messageStringStatus message, `Attachment extracted successfully and converted to binary`.
fileNameStringFile name of the first attachment, as returned by PDF4me.
mimeTypeStringMIME type set from the attachment's extension (txt, pdf, jpg, jpeg, png, zip), `application/octet-stream` otherwise.
fileSizeNumberSize of the first attachment in bytes.
sourceFileNameStringName of the input PDF: the input file's name for Binary Data, the last part of the URL for URL, and Document Name for Base64.
processingTimestampStringTime the node received the result, ISO 8601.
totalAttachmentsNumberNumber of attachments PDF4me found in the PDF (only the first is returned).
dataBinaryThe first attachment of the PDF. The node fails when the PDF has no attachments.

Extracted Attachment Object Structure​

FieldTypeWhat it contains
successBooleanTrue when the operation succeeded.
messageStringStatus message, `Attachment extracted successfully and converted to binary`.
fileNameStringFile name of the first attachment, as returned by PDF4me.
mimeTypeStringMIME type set from the attachment's extension (txt, pdf, jpg, jpeg, png, zip), `application/octet-stream` otherwise.
fileSizeNumberSize of the first attachment in bytes.
sourceFileNameStringName of the input PDF: the input file's name for Binary Data, the last part of the URL for URL, and Document Name for Base64.
processingTimestampStringTime the node received the result, ISO 8601.
totalAttachmentsNumberNumber of attachments PDF4me found in the PDF (only the first is returned).
dataBinaryThe first attachment of the PDF. The node fails when the PDF has no attachments.

N8N Action Response​

The PDF4me Extract Attachment From 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:

[
{
"documents": null,
"outputDocuments": [
{
"fileName": "sample.txt",
"barcodeText": null,
"docText": null,
"image": null
}
],
"traceId": null,
"jobId": null,
"statusUrl": null,
"subscriptionUsage": null,
"_metadata": {
"success": true,
"message": "Attachments extracted successfully",
"processingTimestamp": "2025-09-23T20:04:09.290Z",
"sourceFileName": "document.pdf",
"operation": "extractAttachmentFromPdf"
}
}
]

Use Cases​

Document Content Recovery​

  • Embedded File Restoration: Use the outputDocuments array to recover files that were embedded within PDF documents, restoring access to original source materials
  • File Name Recovery: Extract original filenames from the fileName field to maintain proper file identification and organization
  • Lost Document Recovery: Restore documents that were previously embedded in PDFs but are no longer available in their original formats

Content Processing and Analysis​

  • Attachment Analysis: Process individual files from the outputDocuments collection to analyze content, extract data, or perform specific operations on each file type
  • Barcode Processing: Utilize the barcodeText field to extract and process barcode information from attachments for inventory, tracking, or identification purposes
  • Text Content Extraction: Leverage the docText field to extract textual content from document attachments for search, analysis, or data processing workflows

Workflow Automation and Integration​

  • File Distribution: Automatically distribute extracted attachments to appropriate systems, folders, or users based on file type and content analysis
  • Content Archiving: Use the _metadata.traceId and extraction results to maintain audit trails while organizing extracted files into structured archive systems
  • Multi-System Integration: Integrate extracted files with external document management systems, cloud storage platforms, or business applications

Get Help​