Constructor
new PDFBuilder(options)
Parameters:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object | The options used to build the PDF Properties
|
- Source:
Methods
addHeading(text)
Add a heading to the PDF document.
Parameters:
Name | Type | Description |
---|---|---|
text |
string | The heading to add |
- Source:
addPage()
Add a new page to the PDF document.
- Source:
addPageIfNeeded(currentPage, pageCount) → {boolean}
Adds a new page to the PDF document if close to the end of the content area.
Parameters:
Name | Type | Description |
---|---|---|
currentPage |
number | The current page of the document |
pageCount |
number | The number of pages |
- Source:
Returns:
Was a new page added
- Type
- boolean
addSubHeading(text)
Add a sub heading to the PDF document.
Parameters:
Name | Type | Description |
---|---|---|
text |
String | The subheading text to add |
- Source:
addTable(table)
Add a table to the PDF document.
Parameters:
Name | Type | Description |
---|---|---|
table |
PDFTable | The table to add to the PDF |
- Source:
contentHeight() → {number}
Returns the height of the page inside the page margins.
- Source:
Returns:
- Type
- number
contentWidth() → {number}
Returns the width of the page inside the page margins.
- Source:
Returns:
The width of the page inside the page margins
- Type
- number
generateBlob() → {Promise}
Closes the document and generates blob URL that can be saved to disk.
- Source:
Returns:
Resolves when the PDF has been generated
- Type
- Promise
Example
let pdfBuilder = new PDFBuilder();
let saveAs = require('file-saver');
pdfBuilder.generateBlob().then(function(blob) {
saveAs(blob, 'document.pdf');
});
generateBlobURL() → {Promise}
Closes the document and generates blob URL that can be loaded by a web browser.
- Source:
Returns:
Resolves when the PDF Url has been generated
- Type
- Promise
Example
let pdfBuilder = new PDFBuilder();
pdfBuilder.generateBlobURL().then(function(url) {
$('iframe')[0].src = url;
});
pageLeft() → {number}
Returns the position of the left edge of the page based on left margin.
- Source:
Returns:
The position of the left edge of the page
- Type
- number
pageRight() → {number}
Returns the position of the right edge of the page based on the width and right margin.
- Source:
Returns:
The position of the right edge of the page
- Type
- number
resetPosition()
Sets the current print position to the top-left of the document + margins.
- Source: