/** * Created by chen on 2017/7/28. */ var pdf = require('pdfkit'); var fs = require('fs'); var doc = new pdf({autoFirstPage: false}); var text = '测试,he'; doc.pipe(fs.createWriteStream('测试.pdf')); doc.font('simsunB.ttf'); for(var p=0;p<50;p++){ doc.addPage({size:[1200,900]}); doc.rect(30,113,76,609).lineWidth(0.5).strokeColor('black').stroke(); doc.text('报表报表报表',42,717,{ height: 100, width: 500,align: 'left'}); /* let width = 70; let height=20; let j = 100; let sum = 0; for(i=0;i<400;i++){ if(i%15==0){ j+=height; sum = 0; } sum =sum+width; let x = sum; let y = j; doc.rect(x,y,width,height).lineWidth(0.5).strokeColor('black').stroke(); /!* doc.lineWidth(1.5); doc.moveTo(x,y).lineTo(x,y+height); doc.lineTo(x+width,y+height); doc.lineTo(x+width,y); doc.lineTo(x,y) doc.strokeColor('black').stroke();*!/ doc.fontSize(12); doc.text(text,x,5+y,{ height: height, width: width, align: 'right'}); // doc.text('报表文件',100,100); }*/ doc.save(); /* doc.fontSize(20); doc.rotate(-20,{origin:[400, 105]}) doc.text('报表报表报表',300,110,{ height: 100, width: 500,align: 'left'});*/ doc.restore(); } doc.end();