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文本内容显示不全 #322

Closed 123hyh closed 3 years ago

123hyh commented 3 years ago

引用JS

<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/pdfmake.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/gbsn00lp_fonts.js}"></script>
<!--<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/ZCOOLXiaoWei_fonts.js}"></script>-->
<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/gbsn00lp_fonts.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/jsPDF/jspdf.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/jsPDF-AutoTable/jspdf.plugin.autotable.js}"></script>

<script th:src="@{/ajax/libs/tableExport/libs/js-xlsx/xlsx.core.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/FileSaver/FileSaver.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/tableExport.js}"></script>

JS 调用

$('#previewTable').tableExport({
    fileName: pageQuery.fileName,
    type: 'pdf',
    jspdf: {
        orientation: 'l',
        format: 'a4',
        // margins: {left: 10, right: 10, top: 20, bottom: 20},
        margins: {left: 0, right: 0, top: 20, bottom: 20},
    },
    pdfmake: {
        enabled: true,
        docDefinition: {
            pageOrientation: 'landscape',
        }
    }
});

WEB 页面展示

image

导出的PDF

image

问题

您可以看到最后导出的PDF右侧文本未完全展示,请问这种情况应该如何设置 JS 调用参数 ?

感谢!

hhurz commented 3 years ago

Try the newest release 1.10.22. With this release you can also change the pageSize that pdfmake uses. You don't have to include the jspdf files, because you are using pdfmake as pdf producer.

<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/pdfmake.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/gbsn00lp_fonts.js}"></script>
<!--<script th:src="@{/ajax/libs/tableExport/libs/pdfmake/ZCOOLXiaoWei_fonts.js}"></script>-->

<script th:src="@{/ajax/libs/tableExport/libs/js-xlsx/xlsx.core.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/libs/FileSaver/FileSaver.min.js}"></script>
<script th:src="@{/ajax/libs/tableExport/tableExport.js}"></script>
$('#previewTable').tableExport({
    fileName: pageQuery.fileName,
    type: 'pdf',
    pdfmake: {
        enabled: true,
        docDefinition: {
            pageSize: 'A4', // 4A0,2A0,A{0-10},B{0-10},C{0-10},RA{0-4},SRA{0-4},EXECUTIVE,FOLIO,LEGAL,LETTER,TABLOID
            pageOrientation: 'landscape'
        }
    }
});
123hyh commented 3 years ago

已解决