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 34 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

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
{
  "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
      }
    }
  ]
}