Neanderthals Programming Machines

    pdfmake-support-chinese-fonts

    1.0.3 • Public • Published

    Support Chinese Fonts in PDFmake library.

    Getting Started

    1. support client/server side export PDF by pdfmake.js
    2. support pdf export with chinese fonts FangZhen
    3. limit the package size

    Install

    $ npm install pdfmake-support-chinese-fonts
    

    Usage

     
    import * as pdfMake from 'pdfmake-support-chinese-fonts/pdfmake.min';
    import * as pdfFonts from 'pdfmake-support-chinese-fonts/vfs_fonts';
     
    pdfMake.vfs = pdfFonts.pdfMake.vfs;
    pdfMake.fonts = {
      Roboto: {
        normal: 'Roboto-Regular.ttf',
        bold: 'Roboto-Regular.ttf',
        italics: 'Roboto-Regular.ttf',
        bolditalics: 'Roboto-Regular.ttf'
      },
      fangzhen: {
        normal: 'fzhei-jt.ttf',
        bold: 'fzhei-jt.ttf',
        italics: 'fzhei-jt.ttf',
        bolditalics: 'fzhei-jt.ttf'
      }
    };

    Then, to use it

    const docDefinition = {
        content: [
            "www测试",
            "测试2",
        ],
        defaultStyle: {
            font: 'fangzhen',
        }
    };
    pdfMake.createPdf(docDefinition);
     

    MIT License

    Install

    npm i pdfmake-support-chinese-fonts

    DownloadsWeekly Downloads

    85

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    5.18 MB

    Total Files

    5

    Last publish

    Collaborators

    • ricky_zlh