-
-
Notifications
You must be signed in to change notification settings - Fork 615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
jsPDF autoTable columnWidth wrap cuts table off #306
Comments
I can't replicate the issue. Can you create a runnable example with data included? |
@simonbengtsson Hi! Big fan of the library. I also am struggling with this, even when I copy your code directly from the "long" example. My text just continues off the screen and pushes the columns to the left of it off the page with it. Is there a solution? |
This is the code that I am attempting to execute: function generatePdf(cols, rows, name, headerText) {
// Only pt supported (not mm or in)
var doc = new jsPDF('p', 'pt');
var totalPagesExp = "{total_pages_count_string}";
var leftMargin = 40;
doc.setFontSize(10);
doc.autoTable(cols, rows, {
theme: "grid",
margin: {horizontal: 7},
bodyStyles: {valign: 'top'},
styles: {overflow: 'linebreak', columnWidth: 'wrap'},
addPageContent: function(data) {
doc.text(headerText, leftMargin, 30);
var str = "Page " + data.pageCount;
// Total page number plugin only available in jspdf v1.0+
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp;
}
str = str + ". Generated on " + Date();
doc.text(str, leftMargin, doc.internal.pageSize.height - 10);
}
});
// Total page number plugin only available in jspdf v1.0+
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
}
doc.save(name);
} This is a picture of the outputted PDF: |
Hello, I also tested with custom columnWidth but it doesn't work. |
Unfortunately not :( |
The solution of custom widths it works, but you have to put the width between '' columnStyles: { |
Can you share the full code? |
In theory..
But in real, longColumnName is very long, and the other columns are very thin (a few characters wide). |
Ah interesting. Ok, please post again if you find the reason :) Thanks for your work on this! |
The code looks for numbers, it was enough to remove the ''. |
Should add a warning if a string is provided! |
I am using jsPDF to generate a PDF from an HTML table and jsPDF is great, expect I am having one issue, when I try to wrap the columnWidth, my table gets cut off :(
Is there a solution for this?
The text was updated successfully, but these errors were encountered: