Adding a blank page via Prawn and adding text to it.

71 views
Skip to first unread message

stag...@nycopportunity.nyc.gov

unread,
Dec 13, 2018, 10:16:31 AM12/13/18
to Prawn
Hi all, I'm currently working on building an application that uses a FormService, retrieving data from JSON and then parsing it into a PDF form.
Currently, from the JSON response I get a field with notes. The notes field is text that I would like to add into a blank pdf page.

{ "field" => "12345", "value" => "Some text to add to a PDF blank page" }

I would like that text into a Blank PDF.

def pdf_scrie_application(submission)
    user_data
= submission['data']
    binding
.pry
    pdf
= CombinePDF.new
    file_name
= name_file(submission)
    pdf_path
= PdfScrie.new(user_data, formstack_fields).export(file_name)
    pdf
<< CombinePDF.load(pdf_path)


    attach_docs_from_submission
(user_data).each do |file|
      data
= client.download_file(file)
      is_pdf
= (data =~ /\%PDF-\d+\.?\d+/) == 0


     
unless is_pdf
        format_image
= StringIO.new(data)
        pdf_prawn
= Prawn::Document.new(page_size: 'LETTER', margin: 0)
        pdf_prawn
.image(
          format_image
,
          fit
: [
            PDF_PAGE_WIDTH
,
            PDF_PAGE_LENGTH
         
],
          position
: :center,
          position
: :center
       
)
        data
= pdf_prawn.render
     
end


      pdf
<< CombinePDF.parse(data)
   
end


I'm looking for some guidence on how to accomplish this. Any information regarding adding text to a blank page in prawn is highly appreciated

Alexander Mankuta

unread,
Dec 13, 2018, 10:20:35 AM12/13/18
to Prawn
Have you checked the manual? I'm pretty sure you can find some example code that suits your needs.
Reply all
Reply to author
Forward
0 new messages