As of version 5.18.0, amCharts 5 now ships with pdfmake 0.3. If you are using getPdfmake() to obtain a pdfmake instance and calling its API directly, you will need to update your code.
The pdfmake document structure does not change. If you are using the pdfdocready event to modify only the document contents, the version change has not effect.
Callbacks replaced with promises
The most common breaking change. All document methods that previously accepted a callback now return a Promise instead.
Before (0.2):
exporting.getPdfmake().then(function(pdfmake) {
pdfmake.createPdf(docDefinition).getBuffer(function(buffer) {
// use buffer
});
});
exporting.getPdfmake().then(function(pdfmake) {
pdfmake.createPdf(docDefinition).getBuffer(function(buffer) {
// use buffer
});
});
After (0.3):
const pdfmake = await exporting.getPdfmake(); const buffer = await pdfmake.createPdf(docDefinition).getBuffer();
const pdfmake = await exporting.getPdfmake(); const buffer = await pdfmake.createPdf(docDefinition).getBuffer();
This applies to getBuffer(), getBase64(), getBlob(), getDataUrl(), download(), open(), and print().
Virtual file system registration
Font data is no longer passed to createPdf(). It must be registered upfront on the pdfmake instance.
Before (0.2):
pdfmake.createPdf(docDefinition, null, fonts, vfs);
pdfmake.createPdf(docDefinition, null, fonts, vfs);
After (0.3):
pdfmake.addVirtualFileSystem(vfs); pdfmake.addFonts(fonts); pdfmake.createPdf(docDefinition);
pdfmake.addVirtualFileSystem(vfs); pdfmake.addFonts(fonts); pdfmake.createPdf(docDefinition);
Function signature changes
The pageBreakBefore callback receives a different argument shape in 0.3. Refer to the pdfmake 0.3 documentation for the updated signature.
Internet Explorer 11 no longer supported
pdfmake 0.3 dropped IE11 support. If your user base includes IE11, do not upgrade.