write_first_page_first.json

The JSON file of the “Showing Page One Before the File Has Arrived” example. The same document written twice: once as it is, once with its first page placed at the start of the file. The page gives, for each of the two, the number of bytes a browser must have received before it shows page 1.

JSON 5431 lines of which the first 93 are shown here

This file is far longer than the others: showing it whole would make this page ten times heavier than any other, which is paid for by whoever reads it on a telephone. So the page shows how the file opens, and the button below hands over the file itself, entire.

This file is a request: an application sends it over the network to the server, which creates the PDF and sends it back. It creates 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.

What This Example Is For

Open the book below: the first page appears the instant you click it, as though the file carried a single page — and it carries 357. That is the whole of what this example is for, and it is worth more the longer the document gets: a catalogue, a manual, a report of two hundred pages behaves the same way.

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
{
  "first_page_first": true,
  "renumber": [
    {
      "from_page": 2,
      "value": 1
    }
  ],
  "items": [
    {
      "type": "flow",
      "rect": {
        "llx": 64.0,
        "lly": 530.0,
        "urx": "{page_width} - 64",
        "ury": 560.0
      },
      "content": "Little Women",
      "font": "DejaVuSans",
      "font_size": 24.0,
      "align": "center",
      "leading": 30.0,
      "pages": [
        1
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 64.0,
        "lly": 462.0,
        "urx": "{page_width} - 64",
        "ury": 480.0
      },
      "content": "Louisa May Alcott",
      "font": "DejaVuSans",
      "font_size": 13.0,
      "align": "center",
      "leading": 18.0,
      "pages": [
        1
      ]
    },
    {
      "type": "stack",
      "id": "chapter_1",
      "start": {
        "page": 4
      },
      "first": {
        "llx": 64.0,
        "lly": 66.0,
        "urx": "{page_width} - 64",
        "ury": 700.0
      },
      "next": {
        "llx": 64.0,
        "lly": 66.0,
        "urx": "{page_width} - 64",
        "ury": "{page_height} - 64"
      },
      "blocks": [
        {
          "type": "text",
          "content": "CHAPTER I.",
          "font": "DejaVuSans",
          "font_size": 11.0,
          "align": "center",
          "leading": 13.0,
          "color": [
            0.42,
            0.42,
            0.45
          ]
        },
        {
          "type": "space",
          "height": 15.0
        },
        {
          "type": "text",
          "content": "Playing Pilgrims",
          "font": "DejaVuSans",
          "font_size": 15.0,
          "align": "center",
          "leading": 20.0
        },
        {
          "type": "space",
          "height": 34.0
        },
        {
          "type": "text",