write_gradient_fill.json

The JSON file of the “Text and shapes filled with a gradient” example. A gradient used as the colour something is filled with: a headline whose letters are windows onto a blend of three colours, and a panel filled with a circular one.

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

What this example is for

A headline in a blend of colours belongs to a poster, a cover, a title page — and the usual way to get one is to build it in a drawing program and drop the picture in. The text then stops being text: it cannot be searched, it cannot be copied, and it cannot be translated without going back to whoever made it.

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
{
  "shadings": [
    {
      "name": "letters",
      "shading": {
        "axial": {
          "from": [70.0, 660.0],
          "to": [372.654297, 660.0],
          "space": "rgb",
          "function": {
            "stitching": {
              "functions": [
                {
                  "exponential": {
                    "low": [0.85, 0.12, 0.12],
                    "high": [0.12, 0.55, 0.2]
                  }
                },
                {
                  "exponential": {
                    "low": [0.12, 0.55, 0.2],
                    "high": [0.12, 0.2, 0.8]
                  }
                }
              ],
              "bounds": [0.5],
              "encode": [[0.0, 1.0], [0.0, 1.0]]
            }
          }
        }
      }
    },
    {
      "name": "panel",
      "shading": {
        "radial": {
          "from": [297.5, 445.0, 0.0],
          "to": [297.5, 445.0, 227.5],
          "start": [1.0, 1.0, 1.0],
          "end": [0.1, 0.15, 0.45],
          "extend": [false, true]
        }
      }
    }
  ],
  "items": [
    {
      "type": "text",
      "rect": {"llx": 70, "lly": 660, "urx": 525, "ury": 760.8},
      "content": ["hqf-pdf"],
      "font": "DejaVuSans",
      "font_size": 84,
      "color": {"shading": "letters"}
    },
    {
      "type": "text",
      "rect": {"llx": 70, "lly": 634, "urx": 525, "ury": 649.6},
      "content": ["Text filled with a gradient, through a shading pattern."],
      "font": "DejaVuSans",
      "font_size": 13
    },
    {
      "type": "rect",
      "rect": {"llx": 70, "lly": 350, "urx": 525, "ury": 540},
      "fill": {"shading": "panel"}
    },
    {
      "type": "text",
      "rect": {"llx": 70, "lly": 334, "urx": 525, "ury": 348.4},
      "content": ["A shape filled with a radial gradient."],
      "font": "DejaVuSans",
      "font_size": 12
    }
  ]
}