Ruby PRAWN PDF generatiog values from controller

I have a file named report.pdf.prawn,
which is the view part of my PDF file where we can edit the contents of
the PDF file like >>>
pdf=Prawn::Document.new(:page_layout =>:landscape,:page_size => ‘A4’)
pdf.text"Hello"

[email protected]
headers=[""],[""]
pdf.table headers,
:width => 768,
:size => 11,
:border_style => :underline_header,
:headers => [head.titleize],
:header_color => ‘b7e3fe’,
:padding=>5

<<< etc ect…
The above just prints like

Hello
Header1header2header3

I have two values from my controller >>> def report <<< as
@header and @data

@header gives values like>> Header1Header2Header3
@data gives values like>> data11data12data13data21data22data23

How do i print the values like the format given below on all PDF pages
being generated?

Header1 Header2 Header3

data11 data12 data13
data21 data22 data23
data31 data32 data33
data41 data42 data33

Please help.

Hi,

Use the :column_widths=>{0=>100,1=>100, 2=>100, etc…} property.

Jan

I used the " :column_widths " property before, since the Header field
comes in as hash values, te :column_widths of 0=>100 will be assigned to
the first header only, the remaining cell widths will not be taken.

What i was asking, is the format to be printed on PDF.
thanks for replying.

javinto wrote:

Hi,

Use the :column_widths=>{0=>100,1=>100, 2=>100, etc…} property.

Jan

headerbar=[]
@data.each do |column|
data=[]

 if @headers.include?('dataXX')
 column.number
 data << column.number
 end

             if @headers.include?('dataXX')
 column.number
 data << column.number
 end

headerbar << data

end
pdf.table headerbar,
:width => 768,
:size => 11,
:border_style => :underline_header,
:headers => @header,
:header_color => ‘b7e3fe’,
:column_widths=>{0=>55,1=>100,2=>70,3=>77,4=>88,5=>90,6=>75,7=>75,8=>75,9=>65,10=>55,11=>55},
:padding=>5

Not fully rectified, but works.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs