How do you combine PDFs in ruby?

前端 未结 8 2130
你的背包
你的背包 2020-12-25 15:17

This was asked in 2008. Hopefully there\'s a better answer now.

How can you combine PDFs in ruby?

I\'m using the pdf-stamper gem to fill out a form in a PDF.

8条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-25 15:41

    If you want to add any template (created by macOS Pages or Google Docs) using the combine_pdf gem then you can try with this:

    final_pdf = CombinePDF.new
    company_template = CombinePDF.load(template_file.pdf).pages[0]
    pdf = CombinePDF.load (content_file.pdf)
    pdf.pages.each {|page| final_pdf << (company_template << page)} 
    final_pdf.save "final_document.pdf"
    

提交回复
热议问题