write_picture_cells.json

Le fichier JSON de l'exemple « Des images dans les cellules d'un tableau ». Un catalogue dont la première colonne est une image et non du texte : quatre images de tailles et de proportions très différentes, chacune posée entière et sans déformation dans la cellule que le tableau lui donne, contre un coin différent — sans réclamer ni largeur à sa colonne ni hauteur à sa ligne.

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

Cette requête nomme des fichiers qu'elle ne contient pas : bilevel.png, hqf_development.png, logo.png, photo.jpg. Chacun voyage à côté de la requête, dans le même appel, comme une pièce fournie nommée exactement comme la requête la nomme ici — la description dit quel nom joue quel rôle, vous nommez donc vos fichiers comme vous voulez. Une requête qui nomme un fichier dont l'appel ne contient rien est refusée.

À quoi sert cet exemple

Un catalogue produits, ce sont des photos, et les photos viennent des fournisseurs : l'une fait neuf cents pixels de large, la suivante seize, et il n'y en a pas deux aux mêmes proportions. Les ramener toutes à une taille commune avant de pouvoir monter la page, c'est une étape que quelqu'un doit lancer, penser à relancer au trimestre suivant, et justifier le jour où elle a été sautée.

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
{
  "items": [
    {
      "type": "table",
      "columns": {
        "widths": [
          { "points": 96.0 },
          { "fraction": 1.0 },
          "content",
          "content"
        ],
        "total": 483.27599999999995
      },
      "first": { "llx": 56.0, "lly": 64.0, "urx": 539.276, "ury": 760.0 },
      "next": { "llx": 56.0, "lly": 64.0, "urx": 539.276, "ury": 760.0 },
      "header": 1,
      "rules": [
        { "rule": "frame", "stroke": { "width": 0.8 } },
        {
          "rule": "horizontal_other",
          "stroke": { "width": 0.25, "color": [0.75, 0.75, 0.75] }
        },
        {
          "rule": "vertical_other",
          "stroke": { "width": 0.25, "color": [0.75, 0.75, 0.75] }
        },
        { "rule": { "horizontal": 1 }, "stroke": { "width": 0.8 } }
      ],
      "rows": [
        {
          "min_height": 20.0,
          "cells": [
            {
              "content": ["Picture"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 },
              "fill": [0.86, 0.86, 0.86]
            },
            {
              "content": ["Item"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 },
              "fill": [0.86, 0.86, 0.86]
            },
            {
              "content": ["Reference"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 },
              "fill": [0.86, 0.86, 0.86]
            },
            {
              "content": ["Price, €"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "align": "right",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 },
              "fill": [0.86, 0.86, 0.86]
            }
          ]
        },
        {
          "min_height": 54.0,
          "cells": [
            {
              "image": "hqf_development.png",
              "align": "left",
              "valign": "top",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": [
                "Wide banner",
                "Nine hundred pixels across and half as tall, drawn against the top left of its cell."
              ],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["BN-900"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["148.00"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "align": "right",
              "align_on": ".",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            }
          ]
        },
        {
          "min_height": 54.0,
          "cells": [
            {
              "image": "photo.jpg",
              "align": "center",
              "valign": "middle",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": [
                "Photograph",
                "Four to three, in the middle of its cell — the room it does not fill is shared either side."
              ],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["PH-160"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["24.50"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "align": "right",
              "align_on": ".",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            }
          ]
        },
        {
          "min_height": 54.0,
          "cells": [
            {
              "image": "logo.png",
              "align": "right",
              "valign": "bottom",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": [
                "Square mark",
                "As tall as it is wide, against the bottom right. The height runs out first, so nothing is left below it."
              ],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["SQ-96"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["9.90"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "align": "right",
              "align_on": ".",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            }
          ]
        },
        {
          "min_height": 54.0,
          "cells": [
            {
              "image": "bilevel.png",
              "align": "center",
              "valign": "middle",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": [
                "Two-colour rule",
                "Sixteen pixels by eight, drawn as large as the cell allows: a picture is fitted to its cell, not to its own pixels."
              ],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["RL-16"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            },
            {
              "content": ["3.75"],
              "font": "DejaVuSans",
              "font_size": 9.0,
              "align": "right",
              "align_on": ".",
              "padding": { "left": 6.0, "right": 6.0, "top": 5.0, "bottom": 5.0 }
            }
          ]
        }
      ]
    }
  ]
}