我的数据库数据获取有问题,我需要为这些数据换行,我正在使用jspdf导出pdf https://imgur.com/a/VGt5Oat 我的问题是在img的一列中为另一列使用空间
else if(defaults.type == 'pdf'){
rowPositionHeader = 0;
var doc = new jsPDF({orientation: 'l', unit: 'pt', format: 'a4'});
doc.setFontSize(7);
// Header
var startRowPosition = 20; var page =1;var rowPosition=0;var rowPosition2 = 0;
var startColPosition=defaults.pdfLeftMargin;
$(el).find('thead').find('tr').each(function(index,data) {
index2 = rowCalc = index+1;
if (rowCalc % 35 == 0){
doc.addPage();
page++;
startRowPosition=startRowPosition;
}
rowPositionHeader = rowPosition=(startRowPosition + (rowCalc * 10)) - ((page -1) * 280) -20;
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 130);
console.log("rowPosition: ", rowPosition);
doc.text(colPosition,rowPosition, parseString($(this)));
}
}
});
});
// Row Vs Column
var rowCalc = 0; startRowPosition = rowPositionHeader;
$(el).find('tbody').find('tr').each(function(index,data) {
rowCalc += 1;
if (rowCalc % 50 == 0){
doc.addPage();
startRowPosition=10;
rowPositionHeader = 0;
rowPosition = 0;
rowCalc = 5;
$(el).find('thead').find('tr').each(function(index,data) {
index2 = rowCalc = index+1;
rowPosition=(startRowPosition + (rowCalc * 10)) - ((page -1) * 280) -20;
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 130);
console.log("rowPosition: ", rowPosition);
doc.text(colPosition,rowPosition, parseString($(this)));
}
}
});
});
}
rowPosition=(startRowPosition + (rowCalc * 20));
$(this).filter(':visible').find('td').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 130);
console.log("rowPosition: ", rowPosition);
doc.text(colPosition,rowPosition, parseString($(this)));
}
}
});
rowPosition=(startRowPosition + (rowCalc * 10));
$(this).filter(':visible').find('th').each(function(index,data) {
if ($(this).css('display') != 'none'){
if(defaults.ignoreColumn.indexOf(index) == -1){
var colPosition = startColPosition+ (index * 50);
console.log("rowPosition th:", rowPosition);
doc.text(colPosition,rowPosition, parseString($(this)));
}
}
});
});
// Output as Data URI
doc.output('dataurlnewwindow');
以pdf格式导出的代码,并调整纸张中的行和列
我期待着突破线,请帮助我!