Hi there, I’m trying to use PDFKit to create invoices server-side on my app and then return the final PDF data (as a buffer/stream?). The actual PDFKit seems quite logical but I’m struggling to return something synchronously from the method:
doc = new PDFDocument { margin: 50 }
doc.fontSize(10)
doc.text "Acme Corp"
doc.text "123, Main Street", { align: "right" }
doc.text "New York, NY", { align: "right" }
doc.end()
I’m thinking I’ll have to make use of Meteor.wrapAsync
or Promises but I’m at a bit of a loss at writing the code in such a way as I can wait for the final document data to be ready before returning it to the client. Would anyone be able to help with any examples/tips?
Or if anyone has already had any experience creating the PDFs server-side. Thanks in advance!