Rails PDF Prawn Data Generation 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

--------------Solutions-------------

cs = [ ]
@sql_query.each do |column|
data=[]

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

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

cs << data

end

pdf.table cs,

: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

Category:ruby on rails Time:2010-08-13 Views:0

Related post

  • Rails 3 - saving data with usign CONTROLLER.new(params[:controller]) 2011-06-09

    I am newbie in Rails and now I am solving situation, how to most effectively save data into database. My form contains 10 inputs (= 10 columns in table) and the 11th input is for file. If I'll used @mail = Mail.find(params[:id]).save So I'll get some

  • Using Prawn & Prawnto for Rails PDF generation 2009-12-17

    This is probably more a design or usage question but the main issue is using the Prawn plugin with Rails 2.3.4 and accessing the resulting PDF object to render it to a file. The scenario is basically; a controller with the respond_to block setup a vi

  • Prawn & Prawnto Rails PDF generation - UTF-8? 2010-01-20

    I'm using ruby, prawn, and prawnto to dynamically generate pdf's containing text in other languages. I can't seem to get any text in languages with non-english characters to show up. It doesn't throw any errors...just shows a bunch of dashes instead

  • Ruby on Rails Export CSV data to PDF 2011-06-10

    I have implemented CSV export, and now I am trying to export data to PDF. How can one export the CSV data from the CSV generated file to PDF. Thanks. --------------Solutions------------- You can use prawn https://github.com/sandal/prawn to generate p

  • Submitting POST data from the controller in rails to another website 2009-07-28

    In the web app I'm building with ruby on rails I have a form that the user submits with some basic data. The data is retrieved in the controller and more information that needs to remain private is added. Then I need to send a post request to an exte

  • How do you pass data from a controller to a model with Ruby on Rails? 2012-04-19

    How do you pass data from from a controller to a model? In my application_controller I grab the user's location (state and city) and include a before_filter to make it accesible in all my controllers via before_filter :community def community @city =

  • rails - saving data to another controller 2010-07-18

    I am trying to receive data at one controller and then save it on another controller/model From the api I wrote the following: class ExportController < ApplicationController def search @assignment = Assignment.find_by_id(params[:assignment_id]) @a

  • rails gem prawn, image and anchor 2011-11-27

    Can you tell me how to insert image which will be a link to for example page 20? I know how to make with normal text: text "<link anchor='page20'>Go to page 20</link>", :inline_format=>true and then on page 20 I have add_dest('page20',

  • Is it possible to make a website with Ruby On Rails that scrapes data from another website and displays it 2011-11-26

    I am teaching myself Ruby on Rails. I would like to make website that whenever someone visits it, will scrape another website and display some data. Is this possible? --------------Solutions------------- Yes, it's possible. Just remember one things:

  • Data Generation Plan error 2008-12-22

    When I attempt to run the data generation plan I get the following error, but there are no columns to be deleted. The column XXXXX has been deleted and was previously selected for data generation. Any help on this error would be appreciated. Thanks -

  • Test data generation tool 2009-05-05

    Is there any tool to generate test data based on specific requirements? e.g. Size, file type --------------Solutions------------- Your question is quite open ended ... You can find some data useful for testing in many areas, usually related to natura

  • cakephp - how can I forward data in the controller to another controller? 2009-05-27

    I have a signup form posting to my customers_controller, but now they want the signup form to take payment information too. I have a payment_controller, After saving the new user I'd like to forward the payment post data to the action in the payment_

  • Is there a way of writing PDF byte data to an IFrame clientside 2009-06-23

    Odd question I know but say one has PDF byte data contained within a hidden field on a page which also has an IFrame on it. Is there a way of writing the pdf data to the IFrame using JavaScript such that the IFrame will load in the adobe plug-in and

  • Creating a Data Generation Plan that Includes Correct Lookup Table Values 2009-10-25

    I'm just getting started with Visual Studio Database projects and loving the data generation plans I can create with it. However, in one of my projects I need to populate a lookup table with specific values. Since a foreign-key relationship exists be

  • Data Generation Plan connected fields 2009-11-01

    Is it possible to have 2 fields with the same data for a Data Generation Plan? For example, the table aspnet_roles has 2 fields RoleName and LoweredRoleName and I want them to show the same data. --------------Solutions------------- Sure, but maybe n

  • Data Generation Plan that concatenates two columns to form Email 2010-04-05

    Using the Visual Studio Data Generation Plan, I have two columns, FirstName and Lastname, populated from a Data Bound Generator (referencing a database seeded with actual valid First and Last Names). I want to generate another column for email with t

  • Data Generation Plan Missing from VS2010 Pro 2010-05-25

    I was following this tutorial http://nepomucenobr.com.br/blog/post/Generating-e2809cdummy-datae2809d-with-Visual-Studio.aspx and I got to the point where I am should add a data generation plan file. Yet when I click on the folder there is not data ge

  • Table per Type Inhertiance and Data Generation Plans 2010-06-01

    I have an Entity Framework model using Table per Type Inheritance, but when I use a VS Data Generation Plan it produces duplicate keys in the child tables, which is a problem for EF. Does anyone know of a way to get this to work, so that the child ta

  • read pdf form data using iTextSharp 2010-07-29

    I am trying to find if it is possible to read PDF Form data (Forms filled in and saved with the form) using iTextSharp. If yes.. please provide some guidance on how. thanks in Advance... Bhuvan --------------Solutions------------- You would have to f

Copyright (C) pcaskme.com, All Rights Reserved.

processed in 0.608 (s). 13 q(s)