clip
Clip page content to a rectangle
Usage
pdftl
<input>clip<specs>...[preview]output<file>[<option...>]
Details
Clip a page to a rectangle defined by offsets from the page edges, or
in other ways. The clip operation is identical to crop in terms of
specifying the rectangle, except that instead of cropping to the
rectangle (by changing the page boundaries), all page content is
enclosed in a clipping rectangle. The effect is then that any content
outside that rectangle is hidden, while the page boundaries are
unchanged.
To find out how to specify the rectangle, read the help for crop. Or
see below:
One format is page-range(left[,top[,right[,bottom]]]). Here, left,
top etc. are offsets from the current page boundaries; positive numbers
move inwards towards the center of the page. If you omit some of
these, the rest are filled in in the obvious way. Units can be pt
(points), in (inches), mm, cm or % (a percentage). If omitted,
the default unit is pt.
For example, 1-end(10pt,20pt,10pt,20pt) removes a
margin of 10 points from the left and right, and
20 points from the top and bottom.
Alternatively, specify 1-3(a4) to crop pages 1-3 to size a4.
Many paper size names are allowed, see data/paper_sizes.py.
For landscape add the suffix _l to the paper size, e.g., a4_l.
You can also clip to the visible content using fit:
1-end(fit)or simply ‘(fit)’ clips each page to its content.1-10(fit-group)clips pages 1-10 to the union of their content.1-10(fit-group=2-3)clips pages 1-10 to the union of the contents of pages 2-3.
Or use abs to specify an exact bounding box x0,y0,x1,y1 where
x0,y0 are the coordinates of the bottom left corner and x1,y1 the
coordinates of the upper right corner:
1-10(abs,100,150,400,500)clips pages 1-10 to the absolutely positioned box with corners at (100pt,150pt) and (400pt,500pt)
You can also include a comma-separated list of up to 4 dimensions to
expand the clip rectangle: (fit,1cm) or (fit-group, 10,0,20,50).
When using abs you can also give units or percentages, or just
numbers to default to pt. This uses the PDF page coordinate system,
so x-values increase to the right and y-values increase
upwards. Often, but not always, the origin (0,0) is at the bottom left
corner of the page (this depends on the page MediaBox, as shown by
dump_data, for example.)
If the preview keyword is given, a rectangle will be drawn instead
of clipping.
Examples
Clip to 1cm from the sides and 2cm from the top and bottom of all pages:
pdftl in.pdf clip '1-end(1cm,2cm)' output out.pdf
Clip every page to its visible content minus 10pt
pdftl in.pdf clip '1-end(fit,-10pt)' output clean.pdf
Preview effect of clipping the even-numbered pages between pages 2 and 8 to A5
pdftl in.pdf clip '2-8even(a5)' preview output out.pdf
Tags: in_place, geometry
Source: pdftl.operations.rebox
Read online: https://pdftl.readthedocs.io/en/stable/operations/clip.html
Type: Operation