Skip to content

Commit

Permalink
docs: improve documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
schoero committed Nov 9, 2023
1 parent bfdce8d commit 8e02f41
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 106 deletions.
94 changes: 60 additions & 34 deletions docs/bundle/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
- [formatIBAN(iban)](#function-utilsformatibaniban)
- [isQRReference(reference)](#function-utilsisqrreferencereference)
- [isQRReferenceValid(reference)](#function-utilsisqrreferencevalidreference)
- [isSCORReference(reference)](#function-utilsisscorreferencereference)
- [isSCORReference(reference)](#class-pdftable)
- [isSCORReferenceValid(reference)](#function-utilsisscorreferencevalidreference)
- [calculateSCORReferenceChecksum(reference)](#function-utilscalculatescorreferencechecksumreference)
- [calculateQRReferenceChecksum(reference)](#function-utilscalculateqrreferencechecksumreference)
Expand Down Expand Up @@ -125,7 +125,7 @@ Defined in: [src/bundle/index.ts](../../src/bundle/index.ts#L2C7)

#### Class: pdf.SwissQRBill

Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L48C0)
Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L49C0)

##### Description

Expand Down Expand Up @@ -172,7 +172,7 @@ pdf.end();

##### Constructor: new pdf.SwissQRBill(data\[, options\])

Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L65C2)
Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L67C2)

###### Parameters

Expand All @@ -183,6 +183,10 @@ Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L65C2)

[`SwissQRBill`](#class-pdfswissqrbill)

###### Throws

- [`ValidationError`](#class-errorsvalidationerror) Throws an error if the data is invalid.

###### Description

Creates a new SwissQRBill instance.
Expand Down Expand Up @@ -239,8 +243,8 @@ Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L103C2)

###### Description

Adds the QR Bill to the bottom of the current page if there is enough space,
otherwise it will create a new page for the QR Bill.
Attaches the QR-Bill to a PDFKit document instance. It will create a new page with the size of the QR-Slip if not
enough space is left on the current page.

<br/>

Expand Down Expand Up @@ -268,13 +272,13 @@ Checks whether there is enough space on the current page to add the QR Bill.

#### Class: pdf.SwissQRCode

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L7C0)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L10C0)

<br/>

##### Constructor: new pdf.SwissQRCode(data\[, size\])

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L17C2)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L21C2)

###### Parameters

Expand All @@ -285,6 +289,10 @@ Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L17C2)

[`SwissQRCode`](#class-pdfswissqrcode)

###### Throws

- [`ValidationError`](#class-errorsvalidationerror) Throws an error if the data is invalid.

###### Description

Creates a Swiss QR Code.
Expand All @@ -295,7 +303,7 @@ Creates a Swiss QR Code.

`public`

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L29C2)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L34C2)

###### Parameters

Expand Down Expand Up @@ -462,30 +470,17 @@ Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L62C0)

#### Class: pdf.Table

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L97C0)

<br/>

##### Constructor: new pdf.Table(data)

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L133C2)
Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L138C0)

###### Parameter

- **data** [`PDFTable`](#interface-pdfpdftable) An Object which contains the table information.

###### Return Type

[`Table`](#class-pdftable) The Table instance.

###### Description
##### Description

Inserts a table to the document.
The Table class is used to create tables for PDFKit documents. A table can be attached to any PDFKit document instance
using the [`attachTo`](#method-pdftableattachtodoc-x-y) method.

###### Example
##### Example

```ts
const table = {
const tableData = {
rows: [
{
backgroundColor: "#ECF0F1",
Expand All @@ -511,15 +506,41 @@ const table = {
}
]
};
const pdf = new PDFDocument();
const table = new Table(tableData);

const stream = createWriteStream("table.pdf");

table.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
```

<br/>

##### Constructor: new pdf.Table(data)

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L145C2)

###### Parameter

- **data** [`PDFTable`](#interface-pdfpdftable) The rows and columns for the table.

###### Return Type

[`Table`](#class-pdftable) The Table instance.

###### Description

Creates a new Table instance.

<br/>

##### Method: pdf.Table.attachTo(doc\[, x\]\[, y\])

`public`

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L156C2)
Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L169C2)

###### Parameters

Expand All @@ -537,7 +558,8 @@ Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L156C2)

###### Description

Attaches the table to a PDFKit document instance.
Attaches the table to a PDFKit document instance beginning on the current page. It will create a new page with for
every row that no longer fits on a page.

<br/>

Expand Down Expand Up @@ -648,13 +670,13 @@ Returns the SVG element.

#### Class: svg.SwissQRCode

Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L8C0)
Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L9C0)

<br/>

##### Constructor: new svg.SwissQRCode(data\[, size\])

Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L17C2)
Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L19C2)

###### Parameters

Expand All @@ -665,6 +687,10 @@ Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L17C2)

[`SwissQRCode`](#class-svgswissqrcode)

###### Throws

- [`ValidationError`](#class-errorsvalidationerror) Throws an error if the data is invalid.

###### Description

Creates a Swiss QR Code.
Expand All @@ -675,7 +701,7 @@ Creates a Swiss QR Code.

`public`

Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L10C2)
Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L11C2)

###### Type

Expand All @@ -687,7 +713,7 @@ Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L10C2)

`public`

Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L53C2)
Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L55C2)

###### Return Type

Expand All @@ -703,7 +729,7 @@ Outputs the SVG as a string.

`public`

Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L62C2)
Defined in: [src/svg/swissqrcode.ts](../../src/svg/swissqrcode.ts#L64C2)

###### Return Type

Expand Down
78 changes: 50 additions & 28 deletions docs/pdf/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@

### Class: SwissQRBill

Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L48C0)
Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L49C0)

#### Description

Expand Down Expand Up @@ -87,7 +87,7 @@ pdf.end();

#### Constructor: new SwissQRBill(data\[, options\])

Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L65C2)
Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L67C2)

##### Parameters

Expand All @@ -98,6 +98,10 @@ Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L65C2)

[`SwissQRBill`](#class-swissqrbill)

##### Throws

- `ValidationError` Throws an error if the data is invalid.

##### Description

Creates a new SwissQRBill instance.
Expand Down Expand Up @@ -154,8 +158,8 @@ Defined in: [src/pdf/swissqrbill.ts](../../src/pdf/swissqrbill.ts#L103C2)

##### Description

Adds the QR Bill to the bottom of the current page if there is enough space,
otherwise it will create a new page for the QR Bill.
Attaches the QR-Bill to a PDFKit document instance. It will create a new page with the size of the QR-Slip if not
enough space is left on the current page.

<br/>

Expand Down Expand Up @@ -183,13 +187,13 @@ Checks whether there is enough space on the current page to add the QR Bill.

### Class: SwissQRCode

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L7C0)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L10C0)

<br/>

#### Constructor: new SwissQRCode(data\[, size\])

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L17C2)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L21C2)

##### Parameters

Expand All @@ -200,6 +204,10 @@ Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L17C2)

[`SwissQRCode`](#class-swissqrcode)

##### Throws

- `ValidationError` Throws an error if the data is invalid.

##### Description

Creates a Swiss QR Code.
Expand All @@ -210,7 +218,7 @@ Creates a Swiss QR Code.

`public`

Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L29C2)
Defined in: [src/pdf/swissqrcode.ts](../../src/pdf/swissqrcode.ts#L34C2)

##### Parameters

Expand All @@ -230,30 +238,17 @@ Attaches the Swiss QR Code to a PDF document.

### Class: Table

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L97C0)

<br/>

#### Constructor: new Table(data)

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L133C2)

##### Parameter

- **data** [`PDFTable`](#interface-pdftable) An Object which contains the table information.

##### Return Type

[`Table`](#class-table) The Table instance.
Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L138C0)

##### Description
#### Description

Inserts a table to the document.
The Table class is used to create tables for PDFKit documents. A table can be attached to any PDFKit document instance
using the [`attachTo`](#method-tableattachtodoc-x-y) method.

##### Example
#### Example

```ts
const table = {
const tableData = {
rows: [
{
backgroundColor: "#ECF0F1",
Expand All @@ -279,15 +274,41 @@ const table = {
}
]
};
const pdf = new PDFDocument();
const table = new Table(tableData);

const stream = createWriteStream("table.pdf");

table.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
```

<br/>

#### Constructor: new Table(data)

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L145C2)

##### Parameter

- **data** [`PDFTable`](#interface-pdftable) The rows and columns for the table.

##### Return Type

[`Table`](#class-table) The Table instance.

##### Description

Creates a new Table instance.

<br/>

#### Method: Table.attachTo(doc\[, x\]\[, y\])

`public`

Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L156C2)
Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L169C2)

##### Parameters

Expand All @@ -305,7 +326,8 @@ Defined in: [src/pdf/table.ts](../../src/pdf/table.ts#L156C2)

##### Description

Attaches the table to a PDFKit document instance.
Attaches the table to a PDFKit document instance beginning on the current page. It will create a new page with for
every row that no longer fits on a page.

<br/>

Expand Down
Loading

0 comments on commit 8e02f41

Please sign in to comment.