einfacharchiv/unpack-pdf-attachments

Save PDF attachments to your disk where you can use them

v1.1.1 2019-02-24 00:54 UTC

This package is auto-updated.

Last update: 2024-03-24 12:30:53 UTC


README

Software License

Authors sometimes supplement their documents with additional electronic resources. For example, a document that displays large tables of data might also provide the reader with a matching Excel spreadsheet to work with. PDF's file attachment feature is an open-ended mechanism for packing any electronic file into a PDF like this. These attachments can be associated with the overall document or with individual pages. You can unpack PDF attachments to your disk using Acrobat, Reader, or this unpack-pdf-attachments package. After unpacking an attachment, you can view and manipulate it independently from the PDF document.

einfachArchiv is a German SaaS product to organize your documents in one place and meet all legal requirements. You'll find us on our website.

Requirements

Behind the scenes this package leverages PDFtk. You can verify if the binary is installed on your system by running this command:

which pdftk

If it is installed, it will return the path to the binary.

To install the binary you can use this command on Ubuntu or Debian:

sudo snap install pdftk

Installation

You can install this package via Composer. Run the following command:

composer require einfacharchiv/unpack-pdf-attachments

Usage

Unpacking attachments from a PDF is easy.

By default, this package unpacks all PDF attachments into the same directory.

(new Pdf())
    ->setPdf('document.pdf')
    ->unpack();

Or easier:

Pdf::unpackAttachments('document.pdf');

Sometimes you may want to use pdftk options. To do so you can set them up using the setOptions method.

(new Pdf())
    ->setPdf('document.pdf')
    ->setOptions(['output tmp'])
    ->unpack();

Or as the second parameter to the unpackAttachments static method:

Pdf::unpackAttachments('document.pdf', ['output tmp']);

If the pdftk command is located elsewhere, pass its binary path to the constructor:

(new Pdf('/snap/bin/pdftk'))
    ->setPdf('document.pdf')
    ->unpack();

Or as the third parameter to the unpackAttachments static method:

Pdf::unpackAttachments('document.pdf', [], '/snap/bin/pdftk');

Contributing

Contributions are welcome.

We accept contributions via Pull Requests on Github.

Find yourself stuck using the package? Found a bug? Do you have general questions or suggestions for improvement? Feel free to create an issue on GitHub, we'll try to address it as soon as possible.

If you've found a security issue, please email support@einfacharchiv.com instead of using the issue tracker.

Happy coding!

Credits

License

The MIT License (MIT). Please see License File for more information.