write_columns.json

Die JSON-Datei des Beispiels „In Spalten gegossener Text“. Eine lange Passage, in drei Spalten gegossen, jede mit den Zeilen gefüllt, die ihre Höhe zulässt, und den Rest an die nächste weitergebend.

JSON 399 Zeilen

Diese Datei ist eine Anfrage: Eine Anwendung sendet sie über das Netz an den Server, der das PDF erzeugt und zurücksendet. Sie erzeugt dieselbe Seite wie die Rust- und die Python-Fassung dieses Beispiels. Eine Anfrage nennt jede Datei, die sie verwendet, nie ihren Inhalt; der Aufruf trägt die Anfrage und die Dateien zusammen. Eine Schrift, die der Server bereits vorhält, etwa DejaVuSans, wird ohne Anhang genannt. Senden Sie die Anfrage an die Adresse, die die API-Seite angibt.

Die Bibliothek bricht die Passage einmal um, auf die Breite einer Spalte, und gibt jeder Spalte so viele der umbrochenen Zeilen, wie ihre Höhe zulässt; die Anfrage gibt die Passage ebenfalls einmal an, in einem Block, dessen Rechteck die erste Spalte ist und der in den anderen beiden weiterläuft. Die zweite Spalte endet dort, wo die Passage einen Spaltenumbruch enthält, den beide als Ende einer Spalte lesen. Die zweite Reihe ist ein Block, der auf dieselbe Weise in drei Spalten weiterläuft, wobei seine Zeilengrenze und die Zeilen, die er auf jeder Seite eines Schnitts behält, auf beiden Seiten angegeben sind. Die Zeile, die den linken Rand hinaufläuft, wird auf beiden Seiten aufrecht gesetzt und um ein Viertel gedreht: Die Bibliothek dreht sie beim Zeichnen, die Anfrage gibt am Block die Drehung an, auf die das hinausläuft. Die Beschriftungen unter den Spalten und die Zeile unter der zweiten Reihe sind Zahlen, die die Bibliothek von jeder gefüllten Spalte zurückliest — die genommenen Zeilen, warum die Spalte aufhörte, die enthaltenen Zeichen, ihre breiteste Zeile, wohin die Markierung kam —, und die Anfrage übernimmt sie so, wie sie gemessen wurden. Die beiden Dateien trennen sich bei den Linien um die Spalten: Die Bibliothek zeichnet jede nach den Wörtern ihrer Spalte als Rechteck, während die Anfrage zuerst die Wörter aller drei Spalten setzt und dann jede Linie um ihre vier Ecken führt und schließt.

Wofür dieses Beispiel da ist

Ein Newsletter, ein Faltblatt, die Bedingungen auf der Rückseite eines Bestellformulars: Sobald eine Seite mehr Wörter enthält, als eine Spalte bequem fassen kann, muss der Text vom Fuß der einen in den Kopf der nächsten laufen. Es ist ein gängiges Layout, und die Antwort ändert sich, sobald sich ein einziges Wort ändert.

Was dieses Beispiel zeigt

  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
      ]
    }
  ]
}