In my rails app I need to create pdf reports on the fly. I have installed railspdf, wich is working fine. But, how can I create tables and paragraphs and stuff? Can I mimic an .rhtml file (using <% for ...%> etc? Or is it wise to use Ruby::PDF directly? Is there anyone out there with experience in this, and who is willing to share his findings? Thx -- Posted via http://www.ruby-forum.com/.
Hi oom tuinstoel See if this tutorial helps you, http://www.artima.com/rubycs/articles/pdf_writer.html Victor -- Posted via http://www.ruby-forum.com/.
I switched to using rtex from PDF::Writer due to conflicts with Transaction::Simple (which is used by both ActiveRecord and PDF::Writer). I think those conflicts may be gone now, but I like the rtex system in any case. I wrote a bit about it here: http://convergentarts.com/articles/2006/03/21/rtex-pdf-mojo-on-windows And the link to rtex: http://codefluency.com/pages/rtex On my site I mention posting a sample table, which I haven''t done yet. Here''s a very simple table: \begin{tabular}{l V{3.5cm} r} foo & blah & bar \\ foo & blah blah & bar \\ foo & blah blah blah blah blah blah & bar \\ \end{tabular} That would be in the context of a .rtex page. See my blog if you''re interested. And now, to address your original question :).. to create a table using PDF::Writer, try SimpleTable: t = PDF::SimpleTable.new do |t| t.column_order.push(*%w(player parents email address citystzip birthdate)) t.columns["player"] = PDF::SimpleTable::Column.new("player") { |col| col.heading = "Player" } ... Then you render it to a pdf: t.render_on(@pdf) PDF::Writer has pretty good documentation for this: http://ruby-pdf.rubyforge.org/pdf-writer/ -Tom On 5/24/06, oom tuinstoel <oomtuinstoelNO@spamhotmail.com> wrote:> > In my rails app I need to create pdf reports on the fly. I have > installed railspdf, wich is working fine. But, how can I create tables > and paragraphs and stuff? Can I mimic an .rhtml file (using <% for > ...%> etc? Or is it wise to use Ruby::PDF directly? Is there anyone out > there with experience in this, and who is willing to share his findings? > Thx > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060524/e744cedf/attachment.html
On 5/24/06, Tom Wilcoxen <tomwilcoxen@gmail.com> wrote:> I switched to using rtex from PDF::Writer due to conflicts with > Transaction::Simple (which is used by both ActiveRecord and PDF::Writer). I > think those conflicts may be gone now, but I like the rtex system in any > case. I wrote a bit about it here:It would be useful if someone could verify that this is the case. The current version of Transaction::Simple should now be bundled with Rails, with the long-term goal of removing it from the bundle. -austin -- Austin Ziegler * halostatue@gmail.com * Alternate: austin@halostatue.ca
Tom Wilcoxen wrote:> And now, to address your original question :).. to create a table using > PDF::Writer, try SimpleTable: > > t = PDF::SimpleTable.new do |t| > t.column_order.push(*%w(player parents email address citystzip > birthdate)) > > t.columns["player"] = PDF::SimpleTable::Column.new("player") { > |col| > col.heading = "Player" > } > ... > > Then you render it to a pdf:This is what I do: table = PDF::SimpleTable.new table.data = @children table.column_order.push(*%w(firstname group_id)) table.columns["firstname"] = PDF::SimpleTable::Column.new("firstname") { |col| col.heading = "Firstname" } to get a table. My problem is: how do I get values in there? Imean, children belong to groups, and to parents (real tablenames). What would be the easiest way to get groups.name and parent.lastname etc in the table? table.render_on(pdf) -- Posted via http://www.ruby-forum.com/.