style_text

Change appearance of text

Usage

pdftl <input> style_text [<pages>...] [key=val...] output <output>

Details

The style_text operation converts all filled text (Tr 0) into filled and stroked text (Tr 2) and applies a user-defined stroke width. Page ranges can be specified using <pages>. The default page range is all pages.

Key=val options:

  • stroke=<float|percent> The width of the text outline. May be an absolute value (e.g. 0.5) or a percentage of the current font size (e.g. 2%). Defaults to 0.5 if stroke_color is set, otherwise text outlines are not altered.

  • color=<r g b> Set both fill and stroke colour (floats 0.0–1.0 separated by spaces).

  • fill_color=<r g b> Set fill colour only.

  • stroke_color=<r g b> Set stroke colour only.

Input format

Arguments may be given as a parenthesized spec block:

[page-range](key=val, ...)

or as the equivalent shorthand (separate arguments, no parentheses):

[page-range] key=val ...

Multiple spec blocks may be used to apply different styles to different page ranges:

in.pdf style_text '1-3(stroke=0.5)' '4-end(stroke=2%)' output out.pdf

Examples

Add a 0.5pt text stroke to pages 1-3

pdftl in.pdf style_text 1-3 stroke=0.5 output out.pdf

Add a 2% font-size text stroke and change all text to black

pdftl in.pdf style_text stroke=2% 'color=0 0 0' output out.pdf

Add a red 0.2pt text stroke without changing fill colour

pdftl in.pdf style_text stroke=0.2 'stroke_color=1 0 0' output out.pdf

Different stroke styles on different page ranges

pdftl in.pdf style_text '1-3(stroke=0.5,stroke_color=0.2 0.4 0)' '4-end(stroke=2%)' output out.pdf

Tags: in_place, content_stream, custom

Source: pdftl.operations.style_text

Read online: https://pdftl.readthedocs.io/en/latest/operations/style_text.html

Type: Operation