Skip to content

Commit c934648

Browse files
committed
Format with npm run prettier -- --write
1 parent fd43cbd commit c934648

File tree

111 files changed

+9166
-11005
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+9166
-11005
lines changed

docs/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# PDFKit Guide
22

3-
The PDFKit guide can be read a number of ways. The first is online at [pdfkit.org](http://pdfkit.org/).
3+
The PDFKit guide can be read a number of ways. The first is online at [pdfkit.org](http://pdfkit.org/).
44
You can also read the guide in PDF form, in this directory or [online](http://pdfkit.org/docs/guide.pdf).
55

66
Both the website and the PDF guide are generated from the Markdown files
@@ -9,18 +9,18 @@ You will need to have ImageMagick 7 installed so the `magick` command is
99
on your `$PATH`.
1010

1111
The examples are actually run when generating the PDF in order to show the results inline.
12-
The `generate.js` file in this directory is actually quite short. It parses the markdown files into a
12+
The `generate.js` file in this directory is actually quite short. It parses the markdown files into a
1313
tree structure using [markdown-js](https://github.com/evilstreak/markdown-js), syntax highlights the code
1414
examples using [codemirror](https://github.com/marijnh/codemirror), compiles and runs the code examples and puts the results
15-
inline, and generates the PDF using PDFKit. You can read the generator script source code to get a feeling for
15+
inline, and generates the PDF using PDFKit. You can read the generator script source code to get a feeling for
1616
how you might do something slightly more complex than the guide itself shows.
1717

1818
The markdown syntax used is pretty much standard, with a couple tweaks.
1919

20-
1. Code example output is references using the image notation, using the alt text as the example number starting from
21-
zero in the current file, and the title as the example output height. E.g. `![x](name "height")`.
22-
20+
1. Code example output is references using the image notation, using the alt text as the example number starting from
21+
zero in the current file, and the title as the example output height. E.g. `![x](name "height")`.
22+
2323
2. Page breaks are added before `h1` and `h2`s, unless there are two in a row. `h3` is treated the same as `h2` but
24-
can be used to avoid this in the case you need multiple `h2`s on the same page.
24+
can be used to avoid this in the case you need multiple `h2`s on the same page.
2525

2626
3. The horizontal rule syntax (`* * *`) denotes an explicit page break

docs/accessibility.md

Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -11,29 +11,29 @@ Some other simpler tasks are also required.
1111
This checklist covers everything that is required to create a conformant PDF/UA (PDF for
1212
Universal Accessibility) document (which is an extension of Tagged PDF):
1313

14-
* Pass the option `pdfVersion: '1.5'` (or a higher version) when creating your `PDFDocument`
15-
(depending on the features you use, you may only need 1.4; refer to the PDF reference for
16-
details).
17-
* Pass the option `subset: 'PDF/UA'` when creating your `PDFDocument` (if you wish the PDF to
18-
be identified as PDF/UA-1).
19-
* Pass the option `tagged: true` when creating your `PDFDocument` (technically, this sets the
20-
`Marked` property in the `Markings` dictionary to `true` in the PDF).
21-
* Provide a `Title` in the `info` option, and pass `displayTitle: true` when creating your
22-
`PDFDocument`.
23-
* Specify natural language in the document options and/or logical structure and/or
24-
non-structure marked `Span` content.
25-
* Add logical structure with all significant content included.
26-
* Include accessibility information (such as alternative text, actual text, etc.) in the
27-
logical structure and/or non-structure marked `Span` content.
28-
* Include all spaces which separate words/sentences/etc. in your marked structure content,
29-
even at the ends of lines, paragraphs, etc.. I.e. don't do `doc.text("Hello, world!")` but
30-
instead do `doc.text("Hello, world! ")`.
31-
* Mark all non-structure content as artifacts.
32-
* As well as creating the logical structure, write objects to the PDF in the natural
33-
"reading order".
34-
* Do not convey information solely using visuals (such as colour,
35-
contrast or position on the page).
36-
* No flickering or flashing content.
14+
- Pass the option `pdfVersion: '1.5'` (or a higher version) when creating your `PDFDocument`
15+
(depending on the features you use, you may only need 1.4; refer to the PDF reference for
16+
details).
17+
- Pass the option `subset: 'PDF/UA'` when creating your `PDFDocument` (if you wish the PDF to
18+
be identified as PDF/UA-1).
19+
- Pass the option `tagged: true` when creating your `PDFDocument` (technically, this sets the
20+
`Marked` property in the `Markings` dictionary to `true` in the PDF).
21+
- Provide a `Title` in the `info` option, and pass `displayTitle: true` when creating your
22+
`PDFDocument`.
23+
- Specify natural language in the document options and/or logical structure and/or
24+
non-structure marked `Span` content.
25+
- Add logical structure with all significant content included.
26+
- Include accessibility information (such as alternative text, actual text, etc.) in the
27+
logical structure and/or non-structure marked `Span` content.
28+
- Include all spaces which separate words/sentences/etc. in your marked structure content,
29+
even at the ends of lines, paragraphs, etc.. I.e. don't do `doc.text("Hello, world!")` but
30+
instead do `doc.text("Hello, world! ")`.
31+
- Mark all non-structure content as artifacts.
32+
- As well as creating the logical structure, write objects to the PDF in the natural
33+
"reading order".
34+
- Do not convey information solely using visuals (such as colour,
35+
contrast or position on the page).
36+
- No flickering or flashing content.
3737

3838
## Marked Content
3939

@@ -57,18 +57,18 @@ Tags to use are listed in a later section.
5757

5858
When marking content, you can provide options (take care to use correct capitalisation):
5959

60-
* `type` - used for artifact content; may be `Pagination` (e.g. headers and footers),
61-
`Layout` (e.g. rules and backgrounds) or `Page` (cut marks etc.)
62-
* `bbox` - bounding box for artifact content: `[left, top, right, bottom]` in default
63-
coordinates
64-
* `attached` - used for `Pagination` artifact content, array of one or more strings:
65-
`Top`, `Bottom`, `Left`, `Right`
66-
* `lang` - used for `Span` content: human language code (e.g. `en-AU`) which overrides default
67-
document language, and any enclosing structure element language
68-
* `alt` - used for `Span` content: alternative text for an image or other visual content
69-
* `expanded` - used for `Span` content: the expanded form of an abbreviation or acronym
70-
* `actual` - used for `Span` content: the actual text the content represents (e.g. if it is
71-
rendered as vector graphics)
60+
- `type` - used for artifact content; may be `Pagination` (e.g. headers and footers),
61+
`Layout` (e.g. rules and backgrounds) or `Page` (cut marks etc.)
62+
- `bbox` - bounding box for artifact content: `[left, top, right, bottom]` in default
63+
coordinates
64+
- `attached` - used for `Pagination` artifact content, array of one or more strings:
65+
`Top`, `Bottom`, `Left`, `Right`
66+
- `lang` - used for `Span` content: human language code (e.g. `en-AU`) which overrides default
67+
document language, and any enclosing structure element language
68+
- `alt` - used for `Span` content: alternative text for an image or other visual content
69+
- `expanded` - used for `Span` content: the expanded form of an abbreviation or acronym
70+
- `actual` - used for `Span` content: the actual text the content represents (e.g. if it is
71+
rendered as vector graphics)
7272

7373
It is advisable not to use `Span` content for specifying alternative text, expanded form, or
7474
actual text, especially if there is a possibility of the content automatically wrapping, which
@@ -169,10 +169,10 @@ you cannot mix atomic and incremental styles for the same structure element.
169169

170170
For an element to be flushed out, it must:
171171

172-
* be ended,
173-
* have been added to its parent, and
174-
* if it has content defined through closures (see next section), be attached to the document's
175-
structure (through its ancestors)
172+
- be ended,
173+
- have been added to its parent, and
174+
- if it has content defined through closures (see next section), be attached to the document's
175+
structure (through its ancestors)
176176

177177
When you call `doc.end()`, the document's structure is recursively ended, resulting in all
178178
elements being flushed out. If you created elements but forgot to add them to the document's
@@ -200,8 +200,8 @@ This is equivalent to:
200200
myStruct.add(myStructContent);
201201
myStruct.end();
202202

203-
Note that the content is marked and the closure is executed *if/when the element is attached to
204-
the document's structure*. This means that you can do something like this:
203+
Note that the content is marked and the closure is executed _if/when the element is attached to
204+
the document's structure_. This means that you can do something like this:
205205

206206
const myParagraph = doc.struct('P', [
207207
() => { doc.text("Please see ", { continued: true }); },
@@ -231,11 +231,11 @@ It's best to add elements to their parents as you go.
231231

232232
When creating a structure element, you can provide options:
233233

234-
* `title` - title of the structure element (e.g. "Chapter 1")
235-
* `lang` - human language code (e.g. `en-AU`) which overrides default document language
236-
* `alt` - alternative text for an image or other visual content
237-
* `expanded` - the expanded form of an abbreviation or acronym
238-
* `actual` - the actual text the content represents (e.g. if it is rendered as vector graphics)
234+
- `title` - title of the structure element (e.g. "Chapter 1")
235+
- `lang` - human language code (e.g. `en-AU`) which overrides default document language
236+
- `alt` - alternative text for an image or other visual content
237+
- `expanded` - the expanded form of an abbreviation or acronym
238+
- `actual` - the actual text the content represents (e.g. if it is rendered as vector graphics)
239239

240240
Example of a structure tree with options specified:
241241

@@ -308,69 +308,69 @@ ensure you give them with the correct capitalisation.
308308
309309
Non-structure tags:
310310

311-
* `Artifact` - used to mark all content not part of the logical structure
312-
* `ReversedChars` - every string of text has characters in reverse order for technical reasons
313-
(due to how fonts work for right-to-left languages); strings may have spaces at the
314-
beginning or end to separate words, but may not have spaces in the middle
311+
- `Artifact` - used to mark all content not part of the logical structure
312+
- `ReversedChars` - every string of text has characters in reverse order for technical reasons
313+
(due to how fonts work for right-to-left languages); strings may have spaces at the
314+
beginning or end to separate words, but may not have spaces in the middle
315315

316316
"Grouping" elements:
317317

318-
* `Document` - whole document; must be used if there are multiple parts or articles
319-
* `Part` - part of a document
320-
* `Art` - article
321-
* `Sect` - section; may nest
322-
* `Div` - generic division
323-
* `BlockQuote` - block quotation
324-
* `Caption` - describing a figure or table
325-
* `TOC` - table of contents, may be nested, and may be used for lists of figures, tables, etc.
326-
* `TOCI` - table of contents (leaf) item
327-
* `Index` - index (text with accompanying `Reference` content)
328-
* `NonStruct` - non-structural grouping element (element itself not intended to be exported to
329-
other formats like HTML, but 'transparent' to its content which is processed normally)
330-
* `Private` - content only meaningful to the creator (element and its content not intended to
331-
be exported to other formats like HTML)
318+
- `Document` - whole document; must be used if there are multiple parts or articles
319+
- `Part` - part of a document
320+
- `Art` - article
321+
- `Sect` - section; may nest
322+
- `Div` - generic division
323+
- `BlockQuote` - block quotation
324+
- `Caption` - describing a figure or table
325+
- `TOC` - table of contents, may be nested, and may be used for lists of figures, tables, etc.
326+
- `TOCI` - table of contents (leaf) item
327+
- `Index` - index (text with accompanying `Reference` content)
328+
- `NonStruct` - non-structural grouping element (element itself not intended to be exported to
329+
other formats like HTML, but 'transparent' to its content which is processed normally)
330+
- `Private` - content only meaningful to the creator (element and its content not intended to
331+
be exported to other formats like HTML)
332332

333333
"Block" elements:
334334

335-
* `H` - heading (first element in a section, etc.)
336-
* `H1` to `H6` - heading of a particular level intended for use only if nesting sections
337-
is not possible for some reason
338-
* `P` - paragraph
339-
* `L` - list; should include optional `Caption`, and list items
340-
* `LI` - list item; should contain `Lbl` and/or `LBody`
341-
* `Lbl` - label (bullet, number, or "dictionary headword")
342-
* `LBody` - list body (item text, or "dictionary definition"); may have nested lists or other blocks
335+
- `H` - heading (first element in a section, etc.)
336+
- `H1` to `H6` - heading of a particular level intended for use only if nesting sections
337+
is not possible for some reason
338+
- `P` - paragraph
339+
- `L` - list; should include optional `Caption`, and list items
340+
- `LI` - list item; should contain `Lbl` and/or `LBody`
341+
- `Lbl` - label (bullet, number, or "dictionary headword")
342+
- `LBody` - list body (item text, or "dictionary definition"); may have nested lists or other blocks
343343

344344
"Table" elements:
345345

346-
* `Table` - table; should either contain `TR`, or `THead`, `TBody` and/or `TFoot`
347-
* `TR` - table row
348-
* `TH` - table heading cell
349-
* `TD` - table data cell
350-
* `THead` - table header row group
351-
* `TBody` - table body row group; may have more than one per table
352-
* `TFoot` - table footer row group
346+
- `Table` - table; should either contain `TR`, or `THead`, `TBody` and/or `TFoot`
347+
- `TR` - table row
348+
- `TH` - table heading cell
349+
- `TD` - table data cell
350+
- `THead` - table header row group
351+
- `TBody` - table body row group; may have more than one per table
352+
- `TFoot` - table footer row group
353353

354354
"Inline" elements:
355355

356-
* `Span` - generic inline content
357-
* `Quote` - inline quotation
358-
* `Note` - e.g. footnote; may have a `Lbl` (see "block" elements)
359-
* `Reference` - content in a document that refers to other content (e.g. page number in an index)
360-
* `BibEntry` - bibliography entry; may have a `Lbl` (see "block" elements)
361-
* `Code` - code
362-
* `Link` - hyperlink; should contain a link annotation
363-
* `Annot` - annotation (other than a link)
364-
* `Ruby` - Chinese/Japanese pronunciation/explanation
365-
* `RB` - Ruby base text
366-
* `RT` - Ruby annotation text
367-
* `RP` - Ruby punctuation
368-
* `Warichu` - Japanese/Chinese longer description
369-
* `WT` - Warichu text
370-
* `WP` - Warichu punctuation
356+
- `Span` - generic inline content
357+
- `Quote` - inline quotation
358+
- `Note` - e.g. footnote; may have a `Lbl` (see "block" elements)
359+
- `Reference` - content in a document that refers to other content (e.g. page number in an index)
360+
- `BibEntry` - bibliography entry; may have a `Lbl` (see "block" elements)
361+
- `Code` - code
362+
- `Link` - hyperlink; should contain a link annotation
363+
- `Annot` - annotation (other than a link)
364+
- `Ruby` - Chinese/Japanese pronunciation/explanation
365+
- `RB` - Ruby base text
366+
- `RT` - Ruby annotation text
367+
- `RP` - Ruby punctuation
368+
- `Warichu` - Japanese/Chinese longer description
369+
- `WT` - Warichu text
370+
- `WP` - Warichu punctuation
371371

372372
"Illustration" elements (should have `alt` and/or `actualtext` set):
373373

374-
* `Figure` - figure
375-
* `Formula` - formula
376-
* `Form` - form widget
374+
- `Figure` - figure
375+
- `Formula` - formula
376+
- `Form` - form widget

docs/annotations.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ underline or strikeout portions of text. Annotations are added using the
66
various helper methods, and each type of annotation is defined by a rectangle
77
and some other properties. Here is a list of the available annotation methods:
88

9-
* `note(x, y, width, height, contents, options)`
10-
* `link(x, y, width, height, url, options)`
11-
* `goTo(x, y, w, h, name, options)`
12-
* `highlight(x, y, width, height, options)`
13-
* `underline(x, y, width, height, options)`
14-
* `strike(x, y, width, height, options)`
15-
* `lineAnnotation(x1, y1, x2, y2, options)`
16-
* `rectAnnotation(x, y, width, height, options)`
17-
* `ellipseAnnotation(x, y, width, height, options)`
18-
* `textAnnotation(x, y, width, height, text, options)`
19-
* `fileAnnotation(x, y, width, height, file, options)`
9+
- `note(x, y, width, height, contents, options)`
10+
- `link(x, y, width, height, url, options)`
11+
- `goTo(x, y, w, h, name, options)`
12+
- `highlight(x, y, width, height, options)`
13+
- `underline(x, y, width, height, options)`
14+
- `strike(x, y, width, height, options)`
15+
- `lineAnnotation(x1, y1, x2, y2, options)`
16+
- `rectAnnotation(x, y, width, height, options)`
17+
- `ellipseAnnotation(x, y, width, height, options)`
18+
- `textAnnotation(x, y, width, height, text, options)`
19+
- `fileAnnotation(x, y, width, height, file, options)`
2020

2121
Many of the annotations have a `color` option that you can specify. You can
2222
use an array of RGB values, a hex color, a named CSS color value, or a named
@@ -39,7 +39,7 @@ more than one annotation on a single area and one of those annotations is a
3939
link, make sure that the link is the last one you add, otherwise it will be
4040
covered by another annotation and the user won't be able to click it.
4141

42-
* * *
42+
---
4343

4444
Here is an example that uses a few of the annotation types.
4545

@@ -89,7 +89,7 @@ The output of this example looks like this.
8989
Annotations are currently not the easiest things to add to PDF documents, but
9090
that is the fault of the PDF spec itself. Calculating a rectangle manually isn't
9191
fun, but PDFKit makes it easier for a few common annotations applied to text, including
92-
links, underlines, and strikes. Here's an example showing two of them:
92+
links, underlines, and strikes. Here's an example showing two of them:
9393

9494
doc.fontSize(20)
9595
.fillColor('red')

docs/attachments.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ When embedding a data URL, the `type` option will be set to the data URL's MIME
1818

1919
There are a few other options for `doc.file`:
2020

21-
* `name` - specify the embedded file's name
22-
* `type` - specify the embedded file's subtype as a [MIME-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)
23-
* `description` - add descriptive text for the embedded file
24-
* `hidden` - if true, do not show file in the list of embedded files
25-
* `creationDate` - override the date and time the file was created
26-
* `modifiedDate` - override the date and time the file was last updated
27-
* `relationship` - relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
21+
- `name` - specify the embedded file's name
22+
- `type` - specify the embedded file's subtype as a [MIME-Type](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types)
23+
- `description` - add descriptive text for the embedded file
24+
- `hidden` - if true, do not show file in the list of embedded files
25+
- `creationDate` - override the date and time the file was created
26+
- `modifiedDate` - override the date and time the file was last updated
27+
- `relationship` - relationship between the PDF document and its attached file. Can be 'Alternative', 'Data', 'Source', 'Supplement' or 'Unspecified'.
2828

2929
If you are attaching a file from your file system, creationDate and modifiedDate will be set to the source file's creationDate and modifiedDate.
3030

docs/destinations.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ Examples of creating anchor:
1616
// Insert anchor for this text
1717
doc.text('End of paragraph', { destination: 'ENDP' });
1818

19-
2019
Examples of go to link to anchor:
2120

2221
// Go to annotation
2322
doc.goTo(10, 10, 100, 20, 'LINK')
2423

2524
// Go to annotation for this text
2625
doc.text('Another goto', 20, 0, {
27-
goTo: 'ENDP',
28-
underline: true
29-
});
26+
27+
goTo: 'ENDP',
28+
underline: true
29+
});

0 commit comments

Comments
 (0)