DataTables & PDFmake

自闭症网瘾萝莉.ら 提交于 2019-12-05 09:35:24

You can access the PdfMake object when you declare the DataTables and change the font like this:

window.pdfMake.fonts = {
        alef: {
            normal: 'Alef-Bold.ttf',
            bold: 'Alef-Bold.ttf',
            italics: 'Alef-Bold.ttf"',
            bolditalics: 'Alef-Bold.ttf',
        }
    };

This code assigns the custom font Alef to be used. A font that I assigned as the vfs.

(See https://github.com/bpampuch/pdfmake/wiki/Custom-Fonts---client-side if you are interested in how to make this)

For other customizations what you need is the customize option in the Button.

See here: https://datatables.net/reference/button/pdfHtml5

Here is an example of how to initialize the new font in the DataTable

 $("table").DataTable({
            buttons: [
                {
                    extend: 'pdf', className: 'btn green btn-outline',  text: 'Export PDF',
                    customize: function (doc) {
                        doc.defaultStyle = 
                            {
                                font: 'alef'
                            }

                          }
                       } 
                   ]
               });
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!