update_info

Update PDF metadata from dump_data instructions

Usage

pdftl <input> update_info <metadata> output <filename>

Details

Updates the document-level metadata and structural information of the input PDF by reading from a specified <metadata> file (or stdin, if <metadata> is ‘-‘). Alternatively, instructions can be specified in a structured JSON file, loaded by setting <metadata> to @instructions.json.

This operation consumes the plain-text format generated by the dump_data command. It correctly parses the XML-escaped strings created by that command.

This operation can read a full dump_data file in pdftk ‘stanza’ format, and will apply the following sections to the output PDF:

  • Info: Updates the Document Info dictionary (Title, Author, Subject, Keywords, CreationDate, ModDate, and custom keys).

  • Bookmarks: Deletes all existing bookmarks and replaces them with the Bookmark stanzas from the input file. Target page numbers are 1-indexed.

  • PageMedia: Applies page-level settings (Rotation, CropBox, TrimBox) as defined in PageMedia stanzas. Page numbers are 1-indexed.

  • PageLabels: Replaces the document’s page labelling scheme (e.g., “i, ii, iii”) using the PageLabel stanzas from the input file. Indices are 1-indexed.

  • PdfID: Updates the PdfID0 top-level field (the creation ID).

    • You may provide a 32-character hex string to set a PdfID0. For example, PdfID0: 1234abcd1234abcd1234abcd1234abcd

    • Fresh Bake: If you set PdfID0 to the string RESET (case-insensitive), the tool will remove the existing ID array. The underlying library will generate a brand new, matching ID pair (ID0=ID1) when saving.

    • PdfID1 (the modification ID) is not updatable; it is automatically managed by the underlying PDF library to ensure specification compliance.

      Providing a PdfID1 value in the input will result in a warning. It will otherwise be ignored.

For a complete description of the stanza-based input format this command expects, see the help for dump_data.

The format of the JSON for @instructions.json is hopefully intuitive. Key values for update_info should be xml-escaped. (For update_info_utf8 they should not be.) Here is an example for update_info:

{
  "Info": {
    "Title": "Annual Financial Report &amp; Accounts 2025",
    "Author": "Acme Corp",
    "Subject": "Financial Data",
    "Keywords": "finance, report, 2025",
    "CustomKey": "Internal-ID-99"
  },
  "PdfID0": "38a4d9afd883e2750c63c2473ffd21e1",
  "BookmarkList": [
    {
      "Title": "Executive Summary",
      "Level": 1,
      "PageNumber": 1
    },
    {
      "Title": "Financial Statements",
      "Level": 1,
      "PageNumber": 5,
      "Children": [
        {
          "Title": "Income Statement",
          "Level": 2,
          "PageNumber": 6
        },
        {
          "Title": "Balance Sheet",
          "Level": 2,
          "PageNumber": 8
        }
      ]
    }
  ],
  "PageMediaList": [
    {
      "PageNumber": 1,
      "Rotation": 90
    }
  ],
  "PageLabelList": [
    {
      "Index": 1,
      "Style": "LowercaseRoman",
      "Start": 1
    },
    {
      "Index": 5,
      "Style": "DecimalArabic",
      "Start": 1
    }
  ]
}

Where it makes sense, you can omit keys in order to perform a partial update.

Examples

Update metadata according to meta.txt

pdftl in.pdf update_info meta.txt output out.pdf

Tags: info, metadata

Source: pdftl.operations.update_info

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

Type: Operation