Merging PDFs in Node

前端 未结 2 1238
[愿得一人]
[愿得一人] 2021-02-09 19:40

Hi i\'m trying to merge pdf\'s of total of n but I cannot get it to work.

I\'m using the Buffer module to concat the pdf\'s but it does only apply the last pdf

相关标签:
2条回答
  • 2021-02-09 20:21

    What do you expect to get when you do Buffer.concat([pdf1, pdf2])? Just by concatenating two PDFs files you won’t get one containing all pages. PDF is a complex format (basically one for vector graphics). If you just added two JPEG files you wouldn’t expect to get a big image containing both pictures, would you?

    You’ll need to use an external library. https://github.com/wubzz/pdf-merge might work for instance.

    0 讨论(0)
  • 2021-02-09 20:23

    HummusJS is another PDF manipulation library, but without a dependency on PDFtk. See this answer for an example of combining PDFs in Buffers.

    0 讨论(0)
提交回复
热议问题