write_filled_frame.json

Le fichier JSON de l'exemple « Deux commandes, un cadre, un même bas de page ». Une commande de quatre lignes et une de sept, dans des cadres de même hauteur, se terminant toutes deux sur le même bord bas. En dessous, deux notes de longueur inégale dont les lignes sont écartées jusqu'à ce que chacune atteigne le pied de son cadre.

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

À quoi sert cet exemple

Un bloc de papier à en-tête imprimé a déjà le cadre sur le papier : un cadre pour les lignes, un filet en dessous, le total sous le filet. Ce qui entre dans le cadre a une longueur différente à chaque fois. Une commande de quatre lignes laisse une largeur de main de blanc au-dessus du filet et une commande d'une douzaine le remplit, si bien que deux feuilles du même bloc ressemblent à deux documents différents — et la réponse habituelle, combler la courte avec des lignes vides, laisse une ligne où quelqu'un peut écrire après coup.

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
{
  "items": [
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 768.4, "urx": 523.0, "ury": 790.0 },
      "content": "Two orders, one frame, one bottom edge",
      "font": "DejaVuSans",
      "font_size": 18.0
    },
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 696.4, "urx": 523.0, "ury": 756.4 },
      "content": "The two frames below are the same height, and the orders in them are not the same length. Each frame is filled: whatever room the lines leave is shared out among them in equal parts, once they have all been measured, so the last line of an order of four ends where the last line of an order of seven ends. The headings and the total stay where the stationery puts them, and only the billed lines grow.",
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 660.0, "urx": 523.0, "ury": 674.4 },
      "content": "Four lines and seven, ending together",
      "font": "DejaVuSans",
      "font_size": 12.0
    },
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 637.8, "urx": 288.0, "ury": 648.0 },
      "content": "Order 4412",
      "font": "DejaVuSans",
      "font_size": 8.5,
      "color": [0.42, 0.42, 0.42]
    },
    {
      "type": "flow",
      "rect": { "llx": 307.0, "lly": 637.8, "urx": 523.0, "ury": 648.0 },
      "content": "Order 4413",
      "font": "DejaVuSans",
      "font_size": 8.5,
      "color": [0.42, 0.42, 0.42]
    },
    {
      "type": "table",
      "columns": { "widths": [{ "fraction": 1.0 }, { "points": 62.0 }], "total": 216.0 },
      "first": { "llx": 72.0, "lly": 431.8, "urx": 288.0, "ury": 631.8 },
      "next": { "llx": 72.0, "lly": 431.8, "urx": 288.0, "ury": 631.8 },
      "header": 1,
      "footer": 1,
      "fill_frame": true,
      "rules": [
        { "rule": "frame", "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } },
        { "rule": "horizontal_other", "stroke": { "width": 0.25, "color": [0.78, 0.78, 0.78] } },
        { "rule": { "horizontal": 1 }, "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } },
        { "rule": { "horizontal_from_end": 1 }, "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } }
      ],
      "rows": [
        {
          "cells": [
            { "content": ["Item"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 }, "fill": [0.9, 0.9, 0.9] },
            { "content": ["Amount"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 }, "fill": [0.9, 0.9, 0.9] }
          ],
          "min_height": 18.0
        },
        {
          "cells": [
            { "content": ["Site survey"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["420.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Cable, 40 m"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["96.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Wall boxes"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["158.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Fitting, one day"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["240.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Total"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["914.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 18.0
        }
      ]
    },
    {
      "type": "table",
      "columns": { "widths": [{ "fraction": 1.0 }, { "points": 62.0 }], "total": 216.0 },
      "first": { "llx": 307.0, "lly": 431.8, "urx": 523.0, "ury": 631.8 },
      "next": { "llx": 307.0, "lly": 431.8, "urx": 523.0, "ury": 631.8 },
      "header": 1,
      "footer": 1,
      "fill_frame": true,
      "rules": [
        { "rule": "frame", "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } },
        { "rule": "horizontal_other", "stroke": { "width": 0.25, "color": [0.78, 0.78, 0.78] } },
        { "rule": { "horizontal": 1 }, "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } },
        { "rule": { "horizontal_from_end": 1 }, "stroke": { "width": 0.7, "color": [0.0, 0.0, 0.0] } }
      ],
      "rows": [
        {
          "cells": [
            { "content": ["Item"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 }, "fill": [0.9, 0.9, 0.9] },
            { "content": ["Amount"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 }, "fill": [0.9, 0.9, 0.9] }
          ],
          "min_height": 18.0
        },
        {
          "cells": [
            { "content": ["Site survey"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["180.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Cable, 15 m"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["64.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Wall boxes"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["112.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Junction box"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["45.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Fitting, two days"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["320.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Cover plates"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["88.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Test and report"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["150.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 16.0
        },
        {
          "cells": [
            { "content": ["Total"], "font": "DejaVuSans", "font_size": 8.5, "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } },
            { "content": ["959.00"], "font": "DejaVuSans", "font_size": 8.5, "align": "right", "valign": "middle", "padding": { "left": 5.0, "right": 5.0, "top": 4.0, "bottom": 4.0 } }
          ],
          "min_height": 18.0
        }
      ]
    },
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 391.4, "urx": 523.0, "ury": 405.8 },
      "content": "Two notes of unequal length, ending together",
      "font": "DejaVuSans",
      "font_size": 12.0
    },
    {
      "type": "rect",
      "rect": { "llx": 72.0, "lly": 267.4, "urx": 288.0, "ury": 377.4 },
      "stroke": { "width": 0.4, "color": [0.72, 0.72, 0.72] }
    },
    {
      "type": "flow",
      "rect": { "llx": 78.0, "lly": 267.4, "urx": 282.0, "ury": 377.4 },
      "content": "Goods stay ours until they are paid for in full. Anything found broken is to be written on the driver's sheet before it is signed, and told to us the same week. A pallet left with a neighbour is left at the buyer's own risk.",
      "font": "DejaVuSans",
      "font_size": 8.5,
      "first_baseline": "ascender",
      "last_baseline": "descender",
      "fill_leading": { "limit": 26.0 }
    },
    {
      "type": "rect",
      "rect": { "llx": 307.0, "lly": 267.4, "urx": 523.0, "ury": 377.4 },
      "stroke": { "width": 0.4, "color": [0.72, 0.72, 0.72] }
    },
    {
      "type": "flow",
      "rect": { "llx": 313.0, "lly": 267.4, "urx": 517.0, "ury": 377.4 },
      "content": "Payment is due thirty days from the date of issue, by transfer to the account named at the foot of the invoice. A line queried in writing suspends nothing but the line itself, and the rest of the invoice falls due on the day it always did. Work already booked is held for a fortnight after that day and released afterwards.",
      "font": "DejaVuSans",
      "font_size": 8.5,
      "first_baseline": "ascender",
      "last_baseline": "descender",
      "fill_leading": { "limit": 26.0 }
    },
    {
      "type": "flow",
      "rect": { "llx": 72.0, "lly": 200.2, "urx": 523.0, "ury": 243.4 },
      "content": "The lines of a note are moved apart, and nothing else: the room kept around a paragraph, the drop under the last line and the height of the words themselves stand where they are. A limit is given along with the box, so two lines in a tall box keep the spacing they came with rather than being stretched into a ladder.",
      "font": "DejaVuSans",
      "font_size": 9.0,
      "color": [0.42, 0.42, 0.42]
    }
  ]
}