Standard 14 fonts
Version 0.3 is under development. Do not use in a production.
Documentation is under development.
PDF contains standard 14 fonts.
Attention! This fonts supports only ANSI code page (only english characters)!
Use in pdfmake on server-side
Example of usage:
var fonts = {
Courier: {
normal: 'Courier',
bold: 'Courier-Bold',
italics: 'Courier-Oblique',
bolditalics: 'Courier-BoldOblique'
},
Helvetica: {
normal: 'Helvetica',
bold: 'Helvetica-Bold',
italics: 'Helvetica-Oblique',
bolditalics: 'Helvetica-BoldOblique'
},
Times: {
normal: 'Times-Roman',
bold: 'Times-Bold',
italics: 'Times-Italic',
bolditalics: 'Times-BoldItalic'
},
Symbol: {
normal: 'Symbol'
},
ZapfDingbats: {
normal: 'ZapfDingbats'
}
};
var pdfmake = require('pdfmake');
pdfmake.addFonts(fonts);
var docDefinition = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
],
defaultStyle: {
font: 'Helvetica'
}
};
var pdf = pdfmake.createPdf(docDefinition);
pdf.write('pdfs/basics.pdf').then(() => {
// success event
}, err => {
console.error(err);
});
Use in pdfmake on client-side
Is not supported by default, because this increase size of pdfmake library file about 700 kB.
If you really need it, you can build with standard fonts by gulp buildWithStandardFonts
command.
Building with standard fonts from sources:
git clone https://github.com/bpampuch/pdfmake.git
cd pdfmake
npm install
gulp buildWithStandardFonts
Example of usage:
pdfMake.fonts = {
Courier: {
normal: 'Courier',
bold: 'Courier-Bold',
italics: 'Courier-Oblique',
bolditalics: 'Courier-BoldOblique'
},
Helvetica: {
normal: 'Helvetica',
bold: 'Helvetica-Bold',
italics: 'Helvetica-Oblique',
bolditalics: 'Helvetica-BoldOblique'
},
Times: {
normal: 'Times-Roman',
bold: 'Times-Bold',
italics: 'Times-Italic',
bolditalics: 'Times-BoldItalic'
},
Symbol: {
normal: 'Symbol'
},
ZapfDingbats: {
normal: 'ZapfDingbats'
}
};
var docDefinition = {
content: [
'First paragraph',
'Another paragraph, this time a little bit longer to make sure, this line will be divided into at least two lines',
],
defaultStyle: {
font: 'Helvetica'
}
};
pdfMake.createPdf(docDefinition).download('document.pdf');