mirror of
https://github.com/pdfme/pdfme.git
synced 2026-04-24 16:10:10 -04:00
40 lines
815 B
JavaScript
40 lines
815 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: [
|
|
[
|
|
{
|
|
name: 'a',
|
|
type: 'text',
|
|
position: { x: 0, y: 0 },
|
|
width: 10,
|
|
height: 10,
|
|
},
|
|
{
|
|
name: 'b',
|
|
type: 'text',
|
|
position: { x: 10, y: 10 },
|
|
width: 10,
|
|
height: 10,
|
|
},
|
|
{
|
|
name: '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-generate.pdf`), pdf);
|
|
}); |