Pages And Positioning
Recipe uses a top-left coordinate origin. Create a named page size or provide
width and height directly, then call endPage() before switching pages.
pdfDoc
.createPage("A4", 90, { left: 54, right: 54, top: 72, bottom: 72 })
.rectangle(0, 0, 100, 100, { stroke: "#cccccc" })
.endPage();
The second argument for a named page is rotation. A 90- or 270-degree rotation
swaps its width and height. rotate(degrees) sets the PDF /Rotate value on
the current page, including a page created with an explicit width and height.
When both are used on a named page, rotate() is the last rotation setting and
wins; the named size's swapped dimensions remain unchanged. rotate() throws on a page opened with editPage(), whose
/Rotate the page modifier keeps. pageInfo(pageNumber)
returns page geometry for a specific one-based page. Inside a createPage() or
editPage() block, getCurrentPageInfo() returns that same geometry for the
active page, including after endPage(). Despite its similar name,
getPageInfo() returns document Info metadata, not page geometry. Rectangles
use a top-left anchor; circles and ellipses use center coordinates.
rotationOrigin selects the point used for transformations.
A positive rotation option turns a shape, text, or image clockwise on the
page, around rotationOrigin. Text without rotationOrigin turns around the
x and y given to text(), before align moves it, so every line of a text
box turns as one block.
rotateContent(degrees, x, y) rotates subsequent drawing around a point in
Recipe's top-left coordinates. Unlike the rotation option, a positive angle
turns counter-clockwise on the page.