pdffillerjs / pdffiller

Take an existing PDF Form and data and PDF Filler will create a new PDF with all given fields populated.
MIT License
286 stars 113 forks source link

Using with async/await #76

Open mattboutet opened 5 years ago

mattboutet commented 5 years ago

Not so much an issue as a note for future explorers. Many of the functions of this library rely on this, and so won't work out of the box with Utils.promisify.

In order to successfully use promisify, it's necessary to use bind to correctly set the context when promisifying.

Example: const fillFormWithFlatten = Utils.promisify(PDFFiller.fillFormWithFlatten.bind(PDFFiller)); await fillFormWithFlatten(original, destination, fields, false);