hhurz / tableExport.jquery.plugin

jQuery plugin to export a html table to JSON, XML, CSV, TSV, TXT, SQL, Word, Excel, PNG and PDF
MIT License
990 stars 716 forks source link

输出PDF内容乱码 #320

Closed learnku closed 3 years ago

learnku commented 3 years ago

引用文件


<script src="/ajax/libs/tableExport/tableExport.js"></script>
<script src="/ajax/libs/tableExport/libs/FileSaver/FileSaver.min.js"></script>
<script src="/ajax/libs/tableExport/libs/jsPDF/jspdf.min.js"></script>
<script src="/ajax/libs/tableExport/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js"></script>
<script src="/ajax/libs/tableExport/libs/js-xlsx/xlsx.core.min.js"></script>
<script src="/ajax/libs/tableExport/libs/pdfmake/vfs_fonts.js"></script>
<script src="/ajax/libs/tableExport/libs/pdfmake/ZCOOLXiaoWei_fonts.js"></script>

JS 调用

$("#download-pdf").click(function () {
            $('#previewTable').tableExport({
                fileName: pageQuery.fileName,
                type: 'pdf',
                jspdf: {
                    orientation: 'l',
                    format: 'a4',
                    margins: {left:10, right:10, top:20, bottom:20},
                    autotable: {
                        tableWidth: 'auto'
                    }
                },
                pdfmake:{
                    enabled:false,
                    docDefinition:{
                        pageOrientation:'landscape',
                        defaultStyle: {
                            font: 'ZCOOLXiaoWei'
                        }
                    }
                }
            })
        });

乱码截图

image

hhurz commented 3 years ago

There is an example file using pdfmake to export a chinese table. jspdf is currently not able to do that. In your source code snippet you disabled pdfmake.