-
Classes
-
- Constructor
- Properties
- Methods
-
- Constructor
- Method
-
- Constructor
- Method
-
Defined in: src/pdf/swissqrbill.ts
The SwissQRBill class creates the Payment Part with the QR Code. It can be attached to any PDFKit document instance
using the attachTo
method.
const data = {
amount: 1994.75,
creditor: {
account: "CH44 3199 9123 0008 8901 2",
address: "Musterstrasse",
buildingNumber: 7,
city: "Musterstadt",
country: "CH",
name: "SwissQRBill",
zip: 1234
},
currency: "CHF",
debtor: {
address: "Musterstrasse",
buildingNumber: 1,
city: "Musterstadt",
country: "CH",
name: "Peter Muster",
zip: 1234
},
reference: "21 00000 00003 13947 14300 09017"
};
const pdf = new PDFDocument({ autoFirstPage: false });
const qrBill = new SwissQRBill(data);
const stream = createWriteStream("qr-bill.pdf");
qrBill.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
Defined in: src/pdf/swissqrbill.ts
- data
Data
The data to be used for the QR Bill. - options
PDFOptions
Options to define how the QR Bill should be rendered.optional
ValidationError
Throws an error if the data is invalid.
Creates a new SwissQRBill instance.
public
static
readonly
Defined in: src/pdf/swissqrbill.ts
The horizontal size of the QR Bill.
public
static
readonly
Defined in: src/pdf/swissqrbill.ts
The vertical size of the QR Bill.
public
Defined in: src/pdf/swissqrbill.ts
- doc
PDFDocument
The PDFKit instance. - x
number
The horizontal position in points where the QR Bill will be placed.optional
Default:0
- y
number
The vertical position in points where the QR Bill will be placed.optional
Default:number
void
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.
public
static
Defined in: src/pdf/swissqrbill.ts
- doc
PDFDocument
The PDFKit document instance. - xPosition
number
The horizontal position where the QR Bill will be placed. - yPosition
number
The vertical position where the QR Bill will be placed.
boolean
true
if there is enough space, otherwise false
Checks whether there is enough space on the current page to add the QR Bill.
Defined in: src/pdf/swissqrcode.ts
Defined in: src/pdf/swissqrcode.ts
- data
Data
The data to be encoded in the QR code. - size
number
The size of the QR code in mm.optional
Default:46
ValidationError
Throws an error if the data is invalid.
Creates a Swiss QR Code.
public
Defined in: src/pdf/swissqrcode.ts
- doc
PDFDocument
The PDF document to attach the Swiss QR Code to. - x
number
The horizontal position in points where the Swiss QR Code will be placed.optional
Default:number
- y
number
The vertical position in points where the Swiss QR Code will be placed.optional
Default:number
void
Attaches the Swiss QR Code to a PDF document.
Defined in: src/pdf/table.ts
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.
const tableData = {
rows: [
{
backgroundColor: "#ECF0F1",
columns: [
{
text: "Row 1 cell 1"
}, {
text: "Row 1 cell 2"
}, {
text: "Row 1 cell 3"
}
]
}, {
columns: [
{
text: "Row 2 cell 1"
}, {
text: "Row 2 cell 2"
}, {
text: "Row 2 cell 3"
}
]
}
]
};
const pdf = new PDFDocument();
const table = new Table(tableData);
const stream = createWriteStream("table.pdf");
table.attachTo(pdf);
pdf.pipe(stream);
pdf.end();
Defined in: src/pdf/table.ts
- data
PDFTable
The rows and columns for the table.
Table
The Table instance.
Creates a new Table instance.
public
Defined in: src/pdf/table.ts
- doc
PDFDocument
The PDFKit document instance. - x
number
The horizontal position in points where the table be placed.optional
Default:number
- y
number
The vertical position in points where the table will be placed.optional
Default:number
void
Error
Throws an error if no table rows are provided.
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.
Defined in: src/pdf/table.ts
union
-
tuple
-
tuple
Can be used to set the color of the border of a table, row or column.
Defined in: src/pdf/table.ts
union
-
tuple
-
tuple
Can be used to set the width of the border of a table, row or column.
Defined in: src/pdf/table.ts
union
-
tuple
-
tuple
Can be used to set the padding of a table cell.
Defined in: src/pdf/table.ts
-
rows
Array
Table rows. -
align
"center"
|"left"
|"right"
Horizontal alignment of texts inside the table.optional
-
backgroundColor
string
Background color of the table.optional
-
borderColor
PDFBorderColor
The colors of the border.optional
-
borderWidth
PDFBorderWidth
Width of the borders of the row.optional
-
fontName
string
Font of the text inside the table.optional
-
fontSize
number
Font size of the text inside the table.optional
-
padding
PDFPadding
Cell padding of the table cells.optional
-
textColor
string
Text color of texts inside table.optional
-
textOptions
TextOptions
Same as text PDFKit text options.optional
-
verticalAlign
"bottom"
|"center"
|"top"
Vertical alignment of texts inside the table.optional
-
width
number
Width of whole table.optional
Defined in: src/pdf/table.ts
-
columns
Array
Table columns. -
align
"center"
|"left"
|"right"
Horizontal alignment of texts inside the row.optional
-
backgroundColor
string
Background color of the row.optional
-
borderColor
PDFBorderColor
The colors of the border.optional
-
borderWidth
PDFBorderWidth
Width of the borders of the row.optional
-
fontName
string
Font of the text inside the row.optional
-
fontSize
number
Font size of the text inside the row.optional
-
header
boolean
A header row gets inserted automatically on new pages. Only one header row is allowed.optional
-
height
number
Height of the row. Overrides minHeight and maxHeight.optional
-
maxHeight
number
Maximum height of the row.optional
-
minHeight
number
Minimum height of the row.optional
-
padding
PDFPadding
Cell padding of the table cells inside the row.optional
-
textColor
string
Text color of texts inside the row.optional
-
textOptions
TextOptions
Same as text PDFKit text options.optional
-
verticalAlign
"bottom"
|"center"
|"top"
Vertical alignment of texts inside the row.optional
Defined in: src/pdf/table.ts
- text
boolean
|number
|string
Cell text. - align
"center"
|"left"
|"right"
Horizontal alignment of the text inside the cell.optional
- backgroundColor
string
Background color of the cell.optional
- borderColor
PDFBorderColor
The colors of the border.optional
- borderWidth
PDFBorderWidth
Width of the borders of the row.optional
- fontName
string
Font of the text inside the cell.optional
- fontSize
number
Font size of the text inside the cell.optional
- padding
PDFPadding
Cell padding of the table cell.optional
- textColor
string
Text color of texts inside the cell.optional
- textOptions
TextOptions
Same as text PDFKit text options.optional
- verticalAlign
"bottom"
|"center"
|"top"
Vertical alignment of the text inside the cell.optional
- width
number
Width of the cell.optional