write_rich_text.json

Die JSON-Datei des Beispiels „Den Stil mitten im Absatz ändern“. Ein Absatz, dessen Stil sich darin ändert — Größe, Unterstreichung, Farbe —, dann eine hohl gelassene oder verstärkte Überschrift, eine durch die Buchstaben gezogene Linie, eine lange Webadresse, nach ihren Schrägstrichen umbrochen, und ein in seinem Kasten zentrierter Absatz.

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

Wofür dieses Beispiel da ist

Der meiste Text in einem echten Dokument hat nicht von Anfang bis Ende einen Stil. Ein Satz hat einen fetten Begriff, eine Summe ist unterstrichen, ein Fußnotenzeichen ist kleiner als die Wörter darum herum. Der übliche Behelf ist, den Satz in Stücke zu schneiden und jedes hinter das letzte zu setzen — was hält, bis der Text übersetzt wird und die Stücke nicht mehr dieselbe Breite ergeben.

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
{
  "items": [
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 784.0,
        "urx": 539.276,
        "ury": 800.8
      },
      "content": [
        "Rich text: styles, sizes, underlining, colour"
      ],
      "font": "DejaVuSans",
      "font_size": 14.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 720.4,
        "urx": 476.0,
        "ury": 760.0
      },
      "content": [
        "The amount due is ",
        {
          "text": "1 240.00 EUR",
          "underline": true
        },
        ", payable within thirty days. The balance carries interest at the statutory rate from the day it falls due, and no reminder has to be sent for it to do so."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "align": "justify"
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 660.8,
        "urx": 476.0,
        "ury": 694.4
      },
      "content": [
        "A line is as tall as ",
        {
          "text": "the largest",
          "font_size": 17.0
        },
        " of the styles standing on it, and no taller."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 621.6,
        "urx": 476.0,
        "ury": 634.8
      },
      "content": [
        "A run can carry its own ",
        {
          "text": "colour",
          "color": [0.0, 0.35, 0.7]
        },
        ", set apart from the black around it."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 569.2,
        "urx": 476.0,
        "ury": 595.6
      },
      "content": [
        "A word may change style in the middle: under",
        {
          "text": "lined",
          "underline": true
        },
        " is still one word, and is never broken at the join."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 533.6,
        "urx": 476.0,
        "ury": 543.2
      },
      "content": [
        "The small print sits in small type, ",
        "flush right",
        ", below the body of the text."
      ],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "align": "right"
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 466.8,
        "urx": 476.0,
        "ury": 507.6
      },
      "content": [
        "A heading set ",
        {
          "text": "hollow",
          "outline": {
            "width": 0.6,
            "color": [
              0.0,
              0.0,
              0.0
            ]
          }
        },
        ", or ",
        {
          "text": "thickened",
          "color": [
            0.0,
            0.35,
            0.7
          ],
          "outline": {
            "width": 0.8,
            "color": [
              0.0,
              0.2,
              0.45
            ],
            "filled": true
          }
        },
        " without a bolder font"
      ],
      "font": "DejaVuSans",
      "font_size": 17.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 427.4,
        "urx": 476.0,
        "ury": 453.8
      },
      "content": [
        "A rule can sit where it is told: ",
        {
          "text": "a heavy underline",
          "underline": {
            "position": -4.0,
            "thickness": 1.5
          }
        },
        " clear of the descenders, or ",
        {
          "text": "a hairline",
          "strikethrough": {
            "position": 3.0,
            "thickness": 0.4
          }
        },
        " through the letters."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 401.2,
        "urx": 476.0,
        "ury": 414.4
      },
      "content": [
        "A reference broken after its slashes, and cut where nothing else will do:"
      ],
      "font": "DejaVuSans",
      "font_size": 11.0
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 335.4,
        "urx": 206.0,
        "ury": 388.2
      },
      "content": [
        "hqf-pdf.com/examples/rich-text/overlong/ABCDEFGHJKLMNPQRSTUVWXYZ0123456789"
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "overlong": "break",
      "cut_mark": "-",
      "break_after": "/"
    },
    {
      "type": "rect",
      "rect": {
        "llx": 56.0,
        "lly": 249.4,
        "urx": 476.0,
        "ury": 309.4
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.7,
          0.7,
          0.7
        ]
      }
    },
    {
      "type": "text",
      "rect": {
        "llx": 76.0,
        "lly": 266.2,
        "urx": 456.0,
        "ury": 292.6
      },
      "content": [
        "This paragraph is centred, across and down, in the box drawn around it."
      ],
      "font": "DejaVuSans",
      "font_size": 11.0,
      "align": "center"
    },
    {
      "type": "text",
      "rect": {
        "llx": 56.0,
        "lly": 225.8,
        "urx": 476.0,
        "ury": 235.4
      },
      "content": [
        "2 lines, 26 pt tall together, the widest 341 pt wide."
      ],
      "font": "DejaVuSans",
      "font_size": 8.0
    }
  ]
}