write_articles.json

Le fichier JSON de l'exemple « Un récit qui se poursuit plus loin ». Deux articles sur deux pages : chacun commence dans une colonne de la première page et se poursuit dans une colonne de la seconde, et les deux échangent de côté en chemin. Le fichier dit quelle colonne suit laquelle, si bien que le logiciel de lecture poursuit l'article en cours.

JSON 288 lignes

Ce fichier est une requête : une application l'envoie par le réseau au serveur, qui crée le PDF et le renvoie. Il donne la même page que les versions Rust et Python de cet exemple. Une requête nomme chaque fichier qu'elle emploie, jamais le contenu de ces fichiers ; l'appel porte la requête et les fichiers ensemble. Une police que le serveur détient déjà, comme DejaVuSans, se nomme sans rien y joindre. Envoyez la requête à l'adresse que donne la page de l'API.

La bibliothèque découpe chaque récit en lignes une seule fois, à la largeur d'une colonne, puis donne au premier morceau de page autant de ces lignes qu'il a de place pour en tenir, et le reste au second. Une demande n'a pas de paquet de mots qui passe du bas d'un morceau au haut du suivant : chaque récit voyage donc en deux paquets, chacun contenant déjà les mots revenus à son morceau. Les lignes tombent aux mêmes endroits, parce qu'une ligne se coupe sur la place qu'elle a devant elle, et le paquet qui s'arrête au milieu de son récit le dit, pour que sa dernière ligne soit étalée comme celles du dessus. L'ordre de lecture, lui, se demande de la même façon des deux côtés : deux récits, chacun nommant les deux morceaux par lesquels on le lit.

À quoi sert cet exemple

Un journal met trois récits en première page et n'en finit aucun. Sur le papier, l'œil s'en sort : on lit jusqu'au bas d'une colonne, on tourne la feuille, et on cherche le titre à nouveau. Sur un écran, cette recherche est pire, parce que la colonne située sous celle qu'on lisait raconte autre chose et lui ressemble exactement.

Ce que montre cet exemple

  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
{
  "items": [
    {
      "type": "text",
      "rect": {
        "llx": 70.0,
        "lly": 780.0,
        "urx": 525.0,
        "ury": 806.4
      },
      "content": [
        "The Thursday Sheet"
      ],
      "font": "DejaVuSans",
      "font_size": 22.0,
      "pages": [1]
    },
    {
      "type": "text",
      "rect": {
        "llx": 70.0,
        "lly": 762.0,
        "urx": 525.0,
        "ury": 772.8
      },
      "content": [
        "Two stories, four columns, and a reading order of their own."
      ],
      "font": "DejaVuSans",
      "font_size": 9.0,
      "pages": [1]
    },
    {
      "type": "line",
      "from": {
        "x": 70.0,
        "y": 752.0
      },
      "to": {
        "x": 525.0,
        "y": 752.0
      },
      "stroke": {
        "width": 1.0
      },
      "pages": [1]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 510.0,
        "urx": 285.0,
        "ury": 700.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.75,
          0.75,
          0.75
        ]
      },
      "pages": [1]
    },
    {
      "type": "text",
      "rect": {
        "llx": 76.0,
        "lly": 684.0,
        "urx": 560.0,
        "ury": 698.4
      },
      "content": [
        "The bridge reopens"
      ],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "pages": [1]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 76.0,
        "lly": 510.0,
        "urx": 279.0,
        "ury": 674.0
      },
      "content": "The bridge reopened on Tuesday, eleven months after the river took the middle of it. The county surveyor walked the deck at dawn and declared it sound, which is the only ceremony anyone asked for. Traffic crossed within the hour. What took the eleven months was not the deck but the two piers under it, each rebuilt from the bed up while the water ran round them. The contractor counted nineteen days lost to the weather and none at all to the design, which is a rarer thing than it sounds. The old approach road stays shut until the spring, so",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "align": "justify",
      "leading": 12.5,
      "last_align": "justify",
      "pages": [1]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 310.0,
        "lly": 510.0,
        "urx": 525.0,
        "ury": 700.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.75,
          0.75,
          0.75
        ]
      },
      "pages": [1]
    },
    {
      "type": "text",
      "rect": {
        "llx": 316.0,
        "lly": 684.0,
        "urx": 560.0,
        "ury": 698.4
      },
      "content": [
        "The harvest, county by county"
      ],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "pages": [1]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 316.0,
        "lly": 510.0,
        "urx": 519.0,
        "ury": 674.0
      },
      "content": "The wheat came in ten days early and heavier than anyone had allowed for, and the barns of three parishes were full before the second week of August. The dry June is what did it, say the growers, and the wet April before that. Not every field agrees: the high ground east of the ridge lost a third of what it stood to a wind that came through on a single afternoon. The merchants have held their price so far, which nobody expects to last past the sales, and the millers are already asking what the winter sowing will look like on ground this hard.",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "align": "justify",
      "leading": 12.5,
      "last_align": "justify",
      "pages": [1]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 310.0,
        "lly": 570.0,
        "urx": 525.0,
        "ury": 760.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.75,
          0.75,
          0.75
        ]
      },
      "pages": [2]
    },
    {
      "type": "text",
      "rect": {
        "llx": 316.0,
        "lly": 744.0,
        "urx": 560.0,
        "ury": 758.4
      },
      "content": [
        "The bridge reopens (continued)"
      ],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "pages": [2]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 316.0,
        "lly": 570.0,
        "urx": 519.0,
        "ury": 734.0
      },
      "content": "the lorries still go the long way round by the mill. The parish council has asked for a footway on the upstream side and been told it will wait its turn. Meanwhile the bus takes four minutes off its run and the school on the far bank has moved its bell back to where it stood before the flood. Nobody has yet said what becomes of the temporary crossing downstream, which cost more to keep open than to build and which the anglers would like left where it is.",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "align": "justify",
      "leading": 12.5,
      "pages": [2]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 570.0,
        "urx": 285.0,
        "ury": 760.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.75,
          0.75,
          0.75
        ]
      },
      "pages": [2]
    },
    {
      "type": "text",
      "rect": {
        "llx": 76.0,
        "lly": 744.0,
        "urx": 560.0,
        "ury": 758.4
      },
      "content": [
        "The harvest, county by county (continued)"
      ],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "pages": [2]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 76.0,
        "lly": 570.0,
        "urx": 279.0,
        "ury": 734.0
      },
      "content": "The straw is the other half of the story: there is a great deal of it, it is dry, and the men who bale it have been working the fields two counties away as well as their own. Two of the larger farms have put their second cut off a fortnight in the hope of rain. The weighbridge at the co-operative has been open since six every morning and the queue at seven is longer than it was last year at nine.",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "align": "justify",
      "leading": 12.5,
      "pages": [2]
    }
  ],
  "articles": [
    {
      "title": "The bridge reopens",
      "author": "Claire Vasseur",
      "patches": [
        {
          "page": 1,
          "llx": 70.0,
          "lly": 510.0,
          "urx": 285.0,
          "ury": 700.0
        },
        {
          "page": 2,
          "llx": 310.0,
          "lly": 570.0,
          "urx": 525.0,
          "ury": 760.0
        }
      ]
    },
    {
      "title": "The harvest, county by county",
      "author": "Martin Aubert",
      "patches": [
        {
          "page": 1,
          "llx": 310.0,
          "lly": 510.0,
          "urx": 525.0,
          "ury": 700.0
        },
        {
          "page": 2,
          "llx": 70.0,
          "lly": 570.0,
          "urx": 285.0,
          "ury": 760.0
        }
      ]
    }
  ],
  "metadata": {
    "title": "The Thursday Sheet"
  }
}