pdfmake-chinese
v0.0.8
Published
pdfmake with chinese fonts
Downloads
23
Readme
PDFMake Chinese
Getting Started
pdfmake is library for PDF printing in pure JavaScript.
By default pdfmake uses Roboto font, which does not support Chinese characters.
This package is an extension for adding Chinese character support. It comes with a 方正黑体简体 font, which has 4 styles: Regular, Bold, Italic and Bold Italic.
Installation
Install with NPM:
$ npm install pdfmake-chinese --save
Install with Yarn:
$ yarn add pdfmake-chinese
Install with Bower:
$ bower install pdfmake-chinese --save
Usage
<script src="pdfmake.min.js"></script>
<script src="vfs_fonts.js"></script>
<script>
var docDefinition = { content: '我支持中文啦' };
pdfMake.fonts = {
方正黑体简体: {
normal: '方正黑体简体.TTF',
bold: '方正黑体简体.TTF',
italics: '方正黑体简体.TTF',
bolditalics: '方正黑体简体.TTF',
}
};
defaultStyle: {
font: '方正黑体简体'
}
};
pdfMake.createPdf(docDefinition).download('filename.pdf');
</script>
Use with ES6
import pdfMake from 'pdfmake-chinese/pdfmake';
import pdfFonts from 'pdfmake-chinese/vfs_fonts';
pdfMake.vfs = pdfFonts.pdfMake.vfs;
var docDefinition = { content: '我支持中文啦' };
pdfMake.fonts = {
Roboto: {
normal: 'fonts/Roboto-Regular.ttf',
bold: 'fonts/Roboto-Medium.ttf',
italics: 'fonts/Roboto-Italic.ttf',
bolditalics: 'fonts/Roboto-MediumItalic.ttf'
},
方正黑体简体: {
normal: '方正黑体简体.TTF',
bold: '方正黑体简体.TTF',
italics: '方正黑体简体.TTF',
bolditalics: '方正黑体简体.TTF',
}
};
defaultStyle: {
font: '方正黑体简体'
}
};
pdfMake.createPdf(docDefinition).download('filename.pdf');
Supported Languages
- Chinese