https://github.com/chunyenHuang/hummusRecipe
https://www.npmjs.com/package/hummus-recipe
现行有许多生成PDF的工具,但是唯独欠缺简单好用的"修改"工具。
HummusRecipe建构在HummusJS(https://github.com/galkahana/HummusJS)之上,
大幅简化了使用上的难度,也增加了许多亲切的API。
中文字型需另外下载
https://github.com/chunyenHuang/hummusRecipe/blob/master/tests/font.js
安装
npm i hummus-recipe
修改PDF
const HummusRecipe = require('hummus-recipe');
const pdfDoc = new HummusRecipe('input.pdf', 'output.pdf');
pdfDoc
   .editPage(1)
   .text('浮水印', 'center', 250, {
       color: '066099',
       fontSize: 30,
       bold: true,
       font: 'Helvatica',
       align: 'center center',
       opacity: 0.2,
       rotation: 180
   })
   .rectangle(20, 20, 40, 100)
   .comment('添加Comment annotation', 200, 300)
   .image('/path/to/image.jpg', {width: 300, keepAspectRatio: true})
   .endPage()
   //
   .editPage(2)
   .comment('Add 2nd comment annotaion', 200, 100)
   .endPage()
   .endPDF();
生成PDF
const HummusRecipe = require('hummus-recipe');
const pdfDoc = new HummusRecipe('new', '/output.pdf',{
    version: 1.6,
    author: 'John Doe',
    title: 'Hummus Recipe',
    subject: 'A brand new PDF'
});
pdfDoc
    .createPage('letter-size')
    .text('哈囉~ \n 你好', 'center', 250, {
        color: '066099',
        fontSize: 30,
        bold: true,
        font: 'Helvatica',
        align: 'center center',
        opacity: 0.8,
        rotation: 180
    })
    .endPage()
    .endPDF();