1.0.0 • Published 3 years ago

china_vfs_fonts_msyh v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
3 years ago

安装

npm i china_vfs_fonts_msyh --save

需求

需要下载pdf,pdfmake中只有英文字体,自制中文字体包,可直接使用。

使用方法

// 在angular8中使用方法
import * as pdfMake from 'pdfmake/build/pdfmake';
import * as pdfFonts from 'china_vfs_fonts_msyh'; // 中文字体包

    // pdf内容
    public pdfCon = {
        content: [
            { text: 'pdf的标题 \n\n' ,font:'msyh'},
            { text: '报告日期:2021-9-10          团队名称:法警队房间爱对 \n\n',font:'msyh' },
        ],
    }

    pdfmakes() {
        pdfMake.vfs = pdfFonts.pdfMake.vfs;
        pdfMake.fonts = {
            msyh: {
                normal: 'msyh.ttf',
                bold: 'msyh.ttf',
                italics: 'msyh.ttf',
                bolditalics: 'msyh.ttf',
            }
        };
        var dd = this.pdfCon;
        pdfMake.createPdf(dd).download();
    }