Prev | Current Page 267 | Next

David Berube

"Practical Reporting with Ruby and Rails"

new
pdf_document.select_font "Times-Roman"
pdf_document.text "Hello world!"
pdf_document.save_as "out.pdf"
The Rails PDF plug-in (rpdf), works with PDF::Writer to make writing PDF views in
Rails easy. It allows you to access a new type of Rails view: an .rpdf view. For example, if
you needed to write the preceding example as a Rails view, you could do it like this:
pdf.select_font "Times-Roman"
pdf.text "Hello world!"
As you can see, you get an implicit PDF::Writer object, pdf, and the results of your
PDF view are automatically sent to the user??™s browser.
You can get the full details on PDF::Writer at its home page: http://ruby-pdf.
rubyforge.org/pdf-writer/.
Now that you have an idea of what ActiveRecord::Extensions and PDF::Writer can do,
let??™s take a look at how to use them.
Cost-Per-Sale Reporting
Suppose you operate an online store that sells digital books in PDF format. The books are
marketed through a variety of online advertising sources. Each source referral comes at a
certain cost per click, and each source provides a different amount of traffic each month.


Pages:
255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279
2 1 hale magazynowe białystok prezenty auto Na wylot