Paragraph indents and spacing

The same two paragraphs six ways: the indents, the room around a paragraph, its last line, its first line.

JSON write_paragraphs.json 301 lines

This one is not a program. It is the request the document server is sent: the same page, asked for over the network by an application that writes no PDF code at all.

The library measures three numbers off the lines it has just set — the room a heading takes, the room the block under it fills, and where that block therefore starts — and the request repeats those three as figures written into it, so every rectangle here is worked back from what the library measured. The sixth block asks the library for a last line clear of the letters that hang below it; that setting is not on the wire, and it draws nothing — it only enters the height the block reports. The frame under that block is drawn at the height the library reported, so both pages carry the same frame. The six shapes themselves, and where every line of every block falls, are the same either way.

  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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
{
  "items": [
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 770.5,
        "urx": 285.0,
        "ury": 780.0
      },
      "content": "Nothing set: the shape a flow has by default.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 697.5,
        "urx": 285.0,
        "ury": 762.5
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 60.0,
        "lly": 697.5,
        "urx": 285.0,
        "ury": 762.5
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 571.0,
        "urx": 285.0,
        "ury": 590.0
      },
      "content": "First line indented; the paragraphs are told apart by that alone.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 498.0,
        "urx": 285.0,
        "ury": 563.0
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0,
      "first_line_indent": 18.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 60.0,
        "lly": 498.0,
        "urx": 285.0,
        "ury": 563.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 390.5,
        "urx": 285.0,
        "ury": 400.0
      },
      "content": "First line hung out to the left of the block.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 60.0,
        "lly": 317.5,
        "urx": 285.0,
        "ury": 382.5
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0,
      "left_indent": 24.0,
      "first_line_indent": -24.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 60.0,
        "lly": 317.5,
        "urx": 285.0,
        "ury": 382.5
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 770.5,
        "urx": 535.0,
        "ury": 780.0
      },
      "content": "Room left above and below each paragraph.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 673.5,
        "urx": 535.0,
        "ury": 762.5
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0,
      "space_before": 4.0,
      "space_after": 8.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 310.0,
        "lly": 673.5,
        "urx": 535.0,
        "ury": 762.5
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 580.5,
        "urx": 535.0,
        "ury": 590.0
      },
      "content": "Justified, with the last line of each paragraph centred.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 507.5,
        "urx": 535.0,
        "ury": 572.5
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0,
      "align": "justify",
      "last_align": "center",
      "right_indent": 12.0
    },
    {
      "type": "rect",
      "rect": {
        "llx": 310.0,
        "lly": 507.5,
        "urx": 535.0,
        "ury": 572.5
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 381.0,
        "urx": 535.0,
        "ury": 400.0
      },
      "content": "First baseline on the top of the capitals, last line clear of its descenders.",
      "font": "DejaVuSans",
      "font_size": 7.5,
      "leading": 9.5,
      "color": [
        0.35,
        0.35,
        0.35
      ]
    },
    {
      "type": "flow",
      "rect": {
        "llx": 310.0,
        "lly": 309.359375,
        "urx": 535.0,
        "ury": 373.0
      },
      "content": "The deposit is held on the account named overleaf and is returned within thirty days of the keys being handed back.\nDeductions are itemised in writing, and anything not itemised is not deducted.",
      "font": "DejaVuSans",
      "font_size": 10.0,
      "leading": 13.0,
      "first_baseline": "cap_height"
    },
    {
      "type": "rect",
      "rect": {
        "llx": 310.0,
        "lly": 309.359375,
        "urx": 535.0,
        "ury": 373.0
      },
      "stroke": {
        "width": 0.5,
        "color": [
          0.8,
          0.8,
          0.8
        ]
      }
    }
  ]
}