0

I am generating PDF using NRECO Pdf generator, it works by converting HTML template to PDF document. However I have one more requirement that is to add multiple attachments (images, word document or any other PDF) in Pdf being generated. In case of images, it is straight forward to give attachment path to Img tag in my HTML template, but I can't figure out how to add/merge document like word or PDF.

One approach can be to embed attachment document (PDF/ Word) to my HTML template but that didn't worked because embedded PDF was not rendered (used viewerJS to do this).

Need to find best possible way to solve this problem.

Thanks.

1 Answers1

1

If you are using Html to PDF you won't be able to embed other documents, unless you convert the other documents to an image that can be rendered in the html before conversion. Another way to do this would be to generate the initial PDF from Html, then use a PDF library to add/insert additional PDF pages. (word documents would need to be converted to pdf first)

Mark Redman
  • 24,079
  • 20
  • 92
  • 147
  • Any library which can help in merging two PDF documents? – Ahsan Tariq Feb 07 '18 at 08:55
  • @MarkRedman is right, you can produce PDF with PdfGenerator and then add attachments with 3rd party PDF library. It seems iTextSharp (it has LGPL v.4.1.6 that can be used for free) can do that: https://stackoverflow.com/questions/3007218/itextsharp-for-pdf-how-add-file-attachments – Vitaliy Fedorchenko Feb 07 '18 at 14:41