Credit, Credit Bank, Credit Auto


 

Robby on Rails: Ruby FPDF on Ruby on Rails
thoughts.sort_by{|t| t[:topic]}.collect

  • Ruby FPDF on Ruby on Rails

    I have been tinkering with Ruby FPDF for a client all night. I found the examples for it to lack in some real-world examples, so I have taken the example from the RubyOnRails wiki and added a bit more to it. I have added things like an image, links and made a generic letter template. (just an example). I didn’t get into the header/footer functions yet, may do that later.

    If you are not sure how to use Ruby FPDF, check out the FPDF documentation.

    Just download Ruby FPDF and unpack the archive in your libs directory.

    To get Railst to load fpdf, I added this to environment.rb:

    ADDITIONAL_LOAD_PATHS.concat%w( app app/models [..snip...] lib/fpdf ).map{|dir|"#{RAILS_ROOT}/#{dir}"}.select{|dir|File.directory?(dir)} At the top of my controller that uses this lib, I added: require'fpdf'

    When I browse to this controller/method, I got this PDF to generate with this code.

    def pdfsend_datagen_pdf,:filename=>"robbyonrails-fpdf-test.pdf",:type=>"application/pdf"endprivatedef gen_pdfd=Date.todaypdf=FPDF.newpdf.AddPagepdf.SetFont('Arial')pdf.SetFontSize(10)pdf.Image('/home/matchboy/logo2.jpg',10,8,86,0,'JPG')pdf.Cell(0,6,"PLANET ARGON",0,1,'R')pdf.Cell(0,6,"2802 NE 57th Ave",0,1,'R')pdf.Cell(0,6,"Portland, OR 97213",0,0,'R')pdf.Lnpdf.Lnpdf.Write(5,"Jane Doe 123 ABC Street Gilroy, CA 95020 #{d.month}/#{d.mday}/#{d.year} Dear Jane Doe, I just wanted to say... Epsum factorial non deposit quid pro quo hic escorol. Olypian quarrels et gorilla congolium sic ad nauseum. Souvlaki ignitus carborundum e pluribus unum. Defacto lingo est igpay atinlay. Marquee selectus non provisio incongruous feline nolo contendre. Gratuitous octopus niacin, sodium glutimate. Quote meon an estimate et non interruptus stadium. Sic tempus fugit esperanto hiccup estrogen. Glorious Cheers, Robby Russell ")pdf.Lnpdf.Cell(0,6,"PLANET ARGON",0,1,'L',0,'http://www.planetargon.com/')pdf.Outputend

    Once again, the output. (click to view PDF)

    It’s nothing special, but it’s just an example of how you can add a bit more than ‘Hello World’ to the top of a PDF. I’m still working on figuring out all the x/y stuff. Maybe I will post a better tutorial in the future with headers and footers.

    Until then… have fun!

  • "Ruby FPDF on Ruby on Rails " by sg

    buy propecia
    buy cheap levitra

    Men’s Health
    Propecia
    Viagra
    Levitra
    Cialis
    Stimula for Men

    Women’s Health
    Ortho Tri-Cyclen
    Ortho Evra Patch
    Nordette 28
    Triphasil
    Estradiol
    Diflucan