【问题标题】:jspdf-autotable text word breakjspdf-自动文本分词
【发布时间】:2023-10-02 05:31:01
【问题描述】:

我遇到了列标题文本和行文本在单词中间不正确中断的问题(见附件)。在附件中,我预计“长文本列”会受到更多挤压,这将增加其他列的宽度并增加行的高度。

我使用的代码是:

public exportToPDF(reportName: string, cols: any, rows: any) {
        var doc = new jsPDF('landscape');        
        doc.text(15, 40, "Report");
        var options = {            
            margin: { horizontal: 5 },
            bodyStyles: { valign: 'top' },
            styles: { overflow: 'linebreak', overflowColumns: false },
            headerStyles: {
                fillColor: [51, 122, 183],
                textColor: [255],
                halign: 'center'
            },            
            theme: 'grid'
        };
        doc.autoTable(cols, rows, options);
        doc.save('Report.pdf');
    }

感谢您的帮助。

【问题讨论】:

  • 我的桌子上有同样的问题。我有一个大文本列,它的扩展方式与您的图片相同。我可以这样解决:*.com/questions/38787437/…

标签: jspdf jspdf-autotable


【解决方案1】:
columnWidth: 'wrap',
columnStyles:{
    0: {
        columnWidth: '100'
    },
    1: {
        columnWidth: '100'
    }, 
    2: {
        columnWidth:'100'
    },
    3: {
        columnWidth: '150'
    },
    4: {
        columnWidth: '100'
    }
}

将以上行添加到选项对象中。

【讨论】:

    【解决方案2】:

    查看issue中的解决方案

    【讨论】: