Files
pdfme/playground/generate.js
2023-11-27 09:37:25 +09:00

37 lines
758 B
JavaScript

const { BLANK_PDF } = require('@pdfme/common');
const { generate } = require('@pdfme/generator');
const fs = require('fs');
const path = require('path');
const template = {
basePdf: BLANK_PDF,
schemas: [
{
a: {
type: 'text',
position: { x: 0, y: 0 },
width: 10,
height: 10,
},
b: {
type: 'text',
position: { x: 10, y: 10 },
width: 10,
height: 10,
},
c: {
type: 'text',
position: { x: 20, y: 20 },
width: 10,
height: 10,
},
},
],
};
const inputs = [{ a: 'a1', b: 'b1', c: 'c1' }];
generate({ template, inputs }).then((pdf) => {
console.log(pdf);
fs.writeFileSync(path.join(__dirname, `test.pdf`), pdf);
});