write_linked_text.json

Die JSON-Datei des Beispiels „Links und Markierungen auf platziertem Text“. Links und Markierungen, an Text gehängt, den die Engine bereits platziert hat: ein Band hinter einer Zeile, eine Unterstreichung, eine umrahmte Zelle — jedes Rechteck aus dem genommen, was Layout und Tabelle danach melden, nichts davon von Hand gemessen.

JSON 289 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.

Diese Anfrage schreibt Zahlen aus, die die Bibliothek selbst ermittelt: Das blasse Band, die Linie, das Rechteck und die beiden anklickbaren Flächen sind hier als Zahlen genannt, wo die Bibliothek sie am gerade gesetzten Text misst. Beide Dateien malen dieselben Rechtecke, aber eine andere Schrift würde hier den Text verschieben und die Rechtecke zurücklassen.

Wofür dieses Beispiel da ist

Das Schwierige daran, einen Link auf ein Wort zu setzen, ist nicht der Link. Es ist zu wissen, wo dieses Wort gelandet ist, auf einer Seite, deren Text vom Layout statt von Ihnen in Zeilen umbrochen wurde. Raten Sie das Rechteck, und es bleibt richtig, bis jemand den Satz bearbeitet, die Schrift ändert oder die französische Fassung desselben Dokuments öffnet.

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