Closed cometaRobertillo closed 9 years ago
Hi! Can you post the code you are using? Preferably a working example on codepen or similar that demonstrates the issue. Unfortunately I'm not sure I understand your problem
Sure, take a look
$scope.callJspdfAfterSubmitButton = function(){
var doc = new jsPDF('p', 'pt', 'letter');
var elementHandler = {
'#ignorePDF': function (element, renderer) {
return true;
}
};
var canvas = document.getElementsByClassName('canvasjs-chart-canvas');
document.getElementById('chartContainer').style.width = "550px"
$scope.chart.render();
var imgData = canvas[0].toDataURL("image/png", 1.0);
doc.addImage(imgData, 'PNG', 30, 15);
var totalPagesExp = "{total_pages_count_string}";
var footer = function (doc, lastCellPos, pageCount, options) {
var str = "Page " + pageCount;
// Total page number plugin only available in jspdf v1.0+
if (typeof doc.putTotalPages === 'function') {
str = str + " of " + totalPagesExp;
}
doc.text(str, options.margins.horizontal, doc.internal.pageSize.height - 30);
};
var options = {
renderFooter: footer,
startY: 315, // The start Y position on the first page. If set to false, top margin is used
overflow: 'linebreak' // false, ellipsize or linebreak (false passes the raw text to renderCell)
};
var columns =
[{title: "col1", key: "key1", width: 90 },
{title: "col2", key: "key2", width: 300},
{title: "col3", key: "key3", width: 220},
{title: "col4", key: "key4", width: 90},
{title: "col5", key: "key5", width: 100}];
var data = $scope.data.tipe1;
data.extend($scope.data.tipe2);
data.extend($scope.data.tip3);
data.extend($scope.data.tip4);
//parametros (columnas, info, options)
doc.autoTable(columns, data, options);
if (typeof doc.putTotalPages === 'function') {
doc.putTotalPages(totalPagesExp);
}
doc.output("datauri");
};
see the result, bro.
Erase photo for personal reasons, bro if i set
margins: {bottom: 160},
the problem is fixed, but only because i say the last row was created soo distant from page foot, you know?.
if my columns have a loot of info, the issue appear.
If can't understand what happen here with this portion of code and the image, please tell me, to make a working demostration.
Thanks for reporting this issue! When I tried your code and found multiple bugs when having long text in a table wrapping more than one page. I don't think it has anything todo with images though? I will look into this as soon as possible.
Partly this is fixed in the very experimental version 2.0 of the library which can be found in the v2
branch. However, there were still issues and it's probably not worth testing until it is officially released.
Maybe i should change the issue name, right? because Isnt the image problem, i think it was but.. is just the columns wth long text.
i will try version 2.0 thnx for quick answer!
Good luck.
It should now definitely be fixed in version 2.0. Keep in mind that custom column widths are not supported in that version as of yet however.
One last thing SomeAtoms, what should i change in my code to make it run?... can't make it ran with v2
I will write an upgrade guide when it is officially released. For now you would have to check the examples.
Version 2.0 is released which should fix this issue.
Bro, im not sure if im making a mistake using your plugin, but, i was looking for days about the options and can't found something about this.
When you insert with jsPDF an image before the autotable, the auto sizing of table lost the control of the page, putting the last row (if the content of the column is extence) in the next page, but.. not the complete last row, only the content of the extence column and the columns after that. i found the solution putting top/bottom margins and adding footer to force the pluging to add the content in the right way, if only im doing it wrong, tell me please.
Thanks for your work, its a good plugin bro.
Saludos Desde México!