【问题标题】:how to convert html to pdf with specific font or language using pdfmake如何使用 pdfmake 将 html 转换为具有特定字体或语言的 pdf
【发布时间】:2016-12-03 08:51:11
【问题描述】:

这只是一个使用 pdfmake 的简单 html 文件。 我单击一个按钮,然后打开一个 pdf 文件。 使用:

pdfMake.createPdf(docDefinition).open();

没关系,但现在我想在我的 pdfpage 中查看特定语言(例如:Bangla)。怎么可能。请帮助或建议我。

标题部分:

<head>
    <!--    <meta charset="utf-8" />-->
    <meta http-equiv="Content-Type" content="text/html" meta charset="utf-8" />
    <title>html to pdf</title>
    <link href="css/main.css" rel="stylesheet">
    <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
    <script src='pdfmake/build/pdfmake.min.js'></script>
    <script src='pdfmake/build/vfs_fonts.js'></script>
    <script src='build/pdfmake.min.js'></script>
    <script src='build/vfs_fonts.js'></script>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css" integrity="sha384-fLW2N01lMqjakBkx3l/M9EahuwpSfeNvV63J5ezn3uZzapT0u7EYsXMjQV+0En5r" crossorigin="anonymous">
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>

</head>

正文部分:

<body>

    <h1>Hello World</h1>
    <div class="btn-group">
        <div class="btn btn-success buttin_click_1" type="button">download</div>
        <div class="btn btn-danger button_click_2" type="button">open</div>
    </div>

</body>

脚本:

<script>
    $(document).ready(function () {
        var docDefinition = {
            content: 'This is an sample PDF printed with pdfMake ami '
        };

        $('.buttin_click_1').click(function () {
            console.log('btn 1 clicked');
            pdfMake.createPdf(docDefinition).open();
        });

        $('.button_click_2').click(function () {
            console.log('btn 2 clicked');
        });
    });
</script>

谢谢。

【问题讨论】:

    标签: node.js html browserify mean-stack pdfmake


    【解决方案1】:
    1. 在 pdfMake 中导入字体
    2. 然后按照github 中的说明更新 vfs_fonts.js
    3. 在您的 javascript 中分配 pdfMake.fonts
    $(文档).ready(函数 () { pdfMake.fonts = { 'SolaimanLipi':{ 正常:'SolaimanLipi-Regular.ttf', 粗体:'SolaimanLipi-Medium.ttf' } }; 变量文档定义 = { 内容:'হ্যালো', 默认样式:{ 字体:'SolaimanLipi' } }; $('.buttin_click_1').click(function () { console.log('btn 1 clicked'); pdfMake.createPdf(docDefinition).open(); }); $('.button_click_2').click(function () { console.log('btn 2 clicked'); }); });

    【讨论】:

    • 兄弟我真的很难用数据表在孟加拉语中导出 PDF。 link
    猜你喜欢
    • 2016-06-22
    • 2019-11-25
    • 2019-07-27
    • 2012-11-05
    • 1970-01-01
    • 1970-01-01
    • 2016-08-20
    • 1970-01-01
    • 2018-03-05
    相关资源
    最近更新 更多