krilla 0.7.0

A high-level crate for creating PDF files.
Documentation
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
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
# A tag for group nodes.
[Tag]
# A part of a document that may contain multiple articles or sections.
[Tag.Part]
# An article with largely self-contained content.
[Tag.Article]
optional = [
  "Layout::ColumnCount",
  "Layout::ColumnGap",
  "Layout::ColumnWidths",
]
# Section of a larger document.
[Tag.Section]
optional = [
  "Layout::ColumnCount",
  "Layout::ColumnGap",
  "Layout::ColumnWidths",
]
# A generic block-level grouping element.
[Tag.Div]
optional = [
  "Layout::ColumnCount",
  "Layout::ColumnGap",
  "Layout::ColumnWidths",
]
# A paragraph-level quote.
[Tag.BlockQuote]
# An image or figure caption.
#
# **Best Practice**: In the tag tree, this should appear
# as a sibling after the image (or other) content it describes.
[Tag.Caption]
# Table of contents.
#
# **Best Practice**: Should consist of TOCIs or other nested TOCs.
[Tag.TOC]
# Item in the table of contents.
#
# **Best Practice**: Should only appear within a TOC. Should only consist of
# labels, references, paragraphs and TOCs.
[Tag.TOCI]
# Index of the key terms in the document.
#
# **Best Practice**: Should contain a sequence of text accompanied by
# reference elements pointing to their occurrence in the text.
[Tag.Index]
# A paragraph.
[Tag.P]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# Heading level `n`, including an optional title of the heading.
#
# The title is required for some export modes, like for example PDF/UA.
[Tag.Hn]
required = ["Struct::HeadingLevel"]
suggested = ["Struct::Title"]
optional = [
  "Struct::Title",
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A list.
#
# **Best practice**: Should consist of an optional caption followed by
# list items.
# List numbering is only required for PDF/UA, but we just enforce it for always.
[Tag.L]
required = ["List::Numbering"]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A list item.
#
# **Best practice**: Should consist of one or more list labels and/or list bodies.
[Tag.LI]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# Label for a list item.
[Tag.Lbl]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# Description of the list item.
[Tag.LBody]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A table, with an optional summary describing the purpose and structure.
#
# **Best practice**: Should consist of an optional table header row,
# one or more table body elements and an optional table footer. Can have
# caption as the first or last child.
[Tag.Table]
optional = [
  "Table::Summary",
  "Layout::BBox",
  "Layout::Width",
  "Layout::Height",
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::TextIndent",
  "Layout::TextAlign",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A table row.
#
# **Best practice**: May contain table headers cells and table data cells.
[Tag.TR]
# A table header cell.
[Tag.TH]
required = ["Table::HeaderScope"]
optional = [
  "Table::CellHeaders",
  "Table::RowSpan",
  "Table::ColSpan",
  "Layout::Width",
  "Layout::Height",
  "Layout::TableBorderStyle",
  "Layout::TablePadding",
  "Layout::BlockAlign",
  "Layout::InlineAlign",
]
# A table data cell.
[Tag.TD]
optional = [
  "Table::CellHeaders",
  "Table::RowSpan",
  "Table::ColSpan",
  "Layout::Width",
  "Layout::Height",
  "Layout::TableBorderStyle",
  "Layout::TablePadding",
  "Layout::BlockAlign",
  "Layout::InlineAlign",
]
# A table header row group.
[Tag.THead]
# A table data row group.
[Tag.TBody]
# A table footer row group.
[Tag.TFoot]
# An inline-level element that does not have a specific meaning.
[Tag.Span]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# An inline quotation.
[Tag.InlineQuote]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A foot- or endnote, potentially referred to from within the text.
#
# **Best practice**: It may have a label as a child.
[Tag.Note]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A reference to elsewhere in the document.
#
# **Best practice**: The first child of a tag group with this tag should be a link annotation
# linking to a destination in the document, and the second child should consist of
# the children that should be associated with that reference.
[Tag.Reference]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A reference to the external source of some cited document.
#
# **Best practice**: It may have a label as a child.
[Tag.BibEntry]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# Computer code.
[Tag.Code]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# A link.
#
# **Best practice**: The first child of a tag group with this tag should be a link annotation
# linking to an URL, and the second child should consist of the children that should
# be associated with that link.
[Tag.Link]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# An association between an annotation and the content it belongs to. PDF
#
# **Best practice**: Should be used for all annotations, except for link annotations and
# widget annotations. The first child should be the identifier of a non-link annotation,
# and all other subsequent children should be content identifiers associated with that
# annotation.
[Tag.Annot]
optional = [
  "Layout::SpaceBefore",
  "Layout::SpaceAfter",
  "Layout::StartIndent",
  "Layout::EndIndent",
  "Layout::LineHeight",
  "Layout::BaselineShift",
  "Layout::TextDecorationColor",
  "Layout::TextDecorationThickness",
  "Layout::TextDecorationType",
]
# Item of graphical content.
#
# Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
[Tag.Figure]
suggested = ["Struct::AltText"]
optional = [
  "Layout::BBox",
  "Layout::Width",
  "Layout::Height",
]
# A mathematical formula.
#
# Providing `alt_text` is required in some export modes, like for example PDF/UA-1.
[Tag.Formula]
suggested = ["Struct::AltText"]
optional = [
  "Layout::BBox",
  "Layout::Width",
  "Layout::Height",
]
# An interactive form field.
[Tag.Form]
# Non-structural element. A grouping element having no inherent structural significance;
# it serves solely for grouping purposes.
[Tag.NonStruct]

# Non-standard role-mapped tag kinds:

# A date or time.
[Tag.Datetime]
# A list of terms.
[Tag.Terms]
# A title.
[Tag.Title]
# Encloses content with strong importance, most commonly **bold** text.
[Tag.Strong]
# Encloses content that is emphasized, most commonly *italic* text.
[Tag.Em]

[Attr.Struct]
# The tag id.
Id = { type = "TagId", global = true }
# The language of this tag.
Lang = { type = "String", global = true, accessor = "AsRef<str>" }
# The optional alternate text that describes the text (for example, if the text
# consists of a star symbol, the alt text should describe that in natural language).
AltText = { type = "String", global = true, accessor = "AsRef<str>" }
# The expanded form of an abbreviation.
# Only applicable if the content of the tag is an abbreviation.
Expanded = { type = "String", global = true, accessor = "AsRef<str>" }
# The actual text represented by the content of this tag, i.e. if it contained
# some curves that artistically represent some word. This should be the exact
# replacement text of the word.
ActualText = { type = "String", global = true, accessor = "AsRef<str>" }
# The title, characterizing a specific tag such as `"Chapter 1"`.
Title = { type = "String", accessor = "AsRef<str>" }

# The heading level
HeadingLevel = { name = "level", type = "NonZeroU16", accessor = "Copy" }

[Attr.List]
# The list numbering.
Numbering = { type = "ListNumbering", accessor = "Copy" }

[Attr.Table]
# The table summary.
Summary = { type = "String", accessor = "AsRef<str>" }
# The table header scope.
HeaderScope = { name = "scope", type = "TableHeaderScope", accessor = "Copy" }
# The list of headers associated with a table cell.
# Table data cells (`TD`) may specify a list of table headers (`TH`),
# which can also specify a list of parent header cells (`TH`), and so on.
# To determine the list of associated headers this list is recursively
# evaluated.
#
# This allows specifying header hierarchies inside tables.
CellHeaders = { name = "headers", type = "SmallVec<[TagId; 1]>", accessor = "Custom" }
# The row span of this table cell.
RowSpan = { type = "NonZeroU32", accessor = "Copy" }
# The column span of this table cell.
ColSpan = { type = "NonZeroU32", accessor = "Copy" }

[Attr.Layout]
# The placement.
Placement = { type = "Placement", global = true, accessor = "Copy" }
# The writing mode.
WritingMode = { type = "WritingMode", global = true, accessor = "Copy" }
# The bounding box of a tag that encloses its visible content.
# If the content spans multiple pages, this should be omitted.
BBox = { name = "bbox", type = "BBox", accessor = "Copy" }
# The width.
Width = { type = "f32", accessor = "Copy" }
# The height.
Height = { type = "f32", accessor = "Copy" }
# The background color.
BackgroundColor = { type = "NaiveRgbColor", global = true, accessor = "Copy" }
# The border color.
BorderColor = { type = "Sides<NaiveRgbColor>", global = true, accessor = "Copy" }
# The way the border is drawn.
BorderStyle = { type = "Sides<BorderStyle>", global = true, accessor = "Copy" }
# The border width.
BorderThickness = { type = "Sides<f32>", global = true, accessor = "Copy" }
# The padding inside of an element.
Padding = { type = "Sides<f32>", global = true, accessor = "Copy" }
# The color of text, borders, and text decorations.
Color = { type = "NaiveRgbColor", global = true, accessor = "Copy" }
# The spacing before the block-level element.
SpaceBefore = { type = "f32", accessor = "Copy" }
# The spacing after the block-level element.
SpaceAfter = { type = "f32", accessor = "Copy" }
# The spacing between the start inline edge of the element and the parent.
StartIndent = { type = "f32", accessor = "Copy" }
# The spacing between the end inline edge of the element and the parent.
EndIndent = { type = "f32", accessor = "Copy" }
# The amount the first line of text in a block-level element is indented. Only
# applicable to paragraph-like elements with non-block-level elements.
TextIndent = { type = "f32", accessor = "Copy" }
# The text alignment.
TextAlign = { type = "TextAlign", accessor = "Copy" }
# The alignment of block-level elements inside of this block-level element.
BlockAlign = { type = "BlockAlign", accessor = "Copy" }
# The alignment of inline-level elements inside of this block-level element.
InlineAlign = { type = "InlineAlign", accessor = "Copy" }
# The border style of table cells, overriding `BorderStyle`.
TableBorderStyle = { type = "Sides<BorderStyle>", accessor = "Copy" }
# The padding inside of table cells, overriding `Padding`.
TablePadding = { type = "Sides<f32>", accessor = "Copy" }
# The distance by which the baseline shall be shifted from the default position.
BaselineShift = { type = "f32", global = true, accessor = "Copy" }
# The height of each line in an element on the block axis.
LineHeight = { type = "LineHeight", global = true, accessor = "Copy" }
# The color of the text decoration, overriding the fill color.
TextDecorationColor = { type = "NaiveRgbColor", global = true, accessor = "Copy" }
# The width of the text decoration line.
TextDecorationThickness = { type = "f32", global = true, accessor = "Copy" }
# The kind of text decoration.
TextDecorationType = { type = "TextDecorationType", global = true, accessor = "Copy" }
# How the glyphs are rotated in a vertical writing mode.
GlyphOrientationVertical = { type = "GlyphOrientationVertical", global = true, accessor = "Copy" }
# The number of columns in the grouping element.
ColumnCount = { type = "NonZeroU32", accessor = "Copy" }
# The width of the gaps between columns in the grouping element.
ColumnGap = { type = "ColumnDimensions" }
# The width of the columns in the grouping element.
ColumnWidths = { type = "ColumnDimensions" }