modify_annots

Modify properties of existing annotations

Usage

pdftl <input> modify_annots <spec(K=V...)>... output <output>

Details

Modifies properties of existing annotations (e.g., links, highlights) on specified pages.

This operation allows for targeted, surgical changes to annotation dictionaries, such as changing a link’s border or a highlight’s color.

The syntax is selector(Key=Value, ...), where:

  • selector is a page range (e.g., 1-5, odd, see [[page_specs]]) and/or an annotation type (e.g., /Link, /Highlight).

  • Key=Value pairs define the PDF dictionary keys to set and their new values.

Value Syntax

  • PDF Names: /Name

  • PDF Strings: (My String)

  • PDF Arrays: [0 0 1]

  • PDF Booleans: true / false

  • Null (to delete a key): null

  • Numbers: 1.5, 10

  • Plain strings are treated as PDF Strings: Value is interpreted as (Value)

Examples

Remove the visible border from all links in the document.

pdftl in.pdf modify_annots "1-end/Link(Border=[0 0 0])" output out.pdf

Change the color of all highlights on odd pages to red.

pdftl in.pdf modify_annots "odd/Highlight(C=[1 0 0])" output out.pdf

Set the ‘Title’ (author) of all text notes to ‘New Author’.

pdftl in.pdf modify_annots "/Text(T='(New Author)')" output out.pdf

Delete the custom key ‘/MyKey’ from all annotations on pages 1-5.

pdftl in.pdf modify_annots "1-5(MyKey=null)" output out.pdf

Tags: in_place, annotations

Source: pdftl.operations.modify_annots

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

Type: Operation