LinuxCommandLibrary

pdfattach

Embed files into a PDF document

TLDR

Add a new attachment to an existing PDF file

$ pdfattach [path/to/input.pdf] [path/to/file_to_attach] [path/to/output.pdf]
copy

Replace attachment with same name if it exists
$ pdfattach -replace [path/to/input.pdf] [path/to/file_to_attach] [path/to/output.pdf]
copy

Display help
$ pdfattach [[-h|--help]]
copy

Display version
$ pdfattach -v
copy

SYNOPSIS

pdfattach [options] <PDF-file> <file-to-attach> [file-to-attach...] <output-PDF-file>

PARAMETERS

-id <name>
    Specifies the file ID for the embedded file dictionary. This can be used by PDF viewers to refer to the attachment by a specific identifier.

-desc <text>
    Specifies a human-readable description for the embedded file, which may be displayed in PDF viewers.

-mimetype <mime-type>
    Defines the MIME type of the embedded file (e.g., "application/xml", "image/jpeg"). This helps viewers determine how to handle the file.

-creator <text>
    Sets the creator application or person for the embedded file, similar to the Creator metadata in PDF documents.

-creationdate <date-string>
    Specifies the creation date of the embedded file. The date string format is D:YYYYMMDDHHmmSS[+|-HH'mm'] (e.g., D:20231027153000+01'00').

-moddate <date-string>
    Specifies the modification date of the embedded file. The format is the same as for -creationdate.

-print
    Sets a flag indicating that the embedded file can be printed by the user.

-hidden
    Sets a flag indicating that the embedded file should be hidden from the user interface of a PDF viewer.

-nosave
    Sets a flag indicating that the embedded file should not be allowed to be saved by the user.

-nosaveas
    Sets a flag indicating that the embedded file should not be allowed to be saved with a new name by the user.

-nocopy
    Sets a flag indicating that the embedded file should not be allowed to be copied by the user.

-noprint
    Sets a flag indicating that the embedded file should not be allowed to be printed by the user.

-v
--version

    Displays the copyright and version information for pdfattach and exits.

-h
-help

    Displays usage information for the command and exits.

DESCRIPTION

pdfattach is a command-line utility from the Poppler project designed to embed one or more arbitrary files directly into a Portable Document Format (PDF) document. Instead of linking to external files, pdfattach physically stores the files within the PDF, ensuring that they travel with the document. This can be useful for including source code, images, spreadsheets, or any other data that supplements the PDF content.

The command takes an existing PDF file, the file(s) to be attached, and outputs a new PDF file with the embedded attachments. Users can access these attachments through a PDF viewer's attachment panel, where they can view, save, or open the embedded files. pdfattach provides various options to specify metadata like description, MIME type, creator, and dates for the embedded files, enhancing their discoverability and management within the PDF.

CAVEATS

  • pdfattach always creates a new PDF file. The original input PDF remains unchanged.
  • Embedding large files can significantly increase the size of the resulting PDF document, potentially making it slower to load or share.
  • The embedded files are not directly visible within the PDF's pages; they are typically accessible through a PDF viewer's attachment pane, often found in a sidebar or menu.

AUTHORS

The Poppler developers are credited with creating and maintaining pdfattach and the other Poppler utilities.

BUGS

Reports concerning pdfattach or other Poppler utilities can typically be filed via the Poppler project's bug tracking system, often linked from their official website or source code repository.

HISTORY

pdfattach is an integral part of the Poppler utilities, an open-source library for rendering PDF documents. Poppler originated as a fork of the Xpdf project in 2005, aiming to provide improved features and maintain an active development pace. It provides a comprehensive set of command-line tools for various PDF manipulation tasks, including attaching and detaching files. Its development continues as part of the broader FreeDesktop.org project, ensuring compatibility with PDF standards and offering robust functionality for Linux and other Unix-like systems.

SEE ALSO

Copied to clipboard