2017-10-17 2 views
0

내 jspdf에서 빈 페이지 PDF를 저장하지 않으려 고 시도합니다. 나는 많은 예제를 시도하고, 그러나 아무것도 :(작동하지 않습니다. 내 테이블 내용은 PDF의 두 번째 페이지에 이미지와 함께, 올바른 저장되지만 내 첫 번째 페이지가 비어 있습니다.jspdf 첫 번째 PDF 페이지가 비어 있습니다.

var pdf = new jsPDF('o', 'pt', 'a6'); 
//pdf.autoTable(this.columns, this.data); 
//var width = pdf.internal.pageSize.width;  
//var height = pdf.internal.pageSize.height; 
pdf.addPage('1800','900'); 
pdf.addImage(imgData, 'PNG', 120, 40, 120, 100); 
pdf.setTextColor(0,0,0); 
pdf.text(120, 20, 'BOOKINGS'); 
pdf.setFontSize(22);  
// 'o', 'pt', 'a4' 
// 'p', 'pt', 'letter' 
// source can be HTML-formatted string, or a reference 
// to an actual DOM element from which the text will be scraped. 
source = jQuery('.dataTables_wrapper')[0]; 
// we support special element handlers. Register them with jQuery-style 
// ID selector for either ID or node name. ("#iAmID", "div", "span" etc.) 
// There is no support for any other type of selectors 
// (class, of compound) at this time. 
specialElementHandlers = { 
    // element with id of "bypass" - jQuery style selector 
    '#bypassme': function (element, renderer) { 
     // true = "handled elsewhere, bypass text extraction" 
     return true 
    } 
}; 
margins = { 
    top: 120, 
    bottom: 0, 
    left: 0, 
    width: 2000 
}; 
// all coords and widths are in jsPDF instance's declared units 
// 'inches' in this case 
pdf.fromHTML(
source, // HTML string or DOM elem ref. 
margins.left, // x coord 
margins.top, { // y coord 
    'width': margins.width, // max width of content on PDF 
    'elementHandlers': specialElementHandlers 
}, 

function (dispose) { 
    // dispose: object with X, Y of the last line add to the PDF 
    //   this allow the insertion of new lines after html 
     pdf.save('bookings.pdf'); 
}, margins); 

}

답변

0

을 페이지를 추가하면 jsPDF 생성자를 호출 한 후 첫 번째 호출이므로 첫 번째 페이지가 비어 있습니다. 생성자는 이미 첫 번째 빈 페이지를 만듭니다. 문서 시작 부분에 빈 페이지를 추가로 제거하려면 첫 번째 페이지는 doc.deletePage(1)을 호출하거나 생성자가 호출 된 후 페이지를 추가하지 마십시오.

관련 문제