Rubyonrails -generate Pdf using prawn.how to align table to center in pdf

In a ruby on rails application i have created pdf using prawn(o.12.0) and prawnto.In the pdf there is a table the issue is that i was not able to align the table to center.

when am giving :align =>center ,it throws an error as undefined.

how can i solve this issue.

pdf.bounding_box([5, 705], :width => 530, :height => 680) do
pdf.stroke_bounds

pdf.move_down(20) 
pdf.text "Demographics", :size => 15, :style => :bold, :align => :center


invoiceData = [["Facebook Pushes - Total users","Users Shared Exercise For   Week","Users Shared Exercise For Day","Users Share TestResult"],
[100","20","50","30"]]

pdf.table(invoiceData,:row_colors => ["FDFFFF", "FFFFFF"], :cell_style => { :border_width => 0.1,:border_color=> 'C1C1C1' }) do |table|

end

pdf.bounding_box([pdf.bounds.right - 50,pdf.bounds.bottom], :width => 60, :height => 20) do
pagecount = pdf.page_count
pdf.text "Page #{pagecount}"
end
  end

[screenshot]

http://i.stack.imgur.com/pqBtA.png

Answers


    pdf.bounding_box([5, 705], :width => 530, :height => 680) do
pdf.stroke_bounds

pdf.move_down(20) 
pdf.text "Demographics", :size => 15, :style => :bold, :align => :center

pdf.bounding_box([25,pdf.bounds.top-100], :width => 516, :height => 680) do
invoiceData = [["Facebook Pushes - Total users","Users Shared Exercise For   Week","Users Shared Exercise For Day","Users Share TestResult"],
[100","20","50","30"]]

pdf.table(invoiceData,:row_colors => ["FDFFFF", "FFFFFF"], :cell_style => { :border_width => 0.1,:border_color=> 'C1C1C1' }) do |table|
end
end

pdf.bounding_box([pdf.bounds.right - 50,pdf.bounds.bottom], :width => 60, :height => 20) do
pagecount = pdf.page_count
pdf.text "Page #{pagecount}"
end
  end

By defining a new bounding box above table likethis we can solve this issue

pdf.bounding_box([25,pdf.bounds.top-100], :width => 516, :height => 680) do

Need Your Help

What is the syntax for using the color property of a class in an “if…then” statement

ios objective-c uicolor

I have a program in which depending on where I touch the screen, it will make a square turn red or blue. But based on what color the square is, I want to have a specific set of rules. I'm trying to...

Creating a Global Object?

c# visual-studio object

I'm trying to achieve the following:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.