Comment modifier ou écrire sur le PDF existant avec Ruby

Mots clés : ruby-on-railsrubypdf-generationfpdiruby-on-railsruby

meilleur 4 Réponses Comment modifier ou écrire sur le PDF existant avec Ruby

vote vote


filename = "#{Prawn::DATADIR}/pdfs/multipage_template.pdf" Prawn::Document.generate("full_template.pdf", :template => filename) do   text "THis content is written on the first page of the template", :align => :center end 
vote vote


require 'prawn' require 'pdf/toolkit'  template_filename = 'some/dir/Awesome-Graphics.pdf' prawn_filename = 'temp.pdf' output_filename = 'output.pdf'  Prawn::Document.generate(prawn_filename) do   # Generate whatever you want here.   text_box "This is some new text!", :at => [100, 300] end  PDF::Toolkit.pdftk(prawn_filename, "background", template_filename, "output", output_filename) 
vote vote


company_logo = CombinePDF.load("company_logo.pdf").pages[0] pdf = CombinePDF.load "content_file.pdf" pdf.pages.each { |page| page << company_logo } # notice the << operator is on a page and not a PDF object. "content_with_logo.pdf" 
vote vote


# get the record from the database to add dynamically to the pdf user = User.last  # get the existing pdf pdf = CombinePDF.load "#{Rails.root}/public/pdf/existing_pdf.pdf"  # create a textbox and add it to the existing pdf on page 2 pdf.pages[1].textbox "#{user.first_name} #{user.last_name}", height: 20, width: 70, y: 596, x: 72  # output the new pdf which now contains your dynamic data "#{Rails.root}/public/pdf/output#{}.pdf" 

Questions similaires