set

Set document properties, viewer preferences, and page labels

Usage

pdftl <input> set <key=value>... output <file>

Details

The set operation allows you to modify document-level properties, viewer preferences, logical page labels, and open actions without altering page content.

You can provide one or more key=value pairs.

Document Metadata (Auto-syncs Info Dict & XMP Stream)

Updates standard metadata properties. pdftl automatically synchronizes these values across both the legacy /Info dictionary and the modern PDF 2.0 XMP stream.

  • title: The document’s title.

  • author: The name of the person who created the document.

  • subject: The subject of the document.

  • keywords: Comma-separated keywords associated with the document.

  • creator: The application that originally created the document.

  • producer: The tool used to convert the document to PDF.

  • creationdate: Document creation timestamp (ISO 8601 or PDF D:... date).

  • moddate: Document modification timestamp (ISO 8601 or PDF D:... date).

Supported Properties

  • lang: The language identifier of the document (e.g., en-US). Important for accessibility.

  • layout: The page layout to use when opened. (SinglePage, OneColumn, TwoColumnLeft, TwoColumnRight, TwoPageLeft, TwoPageRight)

  • mode: The document view mode when opened. (UseNone, UseOutlines, UseThumbs, FullScreen, UseOC, UseAttachments)

Viewer Preferences (Booleans)

These control how the PDF reader UI is presented:

  • hide_toolbar: true or false

  • hide_menubar: true or false

  • hide_windowui: true or false

  • fit_window: true or false

  • center_window: true or false

  • display_title: true or false (Displays the Document Title instead of filename)

Open Action (open_action)

Determines the page and zoom level the PDF viewer initially opens to. Syntax: PageNum[,ViewType,Arg1,Arg2...]

  • open_action=5 (Opens to page 5, leaving the zoom level up to the viewer)

  • open_action=2,XYZ,null,null,2.5 (Opens to page 2, zoomed in 2.5x)

  • open_action=5,XYZ (Opens to page 5, trailing nulls are automatically appended)

  • open_action=1,Fit (Opens to page 1, fitting it to the window)

  • open_action="" (Removes the open action entirely)

Page Labels (pagelabels)

Logical page labels determine how page numbers are displayed in the PDF viewer (e.g., i, ii, iii, 1, 2, 3, A-1).

Syntax: A comma-separated list of rules. Rule format: <StartPage>[ (Prefix) ][Style][StartNum]

  • StartPage: 1-indexed physical page number.

  • Prefix: Optional text prefix enclosed in parentheses.

  • Style: Optional numbering style: r (roman), R (ROMAN), a (letters), A (LETTERS), D (Arabic).

  • StartNum: Optional starting number (defaults to 1).

To completely remove custom page labels, use pagelabels="".

Examples

Set the document title/author, and tell the viewer to display the Title instead of the filename.

pdftl in.pdf set title="Q3 Report" author="Jane Doe" display_title=true output out.pdf

Set language to US English and force the PDF to open in a two-column view with bookmarks open.

pdftl in.pdf set lang=en-US layout=TwoColumnRight mode=UseOutlines output out.pdf

Force the PDF to automatically open to Page 5 at a 2.5x zoom level.

pdftl in.pdf set open_action=5,XYZ,null,null,2.5 output out.pdf

Set complex page labels: pages 1-4 as roman numerals, pages 5-7 as arabic starting at 1, and pages 8 onwards as arabic prefixed with ‘A-’ and starting at 8.

pdftl in.pdf set 'pagelabels=1r,5D,8(A-)D8' output out.pdf

Tags: metadata, properties, viewer

Source: pdftl.operations.set_props

Read online: https://pdftl.readthedocs.io/en/stable/operations/set.html

Type: Operation