write_text.json

The JSON file of the “Fonts Embedded in the File” example. Text set in a font embedded in the file, cut down to the letters actually used, and still searchable, copyable and readable aloud.

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

Send a document to somebody who does not have your house font and one of two things happens: their reading software quietly puts another one in its place and your layout moves, or it draws empty boxes where the letters were. Carrying the font inside the file is the only cure, and it is the first thing a commercial printer will ask you for before accepting the job.

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
{
  "metadata": {
    "title": "hqf-pdf text sample"
  },
  "items": [
    {
      "type": "text",
      "rect": {
        "llx": 60,
        "lly": 600,
        "urx": 560,
        "ury": 788.0
      },
      "content": [
        "Invoice No. 1964413 \u2014 HQF Development, Cabri\u00e8s\nIssued 14 July 2026 \u2014 due within 30 days\nRendering engine development ............... 4 250.00 EUR\nVAT at 20 % .................................. 850.00 EUR\nTotal due .................................. 5 100.00 EUR"
      ],
      "font": "DejaVuSans",
      "font_size": 14.0,
      "leading": 28.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 60,
        "lly": 620,
        "urx": 381.719727,
        "ury": 620
      },
      "stroke": {
        "width": 0.8
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 538.0,
        "urx": 655.276,
        "ury": 560.0
      },
      "content": "Each line below steps down by the leading, not by a coordinate.",
      "font": "DejaVuSans",
      "font_size": 11.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 522.0,
        "urx": 655.276,
        "ury": 544.0
      },
      "content": "These letters stand one and a half points apart.",
      "font": "DejaVuSans",
      "font_size": 11.0,
      "first_baseline": {
        "points": 0
      },
      "character_spacing": 1.5
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 506.0,
        "urx": 655.276,
        "ury": 528.0
      },
      "content": "These glyphs are narrowed to eighty per cent of their width.",
      "font": "DejaVuSans",
      "font_size": 11.0,
      "first_baseline": {
        "points": 0
      },
      "horizontal_scaling": 80.0
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 484.0,
        "urx": 655.276,
        "ury": 506.0
      },
      "content": "This line keeps the leading the move above it set: twenty-two points.",
      "font": "DejaVuSans",
      "font_size": 11.0,
      "first_baseline": {
        "points": 0
      }
    },
    {
      "type": "line",
      "from": {
        "x": 60.0,
        "y": 494.0
      },
      "to": {
        "x": 535.0,
        "y": 494.0
      },
      "stroke": {
        "width": 0.4
      }
    }
  ]
}