Repository navigation
v0.36.0
Turn a page by any angle
Doc.Turn and pdfops turn: the arbitrary-angle half that Rotate refuses.
Rotate writes a number on the page — /Rotate, a multiple of ninety — and
Turn rewrites the page onto a sheet of its own.
pdfops turn -by 30 tilted.pdf turned.pdf
pdfops turn -pages 2,5-7 -by -1.5 scan.pdf nudged.pdf⛔ The paper grows and nothing is cut off, which is the whole difference
from Deskew: a deskew is a correction of a fraction of a degree on a page
whose text sits well inside its margins, so it keeps the paper it was given.
The sheet is the turned page's bounding box — w·|cos θ| + h·|sin θ| across,
w·|sin θ| + h·|cos θ| down — and the page is centred on it, checked by
mapping all four corners for angles from −350° to 350°: each must land inside
the sheet, and each edge must be touched.
An angle that is a multiple of ninety goes through /Rotate and nothing else
happens: no transformation, no new content stream, a page whose text was
selectable stays selectable.
⛔ Positive is clockwise, as ISO 32000-1 Table 30 and Doc.Rotate already
mean it. The tool this is ported from, BentoPDF's rotate-custom, documents the
same thing and then does the opposite for any angle that is not a multiple of
ninety — its two arms turn opposite ways, and the seam is at exactly 90°. The
gate here is a render across that seam: a mark at the top of a square page must
come back at the right-hand edge after +90°, measured at 89°, 90° and 91°.
Closes the Rotate by Custom Degrees row of the BentoPDF gap table.
🤖 Generated with Claude Code