<

Go Premium for a chance to win a PS4. Enter to Win

x

Xpdf - PDFdetach - Command Line Utility to Detach Attachments from PDF Files

Posted on
11,638 Points
338 Views
3 Endorsements
Last Modified:
Experience Level: Intermediate
5:14
Joe Winograd, EE MVE 2015&2016
50+ yrs in computer industry. Everything from programming to sales. OS kernel dev on mainframes. CIO. Document imaging. EE MVE 2015 & 2016.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any place where a command line call can be made.

Video Steps

1. Download the software.


You may have already downloaded and unzipped the Xpdf tools while watching the first video in the Xpdf series, but if you haven't, then visit the Xpdf website. Click the Download link and then click the pre-compiled Windows binary ZIP archive to download the utilities for Windows.

Step1

2. Locate the documentation folder for the Xpdf utilities.


Go to the folder where you unzipped the downloaded ZIP file and find the <doc> folder.

Step2

3. Read the documentation for the PDFdetach tool.


Go into the <doc> folder and find the plain text file called <pdfdetach.txt>.

Open it with any text editor, such as Notepad, and read it. This is the documentation for the PDFdetach tool.

Step3

4. Set up a test folder.


Create a test folder.

Copy <pdfdetach.exe> from the unzipped <bin32> folder into your test folder.

Copy a sample PDF file that has attachments into your test folder (in the video and the screenshots below, the file is called test.pdf, which is a PDF file created from my EE article, Windows 10 uses YOUR computer to help distribute itself, but with some attachments added to it).

Step4

5. Set up a command prompt for testing.


Open a command prompt window.

Navigate to your test folder.

Issue a DIR command in the command prompt to be sure that only two files are in it - the PDFdetach executable and the sample PDF file.

Step5

6. View and extract attachments in the test file using Adobe Acrobat or any PDF reader/viewer.


The exact technique depends on what PDF product you use, but, for example, in Adobe Acrobat and Adobe Reader, click the paper clip icon to open the Attachments pane, Select All of the attachments, then click the Save Attachment icon. The purpose of this step is simply to validate the existence of attachments in the test PDF file.

Step6

7. Issue DIR command to show that the files were extracted.


Run a DIR command to confirm that the files were extracted, but then delete them in preparation for using PDFdetach.

Step7

8. Run PDFdetach with the -list option.


Issue this command:

pdfdetach -list test.pdf

This will show a list of all the attachments in your test PDF file.

Step8

9. Run PDFdetach with the -saveall option.


Issue this command:

pdfdetach -saveall test.pdf

This will detach all the attachments in your test PDF file and save each one in a separate file. Issue a DIR command to show that PDFdetach was successful.

Step9
That's it! If you find this video to be helpful, please click the thumbs-up icon below. Thank you for watching!
What does it mean to be "Always On"?
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

3
Comment
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:NVIT
Hi Joe,

Thanks for this info.
I haven't looked at the docs yet but... does pdfdetach just extract a copy of the attachments? Does it have a "remove attachments from PDF" option?
0
 
LVL 56

Author Comment

by:Joe Winograd, EE MVE 2015&2016
Aloha NewVillage,
You're welcome. It just extracts — does not have a "remove attachments" feature. A way to achieve that is to extract first with PDFdetach and then print the file to a PDF print driver. I tested three print drivers (Bullzip, CutePDF, doPDF) and all of them created a new PDF without the attachments — normally, I'd complain about that, but in this case, it's just what the doctor ordered. :)  However, those three print drivers all put up a GUI. You'll need to look elsewhere if you want a command line version, such as PDFCreator (from pdfforge) or bioPDF (the non-free version of Bullzip), but I didn't test either. Mahalo, Joe
0
 
LVL 25

Expert Comment

by:NVIT
Hi Joe...

> A way to achieve that is to extract first with PDFdetach and then print the file to a PDF print driver.

That would work for me. Thanks!

Mahalo
0
 
LVL 56

Author Comment

by:Joe Winograd, EE MVE 2015&2016
A`ole pilikia!
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Join & Write a Comment

Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Suggested Courses
Next Video:

Keep in touch with Experts Exchange

Tech news and trends delivered to your inbox every month