admin管理员组文章数量:1435859
Is there some way to stretch tables in jsdpdf-autotable package? My use case - I am making a generic pdf table downloader which generates a pdf downloader based on table structure. Currently, I am facing an issue with different table sizes.
If one table has 6 columns, the table is displayed corner to corner, but if a table has few columns, it only takes half or even lesser page size which leads to inconsistent pdf layouts.
So for that case, I am thinking of stretching all tables to a width of 100%.
I tried using margin: {left:0,right:0}
and tableWidth:'auto'
but to no avail :(
Any attribute I am missing?
PS: This is the autoTable
block
doc.autoTable(headings, data, {
theme: "grid",
tableWidth: 200,
margin: {right:0,left:0},
tableWidth: 'auto',
styles: {
fontSize: fontSize,
columnWidth: "wrap"
},
headerStyles: { fillColor: 120, textColor: 255, halign: "center" },
columnStyles: {
id: { fillColor: 255 }
},
Is there some way to stretch tables in jsdpdf-autotable package? My use case - I am making a generic pdf table downloader which generates a pdf downloader based on table structure. Currently, I am facing an issue with different table sizes.
If one table has 6 columns, the table is displayed corner to corner, but if a table has few columns, it only takes half or even lesser page size which leads to inconsistent pdf layouts.
So for that case, I am thinking of stretching all tables to a width of 100%.
I tried using margin: {left:0,right:0}
and tableWidth:'auto'
but to no avail :(
Any attribute I am missing?
PS: This is the autoTable
block
doc.autoTable(headings, data, {
theme: "grid",
tableWidth: 200,
margin: {right:0,left:0},
tableWidth: 'auto',
styles: {
fontSize: fontSize,
columnWidth: "wrap"
},
headerStyles: { fillColor: 120, textColor: 255, halign: "center" },
columnStyles: {
id: { fillColor: 255 }
},
Share
Improve this question
edited Jul 27, 2018 at 10:59
Aseem Upadhyay
asked Jul 27, 2018 at 9:48
Aseem UpadhyayAseem Upadhyay
4,5574 gold badges17 silver badges36 bronze badges
2 Answers
Reset to default 2The tableWidth: 'auto'
should work and since that is the default you can also simply omit it. Otherwise it is a bug which you can report in the github repo. Be sure to include a plete example of the problem.
You just need to set the tableWidth to the size of your page and set the left margin to 0
see this
autoTable(doc, {
head: headers,
body: data,
startY: 80,
showHead: "never",
showFoot: "never",
// this two properties
tableWidth: doc.internal.pageSize.getWidth(),
margin: { left: 0 },
});
本文标签: javascriptStretch table to full width jsPDF AutotableStack Overflow
版权声明:本文标题:javascript - Stretch table to full width jsPDF Autotable - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744519104a2610347.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论