Liens et marques sur un texte déjà composé

Des liens et des repères accrochés à un texte que le moteur a déjà mis en place : un bandeau derrière une ligne, un soulignement, une cellule encadrée — chaque rectangle repris de ce que la mise en page et le tableau indiquent après coup, aucun mesuré à la main.

JSON write_linked_text.json 289 lignes

Celui-ci n'est pas un programme. C'est la requête envoyée au serveur de documents : la même page, demandée par le réseau, par une application qui n'écrit pas une ligne de code PDF.

Cette demande écrit en toutes lettres des nombres que la bibliothèque trouve toute seule : le bandeau pâle, le filet, le cadre et les deux zones cliquables sont nommés ici par leurs nombres, là où la bibliothèque les mesure sur le texte qu'elle vient de mettre en page. Les deux fichiers peignent les mêmes rectangles, mais changer de police déplacerait le texte ici et laisserait les rectangles en arrière.

  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
{
  "items": [
    {
      "type": "text",
      "rect": {
        "llx": 70.0,
        "lly": 590.0,
        "urx": 525.0,
        "ury": 790.0
      },
      "content": [
        "Boxes over what the engine placed"
      ],
      "font": "DejaVuSans",
      "font_size": 18.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 732.40576171875,
        "urx": 513.16357421875,
        "ury": 745.21044921875
      },
      "fill": [
        1.0,
        0.93,
        0.6
      ]
    },
    {
      "type": "text",
      "rect": {
        "llx": 70.0,
        "lly": 550.0,
        "urx": 525.0,
        "ury": 750.0
      },
      "content": [
        "The engine knows where every line and every cell lands, down to the point. This paragraph was flowed into a column, and the pale band was painted behind its first line from the box the engine reported, not measured by hand. The same boxes make a line clickable and draw a rule exactly under it."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "leading": 15.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 70.0,
        "lly": 455.0,
        "urx": 525.0,
        "ury": 655.0
      },
      "content": [
        "Read the terms at https://example.org/hqf-pdf/terms"
      ],
      "font": "DejaVuSans",
      "font_size": 12.0,
      "color": [
        0.0,
        0.2,
        0.8
      ]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 70.0,
        "lly": 637.769921875,
        "urx": 387.53125,
        "ury": 638.369921875
      },
      "fill": [
        0.0,
        0.2,
        0.8
      ]
    },
    {
      "type": "table",
      "columns": {
        "widths": [
          {
            "points": 140.0
          },
          {
            "points": 315.0
          }
        ],
        "total": 455.0
      },
      "first": {
        "llx": 70.0,
        "lly": 410.0,
        "urx": 525.0,
        "ury": 610.0
      },
      "next": {
        "llx": 70.0,
        "lly": 410.0,
        "urx": 525.0,
        "ury": 610.0
      },
      "header": 1,
      "rules": [
        {
          "rule": "frame",
          "stroke": {
            "width": 0.8
          }
        },
        {
          "rule": "horizontal_other",
          "stroke": {
            "width": 0.25,
            "color": [
              0.75,
              0.75,
              0.75
            ]
          }
        }
      ],
      "rows": [
        {
          "cells": [
            {
              "content": [
                "Field"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            },
            {
              "content": [
                "Value"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            }
          ]
        },
        {
          "cells": [
            {
              "content": [
                "Product"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            },
            {
              "content": [
                "hqf-pdf"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            }
          ]
        },
        {
          "cells": [
            {
              "content": [
                "Licence"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            },
            {
              "content": [
                "See the licence online"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            }
          ]
        },
        {
          "cells": [
            {
              "content": [
                "Version"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            },
            {
              "content": [
                "1.0"
              ],
              "font": "DejaVuSans",
              "font_size": 10.0,
              "padding": {
                "left": 6.0,
                "right": 6.0,
                "top": 4.0,
                "bottom": 4.0
              }
            }
          ]
        }
      ]
    },
    {
      "type": "rect",
      "rect": {
        "llx": 210.0,
        "lly": 550.0,
        "urx": 525.0,
        "ury": 570.0
      },
      "stroke": {
        "width": 1.0,
        "color": [
          0.8,
          0.0,
          0.0
        ]
      }
    },
    {
      "type": "link",
      "rect": {
        "llx": 70.0,
        "lly": 637.769921875,
        "urx": 387.53125,
        "ury": 651.738671875
      },
      "to": {
        "uri": "https://example.org/hqf-pdf/terms"
      }
    },
    {
      "type": "link",
      "rect": {
        "llx": 210.0,
        "lly": 550.0,
        "urx": 525.0,
        "ury": 570.0
      },
      "to": {
        "uri": "https://example.org/hqf-pdf/licence"
      }
    }
  ]
}