write_layers.json

The JSON file of the “One drawing, and each reader sees their own” example. The same floor plan on six layers shown and hidden one at a time: the furniture and the distances shown, the internal notes hidden until asked for, and a draft watermark meant for the screen and not for the paper.

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

The library writes each line of the page at a stated height; a request gives a block of words a rectangle instead, so every line's rectangle here is worked back from that height. Eleven of them reach past the plan they sit under, harmlessly, because the library writes those lines without breaking them and a block of words would break them at the edge of its rectangle. The walls are one colour set once on the library's side, an outer wall and then a partition; on the wire they are two things, each stating that colour for itself, and each piece of furniture is filled and then outlined as two shapes there and drawn once and painted in one go here. The six layers themselves, what each of them carries, and the draft watermark a reader may not decide to print are the same either way, down to the order the panel lists them in.

What this example is for

The same floor plan has to reach three people: the site, with its dimensions; the client, without the internal notes; the printer, without the draft watermark across it. Making three files means three files to keep in step, and the day one of them is remade and the others are not, somebody builds from the wrong drawing.

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
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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
{
  "layers": [
    {
      "name": "Furniture",
      "made_by": { "application": "Plan Studio", "work": "technical" }
    },
    { "name": "Dimensions" },
    { "name": "Notes", "visible": false },
    {
      "name": "Draft",
      "on_screen": true,
      "printed": false,
      "purpose": "watermark"
    },
    { "name": "Grid", "visible": false, "intent": "design" },
    { "name": "Crop marks", "purpose": "printers_marks" }
  ],
  "drawings": [
    {
      "name": "chair",
      "layer": "Furniture",
      "box": { "llx": 0.0, "lly": 0.0, "urx": 14.0, "ury": 10.0 },
      "items": [
        {
          "type": "rect",
          "rect": { "llx": 0.5, "lly": 0.5, "urx": 13.5, "ury": 9.5 },
          "fill": [0.85, 0.88, 0.93],
          "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] }
        }
      ]
    }
  ],
  "items": [
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 750.0, "urx": 560.0, "ury": 768.0 },
      "content": ["One plan, six layers"],
      "font": "DejaVuSans",
      "font_size": 15.0
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 730.0, "urx": 590.0, "ury": 742.0 },
      "content": [
        "The walls are always there. Everything else is a layer the reader can show and hide."
      ],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },

    {
      "type": "rect",
      "rect": { "llx": 80.0, "lly": 380.0, "urx": 515.0, "ury": 700.0 },
      "stroke": { "width": 3.0, "color": [0.15, 0.15, 0.15] }
    },
    {
      "type": "line",
      "from": { "x": 345.0, "y": 380.0 },
      "to": { "x": 345.0, "y": 570.0 },
      "stroke": { "width": 3.0, "color": [0.15, 0.15, 0.15] }
    },

    {
      "type": "path",
      "segments": [
        { "move_to": { "x": 109.0, "y": 380.0 } },
        { "line_to": { "x": 109.0, "y": 700.0 } },
        { "move_to": { "x": 138.0, "y": 380.0 } },
        { "line_to": { "x": 138.0, "y": 700.0 } },
        { "move_to": { "x": 167.0, "y": 380.0 } },
        { "line_to": { "x": 167.0, "y": 700.0 } },
        { "move_to": { "x": 196.0, "y": 380.0 } },
        { "line_to": { "x": 196.0, "y": 700.0 } },
        { "move_to": { "x": 225.0, "y": 380.0 } },
        { "line_to": { "x": 225.0, "y": 700.0 } },
        { "move_to": { "x": 254.0, "y": 380.0 } },
        { "line_to": { "x": 254.0, "y": 700.0 } },
        { "move_to": { "x": 283.0, "y": 380.0 } },
        { "line_to": { "x": 283.0, "y": 700.0 } },
        { "move_to": { "x": 312.0, "y": 380.0 } },
        { "line_to": { "x": 312.0, "y": 700.0 } },
        { "move_to": { "x": 341.0, "y": 380.0 } },
        { "line_to": { "x": 341.0, "y": 700.0 } },
        { "move_to": { "x": 370.0, "y": 380.0 } },
        { "line_to": { "x": 370.0, "y": 700.0 } },
        { "move_to": { "x": 399.0, "y": 380.0 } },
        { "line_to": { "x": 399.0, "y": 700.0 } },
        { "move_to": { "x": 428.0, "y": 380.0 } },
        { "line_to": { "x": 428.0, "y": 700.0 } },
        { "move_to": { "x": 457.0, "y": 380.0 } },
        { "line_to": { "x": 457.0, "y": 700.0 } },
        { "move_to": { "x": 486.0, "y": 380.0 } },
        { "line_to": { "x": 486.0, "y": 700.0 } },
        { "move_to": { "x": 80.0, "y": 412.0 } },
        { "line_to": { "x": 515.0, "y": 412.0 } },
        { "move_to": { "x": 80.0, "y": 444.0 } },
        { "line_to": { "x": 515.0, "y": 444.0 } },
        { "move_to": { "x": 80.0, "y": 476.0 } },
        { "line_to": { "x": 515.0, "y": 476.0 } },
        { "move_to": { "x": 80.0, "y": 508.0 } },
        { "line_to": { "x": 515.0, "y": 508.0 } },
        { "move_to": { "x": 80.0, "y": 540.0 } },
        { "line_to": { "x": 515.0, "y": 540.0 } },
        { "move_to": { "x": 80.0, "y": 572.0 } },
        { "line_to": { "x": 515.0, "y": 572.0 } },
        { "move_to": { "x": 80.0, "y": 604.0 } },
        { "line_to": { "x": 515.0, "y": 604.0 } },
        { "move_to": { "x": 80.0, "y": 636.0 } },
        { "line_to": { "x": 515.0, "y": 636.0 } },
        { "move_to": { "x": 80.0, "y": 668.0 } },
        { "line_to": { "x": 515.0, "y": 668.0 } }
      ],
      "stroke": { "width": 0.3, "color": [0.55, 0.75, 0.9] },
      "layer": "Grid"
    },

    {
      "type": "rect",
      "rect": { "llx": 120.0, "lly": 590.0, "urx": 240.0, "ury": 660.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },
    {
      "type": "rect",
      "rect": { "llx": 380.0, "lly": 570.0, "urx": 470.0, "ury": 680.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },
    {
      "type": "rect",
      "rect": { "llx": 370.0, "lly": 410.0, "urx": 480.0, "ury": 450.0 },
      "fill": [0.85, 0.88, 0.93],
      "stroke": { "width": 1.0, "color": [0.35, 0.45, 0.6] },
      "layer": "Furniture"
    },

    {
      "type": "drawing",
      "drawing": "chair",
      "x": 140.0,
      "y": 662.0
    },
    {
      "type": "drawing",
      "drawing": "chair",
      "x": 173.0,
      "y": 662.0
    },
    {
      "type": "drawing",
      "drawing": "chair",
      "x": 206.0,
      "y": 662.0
    },
    {
      "type": "drawing",
      "drawing": "chair",
      "x": 140.0,
      "y": 578.0
    },
    {
      "type": "drawing",
      "drawing": "chair",
      "x": 173.0,
      "y": 578.0
    },
    {
      "type": "drawing",
      "drawing": "chair",
      "x": 206.0,
      "y": 578.0
    },

    {
      "type": "path",
      "segments": [
        { "move_to": { "x": 80.0, "y": 354.0 } },
        { "line_to": { "x": 515.0, "y": 354.0 } },
        { "move_to": { "x": 80.0, "y": 349.0 } },
        { "line_to": { "x": 80.0, "y": 359.0 } },
        { "move_to": { "x": 515.0, "y": 349.0 } },
        { "line_to": { "x": 515.0, "y": 359.0 } },
        { "move_to": { "x": 34.0, "y": 380.0 } },
        { "line_to": { "x": 34.0, "y": 700.0 } },
        { "move_to": { "x": 29.0, "y": 380.0 } },
        { "line_to": { "x": 39.0, "y": 380.0 } },
        { "move_to": { "x": 29.0, "y": 700.0 } },
        { "line_to": { "x": 39.0, "y": 700.0 } }
      ],
      "stroke": { "width": 0.8, "color": [0.2, 0.5, 0.35] },
      "layer": "Dimensions"
    },
    {
      "type": "text",
      "rect": { "llx": 279.5, "lly": 362.0, "urx": 360.0, "ury": 372.8 },
      "content": ["7.25 m"],
      "font": "DejaVuSans",
      "font_size": 9.0,
      "color": [0.2, 0.5, 0.35],
      "layer": "Dimensions"
    },
    {
      "type": "text",
      "rect": { "llx": 40.0, "lly": 540.0, "urx": 120.0, "ury": 550.8 },
      "content": ["5.00 m"],
      "font": "DejaVuSans",
      "font_size": 9.0,
      "color": [0.2, 0.5, 0.35],
      "layer": "Dimensions"
    },

    {
      "type": "text",
      "rect": { "llx": 124.0, "lly": 570.0, "urx": 340.0, "ury": 579.6 },
      "content": ["Table seats six."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },
    {
      "type": "text",
      "rect": { "llx": 372.0, "lly": 552.0, "urx": 590.0, "ury": 561.6 },
      "content": ["Bed against the party wall."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },
    {
      "type": "text",
      "rect": { "llx": 372.0, "lly": 396.0, "urx": 590.0, "ury": 405.6 },
      "content": ["Counter, waste under."],
      "font": "DejaVuSans",
      "font_size": 8.0,
      "color": [0.7, 0.25, 0.1],
      "layer": "Notes"
    },

    {
      "type": "stamp",
      "rect": { "llx": 80.0, "lly": 380.0, "urx": 515.0, "ury": 700.0 },
      "content": "DRAFT",
      "font": "DejaVuSans",
      "slant": "up",
      "color": [0.8, 0.3, 0.3],
      "layer": "Draft"
    },

    {
      "type": "path",
      "segments": [
        { "move_to": { "x": 30.0, "y": 36.0 } },
        { "line_to": { "x": 12.0, "y": 36.0 } },
        { "move_to": { "x": 36.0, "y": 30.0 } },
        { "line_to": { "x": 36.0, "y": 12.0 } },
        { "move_to": { "x": 565.0, "y": 36.0 } },
        { "line_to": { "x": 583.0, "y": 36.0 } },
        { "move_to": { "x": 559.0, "y": 30.0 } },
        { "line_to": { "x": 559.0, "y": 12.0 } },
        { "move_to": { "x": 30.0, "y": 806.0 } },
        { "line_to": { "x": 12.0, "y": 806.0 } },
        { "move_to": { "x": 36.0, "y": 812.0 } },
        { "line_to": { "x": 36.0, "y": 830.0 } },
        { "move_to": { "x": 565.0, "y": 806.0 } },
        { "line_to": { "x": 583.0, "y": 806.0 } },
        { "move_to": { "x": 559.0, "y": 812.0 } },
        { "line_to": { "x": 559.0, "y": 830.0 } }
      ],
      "stroke": { "width": 0.5, "color": [0.0, 0.0, 0.0] },
      "layer": "Crop marks"
    },

    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 300.0, "urx": 165.0, "ury": 312.0 },
      "content": ["Furniture"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 300.0, "urx": 590.0, "ury": 312.0 },
      "content": ["shown; turn it off and the rooms stand empty, chairs too"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 282.0, "urx": 165.0, "ury": 294.0 },
      "content": ["Dimensions"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 282.0, "urx": 590.0, "ury": 294.0 },
      "content": ["shown; the distances around the plan"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 264.0, "urx": 165.0, "ury": 276.0 },
      "content": ["Notes"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 264.0, "urx": 590.0, "ury": 276.0 },
      "content": ["hidden; turn it on to read them"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 246.0, "urx": 165.0, "ury": 258.0 },
      "content": ["Draft"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 246.0, "urx": 590.0, "ury": 258.0 },
      "content": ["shown on screen, never printed; the file calls it a watermark"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 228.0, "urx": 165.0, "ury": 240.0 },
      "content": ["Grid"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 228.0, "urx": 590.0, "ury": 240.0 },
      "content": ["hidden; an aid for whoever drew the plan, not part of it"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 210.0, "urx": 165.0, "ury": 222.0 },
      "content": ["Crop marks"],
      "font": "DejaVuSans",
      "font_size": 10.0
    },
    {
      "type": "text",
      "rect": { "llx": 170.0, "lly": 210.0, "urx": 590.0, "ury": 222.0 },
      "content": ["shown; the file calls them printer's marks"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 180.0, "urx": 590.0, "ury": 192.0 },
      "content": ["The draft mark carries its own answer for the printer, so nothing has to"],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    },
    {
      "type": "text",
      "rect": { "llx": 80.0, "lly": 166.0, "urx": 590.0, "ury": 178.0 },
      "content": ["be switched off before the page is printed."],
      "font": "DejaVuSans",
      "font_size": 10.0,
      "color": [0.35, 0.35, 0.35]
    }
  ]
}