write_columns.json

The JSON file of the “Text Poured into Columns” example. One long passage poured into three columns, each fitting the lines its height allows and handing the rest to the next.

JSON 399 lines

This file is a request: an application sends it over the network to the server, which creates the PDF and sends it back. It creates the same page as the Rust and Python versions of this example. A request names every file it uses, never its content; the call carries the request and the files together. A font the server already holds, such as DejaVuSans, is named with nothing attached. Send the request to the address the API page gives.

The library breaks the passage once, to the width of one column, and hands each column as many of the broken lines as its height allows; the request states the passage once too, in one block whose rectangle is the first column and which goes on in the other two. The second column ends where the passage holds a column break, which both read as the end of a column. The second row is one block going on in three columns the same way, its limit of lines and the lines it keeps either side of a cut stated on both sides. The line up the left margin is set upright and turned a quarter on both sides: the library turns it as it draws it, the request states on the block the turn that comes to. The captions under the columns and the line under the second row are figures the library reads back off each column it has filled — the lines taken, why the column stopped, the characters it holds, its widest line, where the marker went — and the request copies them as they were measured. The two files part in the rules round the columns: the library draws each one after its column's words, as a rectangle, where the request sets the words of all three columns first and then walks each rule round its four corners and closes it.

What This Example Is For

A newsletter, a leaflet, the terms on the back of an order form: as soon as a page holds more words than one column can carry comfortably, the text has to run from the foot of one into the head of the next. It is a common layout, and the answer changes the moment a single word does.

What This Example Shows

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
{
  "items": [
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 590.0,
        "urx": 215.0,
        "ury": 720.0
      },
      "content": "A flow too long for one column is set column by column. Each column takes as many of the broken lines as its height allows, draws them, and hands the rest to the column beside it, which takes up exactly where the last one stopped. The words are broken once, to the width one column has, so every column is set to the same measure.\fA column break written in the text ends the second column early, and this paragraph opens the third. This is what sets a newspaper's text, a report's two columns, or the narrow measure a wide page reads best in.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "align": "justify",
      "leading": 14.0,
      "continued_in": [
        {
          "llx": 240.0,
          "lly": 590.0,
          "urx": 385.0,
          "ury": 720.0
        },
        {
          "llx": 410.0,
          "lly": 590.0,
          "urx": 555.0,
          "ury": 720.0
        }
      ],
      "box_break": "\f",
      "orphans": 2,
      "widows": 2
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 590.0,
        "urx": 215.0,
        "ury": 720.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "rect",
      "rect": {
        "llx": 240.0,
        "lly": 590.0,
        "urx": 385.0,
        "ury": 720.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "rect",
      "rect": {
        "llx": 410.0,
        "lly": 590.0,
        "urx": 555.0,
        "ury": 720.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 370.0,
        "urx": 215.0,
        "ury": 500.0
      },
      "content": "This flow lets a column take seven lines at most, and keeps at least three lines of a paragraph on either side of a cut. A column may therefore stop short of its foot: at its limit of lines, or where a cut would strand fewer than three lines of a paragraph, which then waits for the next column whole. The caption under each column says which it was.\nA \u00a7marker planted in the text draws nothing and takes no room; it says which column and which line the word after it went into, as the line under the columns reports.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "align": "justify",
      "leading": 14.0,
      "continued_in": [
        {
          "llx": 240.0,
          "lly": 370.0,
          "urx": 385.0,
          "ury": 500.0
        },
        {
          "llx": 410.0,
          "lly": 370.0,
          "urx": 555.0,
          "ury": 500.0
        }
      ],
      "max_lines": 7,
      "orphans": 3,
      "widows": 3,
      "marker": "\u00a7"
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 370.0,
        "urx": 215.0,
        "ury": 500.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "rect",
      "rect": {
        "llx": 240.0,
        "lly": 370.0,
        "urx": 385.0,
        "ury": 500.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "rect",
      "rect": {
        "llx": 410.0,
        "lly": 370.0,
        "urx": 555.0,
        "ury": 500.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 564.0,
        "urx": 665.276,
        "ury": 578.0
      },
      "content": "9 lines: the column is full.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 554.0,
        "urx": 665.276,
        "ury": 568.0
      },
      "content": "240 characters, widest line 142 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 240.0,
        "lly": 564.0,
        "urx": 835.276,
        "ury": 578.0
      },
      "content": "4 lines: a column break.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 240.0,
        "lly": 554.0,
        "urx": 835.276,
        "ury": 568.0
      },
      "content": "91 characters, widest line 131 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 410.0,
        "lly": 564.0,
        "urx": 1005.276,
        "ury": 578.0
      },
      "content": "9 lines: the text ends here.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 410.0,
        "lly": 554.0,
        "urx": 1005.276,
        "ury": 568.0
      },
      "content": "211 characters, widest line 140 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 344.0,
        "urx": 665.276,
        "ury": 358.0
      },
      "content": "7 lines: its limit of lines.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 334.0,
        "urx": 665.276,
        "ury": 348.0
      },
      "content": "193 characters, widest line 140 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 240.0,
        "lly": 344.0,
        "urx": 835.276,
        "ury": 358.0
      },
      "content": "6 lines: lines held back.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 240.0,
        "lly": 334.0,
        "urx": 835.276,
        "ury": 348.0
      },
      "content": "158 characters, widest line 143 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 240.0,
        "lly": 324.0,
        "urx": 835.276,
        "ury": 338.0
      },
      "content": "It had room for 7 lines.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 410.0,
        "lly": 344.0,
        "urx": 1005.276,
        "ury": 358.0
      },
      "content": "6 lines: the text ends here.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 410.0,
        "lly": 334.0,
        "urx": 1005.276,
        "ury": 348.0
      },
      "content": "166 characters, widest line 142 pt",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 70.0,
        "lly": 304.0,
        "urx": 665.276,
        "ury": 318.0
      },
      "content": "The marker: column 3, line 1.",
      "font": "DejaVuSans",
      "font_size": 7.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 44.0,
        "lly": 560.0,
        "urx": 174.0,
        "ury": 590.0
      },
      "content": "Poured into three columns",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "transform": [
        0.0,
        1.0,
        -1.0,
        0.0,
        634.0,
        546.0
      ]
    }
  ]
}