2017-03-08 71 views
2

//我使用這樣的事情來創建一個單元格中創建PDF文件靈活的表,但我不知道如何建立靈活的表如何使用PDFkit的NodeJS

var doc = new pdfDocument(); 
doc.lineCap('square') 
.moveTo(250, 20) 
.circle(275, 30, 15) 
.stroke() 

回答

0

您使用動態數據此代碼使用PDFKit創建表格

x1=doc.x; 
x6=310; 
doc.rect(doc.x, doc.y, 450, 65) 
    .moveTo(300, doc.y).lineTo(300, doc.y+65) 
    .moveDown(0.2) 
    .text('Member Name',{indent:5, align:'left',width:140, height:doc.currentLineHeight()}) 
    .rect(x1,doc.y,450,0.5) 
    .moveUp() 
    .text(member_name,x6,doc.y) 
    .moveDown(0.2) 
    .text('Member ID',x1,doc.y,{indent:5, align:'left',width:140, height:doc.currentLineHeight()}) 
    .rect(x1,doc.y,450,0.5) 
    .moveUp() 
    .text(member_id,x6,doc.y) 
    .moveDown(0.2) 
    .text('Member DOB',x1,doc.y,{indent:5, align:'left'}) 
    .rect(x1,doc.y,450,0.5) 
    .moveUp() 
    .text(member_dob,x6,doc.y) 
    .moveDown(0.2) 
    .text('Baby Due Date',x1,doc.y,{indent:5, align:'left'}) 
    .moveUp() 
    .text(baby_due_date,x6,doc.y) 
    .stroke() 
    .moveDown(1.5);