Releases: bpampuch/pdfmake
0.1.22
Features:
- update to PDFKit v0.8.0 with fontkit (support otf and woff font formats)
- update all dependencies and uplift code to work with latest package versions
- added yarn support
- allow to specify CreationDate property
- compression is enabled by default. Can be disabled by
compress: false
- watermark formatting/styling
- border for table cells
- gulp: added the ability to create virtual file system for fonts. Command:
gulp buildFonts
- added parameter
pageSize
toheader
function
Bugfixes:
- fixed print and open for large files
- fixed links support
- fixed building on Windows
- don't add up the images horizontal offset
- catch malformed table row error
- validate text before replacing
- fixed tables bug with header border lines on new pages being repeated several times
- fixed check of browser support, no more being annoyed while building too
- update FileSaver.js submodule to latest master, this should fix problems with using pdfmake on iOS devices
- fixed a problem with the performance for large documents
- and other fixes...
Watermark formatting
example with own format:
var docDefinition = {
...
watermark: {text: 'test watermark', color: 'blue', opacity: 0.3, font: 'Courier', bold: true, italics: true},
...
};
example without formatting:
watermark: 'test watermark'
Border for table cells
example of table cell:
{
// (left border, top border, right border, bottom border)
border: [false, true, false, false],
text: 'text in table cell'
}
New parameter pageSize
in header function
var docDefinition = {
footer: function(currentPage, pageCount) { return currentPage.toString() + ' of ' + pageCount; },
header: function(currentPage, pageCount, pageSize) {
// you can apply any logic and return any valid pdfmake element
return [
{ text: 'simple text', alignment: (currentPage % 2) ? 'left' : 'right' },
{ canvas: [ { type: 'rect', x: 170, y: 32, w: pageSize.width - 170, h: 40 } ] }
]
},
(...)
};
0.1.17
Features:
- Introduce new styling properties marginLeft, marginRight, marginTop, and marginBottom.
- Add the capability to have switch of page orientation per page.
- Adds an editorconfig.
- Adding possibility to specify line height.
- Access to internal pages array, to have better testing capabilities.
- Dynamically control page breaks, for instance to avoid orphan childs.
Bug Fixes:
- Add the type to the font name for pdfkit. This is to avoid using the same type (normal, bold, italics, bolditalics) every time a font is requested. Fixes #162.
- Use function for vLineColor if provided on table layout. Fixes #166.
Introduce new styling properties marginLeft, marginRight, marginTop, and marginBottom.
An element in the document definition can now specify margin on any side individually. This allows to combine margins from different styles.
{
content: [
{text: 'text with style 1', style: ['style1']},
{text: 'text with style 2', style: ['style2']},
{text: 'text with both styles', style: ['style1', 'style2']}
],
styles: {
style1: {
marginTop: 30
},
style2: {
marginLeft: 20
}
}
}
Add the capability to have switch of page orientation per page.
This allows a document to switch between landscape and portrait in a document.
{
pageOrientation: 'portrait',
content: [
{text: 'Text on Portrait'},
{text: 'Text on Landscape', pageOrientation: 'landscape', pageBreak: 'before'},
{text: 'Text on Landscape 2', pageOrientation: 'portrait', pageBreak: 'after'},
{text: 'Text on Portrait 2'},
]
}
Important you need to specify a page break on the same node, to make sure the page can switch it's orientation.
Adds an editorconfig.
An .editorconfig
file makes sure that coding conventions, especially whitespaces, are kept within each editor.
Adding possibility to specify line height.
A new style property lineHeight
is now available.
{
content: [{text: 'this is a very long text', lineHeight: 1.5}]
}
lineHeight
is a relative value.
Access to internal pages array, to have better testing capabilities.
This allows writing integration test agains a array of pages in PDF Make.
pdfMake.createPdf(docDefinition)._getPages({}, function(pages){
assert.equal(pages.length, 2);
});
Dynamically control page breaks, for instance to avoid orphan childs.
You can now specify a pageBreakBefore
function, which can determine if a page break should be inserted before the page break. To implement a 'no orphan child' rule, this could like like this:
var dd = {
content: [
{text: '1 Headline', headlineLevel: 1},
'Some long text of variable length ...',
{text: '2 Headline', headlineLevel: 1},
'Some long text of variable length ...',
{text: '3 Headline', headlineLevel: 1},
'Some long text of variable length ...',
],
pageBreakBefore: function(currentNode, followingNodesOnPage, nodesOnNextPage, previousNodesOnPage) {
return currentNode.headlineLevel === 1 && followingNodesOnPage.length === 0;
}
}
If pageBreakBefore
returns true, a page break will be added before the currentNode
. Current node has the following information attached:
{
id: '<as specified in doc definition>',
headlineLevel: '<as specified in doc definition>',
text: '<as specified in doc definition>',
ul: '<as specified in doc definition>',
ol: '<as specified in doc definition>',
table: '<as specified in doc definition>',
image: '<as specified in doc definition>',
qr: '<as specified in doc definition>',
canvas: '<as specified in doc definition>',
columns: '<as specified in doc definition>',
style: '<as specified in doc definition>',
pageOrientation '<as specified in doc definition>',
pageNumbers: [2, 3], // The pages this element is visible on (e.g. multi-line text could be on more than one page)
pages: 6, // the total number of pages of this document
stack: false, // if this is an element which encapsulates multiple sub-objects
startPosition: {
pageNumber: 2, // the page this node starts on
pageOrientation: 'landscape', // the orientation of this page
left: 60, // the left position
right: 60, // the right position
verticalRatio: 0.2, // the ratio of space used vertically in this document (excluding margins)
horizontalRatio: 0.0 // the ratio of space used horizontally in this document (excluding margins)
}
}