write_picture_cells.json

The JSON file of the “Pictures inside table cells” example. A catalogue whose first column is a picture rather than text: four pictures of very different sizes and proportions, each fitted whole and undistorted into the cell the table gives it and standing against a different corner of it, claiming no width from its column and no height from its row.

JSON 203 lines

This file is a request: an application sends it over the network to the server, which creates the PDF and sends it back. It makes the same page as the Rust and Python versions of this example. A request names every file it uses, never its content; the call carries the request and the files together. A font the server already holds, such as DejaVuSans, is named with nothing attached. Send the request to the address the API page gives.

This request names files it does not carry: bilevel.png, hqf_development.png, logo.png, photo.jpg. Each one travels beside the request, in the same call, as a supplied part named exactly as the request names it here — the description says which name plays which role, so you name your files as you like. A request naming a file the call carries nothing of is refused.

What this example is for

A product catalogue means photographs, and photographs come from suppliers: one is nine hundred pixels across, the next is sixteen, and no two share the same proportions. Bringing them all to a common size before the page can be laid out is a step somebody has to run, remember to run again next quarter, and account for the day it was skipped.

What this example shows

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