pdfkit_test.js 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /**
  2. * Created by chen on 2017/7/28.
  3. */
  4. var pdf = require('pdfkit');
  5. var fs = require('fs');
  6. var doc = new pdf({autoFirstPage: false});
  7. var text = '测试,he';
  8. doc.pipe(fs.createWriteStream('测试.pdf'));
  9. doc.font('simsunB.ttf');
  10. for(var p=0;p<50;p++){
  11. doc.addPage({size:[1200,900]});
  12. doc.rect(30,113,76,609).lineWidth(0.5).strokeColor('black').stroke();
  13. doc.text('报表报表报表',42,717,{ height: 100, width: 500,align: 'left'});
  14. /* let width = 70;
  15. let height=20;
  16. let j = 100;
  17. let sum = 0;
  18. for(i=0;i<400;i++){
  19. if(i%15==0){
  20. j+=height;
  21. sum = 0;
  22. }
  23. sum =sum+width;
  24. let x = sum;
  25. let y = j;
  26. doc.rect(x,y,width,height).lineWidth(0.5).strokeColor('black').stroke();
  27. /!* doc.lineWidth(1.5);
  28. doc.moveTo(x,y).lineTo(x,y+height);
  29. doc.lineTo(x+width,y+height);
  30. doc.lineTo(x+width,y);
  31. doc.lineTo(x,y)
  32. doc.strokeColor('black').stroke();*!/
  33. doc.fontSize(12);
  34. doc.text(text,x,5+y,{
  35. height: height,
  36. width: width,
  37. align: 'right'});
  38. // doc.text('报表文件',100,100);
  39. }*/
  40. doc.save();
  41. /* doc.fontSize(20);
  42. doc.rotate(-20,{origin:[400, 105]})
  43. doc.text('报表报表报表',300,110,{ height: 100, width: 500,align: 'left'});*/
  44. doc.restore();
  45. }
  46. doc.end();