Text in paragraphs, with indents and tab stops
Lay several paragraphs in a frame, with a first-line indent, space between them, bulleted lists and neat columns of figures.
Summary
A letter, a contract, a set of terms: text that runs on, and settles by itself as it goes. The lines can hold to the left edge, sit in the middle, or stretch out to both edges at once. A bullet stands alone in the margin while its text lines up neatly beneath it. And a row of little dots can run from a heading across to a price, the way a table of contents does.
Technically
Asked for with
"type": "flow"
A flow item takes its text as a single string: a newline ends a paragraph, a tabulation advances to the next tab stop, and the result goes into the page content stream as positioned text. The whole block is set in one font at one size, which leaves the room for paragraph settings, all measured in points: left, right and first-line indents, space before and after, the position of the first baseline and the room kept below the last one, the alignment of a paragraph's last line, and a leader character. Tab stops are set in relative steps, typewriter style, or from an explicit ruler, each stop aligned left, centre, right or on a decimal character. The hanging list is a shorthand that sets the left indent, the first-line indent and the body stop in one go.
Request schema
Required keys: rect; content, a single string; font; font_size. Optional: align (default left, then right, center, justify); last_align, the alignment of each paragraph's last line (absent: as the rest, except under justify, where it settles flush left); overlong (overflow by default, break); leading (default 1.2 × font_size); break_after; color (default black); outline, an object of width, a required number of points, color (default black) and filled (default false), the letters stroked round their edges and hollow unless filled draws them solid as well; shadow (dx, dy, color, all three required); left_indent, right_indent, first_line_indent, numbers of points, the last one accepting a negative value that hangs the first line out to the left of the others; space_before, space_after; first_baseline, one of "leading" (default), "ascender", "cap_height" or {"points": n}; last_baseline, one of "none" (default), "descender" or {"points": n}, the room the block keeps below its last baseline, which is what a leading filling a box is measured against, so that two blocks of unequal length end on one line of ink rather than on one line of baselines; leader, one character; tabs, an object of method (relative by default, typewriter, ruler), size ({"fraction": n} or {"points": n}, default 7.5 % of the line), ruler (array of numbers, default empty), alignments (array of left, center, right, decimal, default empty) and align_char (default .); hanging_list, an object of marker and body, both numbers, both required; fill_leading, an object with one required limit, a number of points, the leading the lines take so that the last of them ends on the floor of the rectangle — the lines are moved apart and nothing else, the room kept around a paragraph, the drop under the last baseline and the height of the text itself standing where they are, and a limit below the leading the block would take leaves that leading where it is; fit_size, an object with one required floor, a number of points, the size the block works out for itself so that the whole of its text holds the rectangle — the sizes tried step down from the one the block asked for, each broken to the box and weighed against it, the largest that holds the text being the one it is set at, and a box no size can fill sets the text at the floor and lets it run past; absent, the block is set at the size it asked for, whatever runs past; pages (default empty); id; relative_to; transform; rotate; layer. Cross refusals: hanging_list with left_indent, first_line_indent, tabs.method or tabs.ruler; fill_leading with leading; transform with rotate.
A whole request that creates a PDF
{
"standard_fonts": [{"name": "serif", "face": "times_roman"}],
"items": [
{
"type": "flow",
"rect": {"llx": 72, "lly": 640, "urx": 523, "ury": 780},
"content": "First paragraph, set in one font.\nSecond paragraph, indented.",
"font": "serif",
"font_size": 11,
"first_line_indent": 14,
"space_after": 6,
"first_baseline": "cap_height",
"last_baseline": "descender",
"overlong": "break",
"tabs": {
"method": "relative",
"size": { "points": 36 },
"ruler": [72, 180],
"alignments": ["left", "decimal"]
}
}
]
}
Text
A block of text placed on the page A stamp laid across the page A line of words set along a path Blocks laid one under the other, page after page
Where to go next
Every JSON key of a request, in one page The other twenty-two things you can draw