Converters

How to Extract Attachments From a PDF on Mac

Some PDFs hide other files inside them. One Terminal command lists every embedded file and another saves them all.

5 min read

Quick AnswerExtract attachments from a PDF on Mac in 2 ways. Use free pdfdetach or purpose built software. One command lists every embedded file. Another command saves them to a folder. Page images are not attachments. Check the file type before you open anything. Count the saved files against the list.

Invoices, contracts and reports sometimes arrive as one PDF with spreadsheets or images packed inside. Pages look normal so the extra files are easy to overlook. Below, you will see how to extract attachments from a PDF on Mac with a free tool and with bulk software.

What Is a PDF Attachment?

PDFs can embed entire files and the page text never shows them. Adobe documents ways to access, view and search file attachments in PDFs with Acrobat on Windows and macOS. Adobe also publishes settings to allow or refuse file attachments, which shows why you should treat unknown attachments with care.

How Does pdfdetach Extract Attachments From a PDF on Mac?

Who it suits. Technical users who work in Terminal. Extra application. Poppler, which includes pdfdetach.

pdfdetach ships with Poppler, an open source PDF library. Homebrew lists the poppler formula at version 26.11.0 with pdfdetach among its tools, under a dual GPL 2.0 or GPL 3.0 license.

  1. Install Poppler by entering brew install poppler in Terminal.
  2. Enter pdfdetach -list report.pdf to see the numbered embedded files.
  3. Create a folder, then enter pdfdetach -saveall -o attachments report.pdf to save them all into it.
2 embedded files\n1: data.csv\n2: notes.txt
Output of the list command on a test PDF, using pdfdetach version 24.02.0. Saved files retain their own names inside the output folder.

Option -save with a number saves one file and -o sets the file name for a single save or the folder for -saveall. Work on a copy of the PDF if the file matters.

Can You Extract Files From Encrypted PDFs?

pdfdetach accepts -upw for the user password and -opw for the owner password. Per the manual, the owner password bypasses all security restrictions so use passwords only on files you are entitled to open.

What Works When Terminal Is Not Practical?

One command per file works for a handful of PDFs. MacXTools PDF Extractor is built for folders of PDFs where scripting every one costs too much time.

Software of this kind saves the attachments of every PDF in a folder in one batch and filters them by file size or file type. A viewer with an attachments panel shows the embedded files in a PDF one file at a time, while Terminal suits a few files and scripts.

RouteWhat it doesBest for
pdfdetach in TerminalLists and saves embedded files with commandsA few PDFs and technical users
PDF viewer attachments panelShows the embedded files of one open PDFChecking whether a PDF has extras
Bulk extraction softwareSaves attachments from many PDFs into foldersFolders of PDFs

How Can You Tell Whether a PDF Has Attachments?

Page content gives no hint so you have to ask the file. List output from earlier prints how many embedded files exist and prints nothing useful when there are none. Some PDF viewers also show a paperclip icon or an attachments panel. Check there first if you only need to know whether a file contains extras, then use the command line for the actual extraction.

Are Page Images Attachments in a PDF?

People regularly mix up two different things. Embedded files are full files packed inside the PDF, like a spreadsheet. Images on a page belong to the page and are not attachments. Commands in this article handle embedded files only. If you want pictures from pages, that is a different task with different tools.

What Goes Wrong When You Save PDF Attachments?

  • Lists that show zero files need a second look. PDFs can have none or the extras can be images on pages, which this method does not extract.
  • Saved files have no extension or an odd name. Check the name in the list output, then rename the file manually if it lost its ending.
  • Two embedded files share a name. Save them one by one with the number option so one does not replace the other.
  • Password protected PDFs need the password options. Use the password options only on files you are allowed to open.
  • Saved files that will not open need the right app. Confirm the right app is installed for that type, for example a spreadsheet app for a CSV file.

What Does an Empty Attachment List Mean?

Empty lists do not always mean the file is plain or that the embedded files in a PDF are missing. Some documents link to files online instead of embedding them and some store extras as page content. If you expected attachments and the list shows none, ask the sender how the file was made or open the PDF in a viewer that shows an attachments panel and compare.

Are Embedded Files in a PDF Safe?

Embedded files can be anything, including an application. Extraction saves the file without starting it, which is the safe part. Opening it is where risk begins. Treat embedded files from unknown senders as you would an unexpected email attachment. Check the file type first, avoid executables and scripts and open documents in an app that you update regularly. If a business PDF unexpectedly contains an executable, that is a strong reason to stop and ask the sender.

Which Steps Extract Embedded Files Safely?

  1. Copy the PDF to a working folder.
  2. List the embedded files and note the count.
  3. Create an output folder and save them all into it.
  4. Compare the saved count with the listed count.
  5. Open the files you need and do not open unknown types.

For a single PDF this takes under a minute. For a folder of hundreds, wrap the same steps in a loop or move to a bulk tool and repeat the count check at the end.

How Do You Check the Extracted Files?

Compare the count from the list command with the number of files saved. Open a few and avoid opening unknown executables. Our article on checking a converted mailbox shows the same counting method for mail. For attachments inside mail files, see the article on MBOX attachments.

Common Questions

Can a PDF Contain Other Files?

Yes, because the PDF format can embed entire files as attachments that the page text does not show.

Does pdfdetach Work on Password Protected PDFs?

Yes, with the user password option or the owner password option. Use them only on files you are entitled to open.

Are Images on PDF Pages Attachments?

No. Images are part of the page. Attachments are separate files packed inside the PDF and the commands here extract only those.

Is It Safe to Extract Attachments From an Unknown PDF?

Extracting only saves the files. Risk starts when you open them so check every file type first and avoid executables.

How Do I List Attachments in a PDF on Mac?

Install Poppler with Homebrew, then enter pdfdetach with the list option and the PDF file name in Terminal.

How Do I Save Every Embedded File at Once?

Enter pdfdetach with the saveall option and the output option naming a folder, then the PDF file name.

Sources

Every version, option and date above is taken from these pages and not from memory.

  1. pdfdetach manual page, Poppler Debian Manpages
  2. poppler formula, on version, license and installed tools Homebrew
  3. Links and attachments in PDFs, Adobe Acrobat Adobe