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, a panel filled with a circular one that lets the page show through, and a band whose blend is stood upright and whose border is painted with the circular one.

JSON 105 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 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

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
 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
{
  "graphics_states": [
    {"name": "see_through", "state": {"fill_alpha": 0.7}}
  ],
  "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]
        }
      },
      "graphics_state": "see_through"
    },
    {
      "name": "upright",
      "shading": {
        "axial": {
          "from": [0, 0],
          "to": [120, 0],
          "start": [0.85, 0.12, 0.12],
          "end": [0.12, 0.2, 0.8],
          "extend": [true, true]
        }
      },
      "matrix": [0, 1, -1, 0, 70, 150]
    }
  ],
  "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 radial gradient, painted by its pattern at 70 % opacity."],
      "font": "DejaVuSans",
      "font_size": 12
    },
    {
      "type": "rect",
      "rect": {"llx": 70, "lly": 150, "urx": 525, "ury": 270},
      "fill": {"shading": "upright"},
      "stroke": {"width": 6, "color": {"shading": "panel"}}
    },
    {
      "type": "text",
      "rect": {"llx": 70, "lly": 134, "urx": 525, "ury": 148.4},
      "content": ["A gradient laid flat, stood upright by its pattern's matrix, edged in radial."],
      "font": "DejaVuSans",
      "font_size": 12
    }
  ]
}