fpdf in ruby

N

Nick

this is the controller

class ProductController < ApplicationController
scaffold :product
require 'fpdf'

def pdf
send_data gen_pdf, :filename => "robbyonrails-fpdf-test.pdf", :type =>
"application/pdf"
end

private
def gen_pdf
d = Date.today
pdf=FPDF.new
pdf.AddPage
pdf.SetFont('Arial')
pdf.SetFontSize(10)

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.Ln
pdf.Ln
pdf.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.Ln
pdf.Cell(0,6, "PLANET ARGON", 0,1,'L',0,'http://www.planetargon.com/')
pdf.Output

end

end

-------------------
sometimes it is all wierd letters i get, or i want to download it, but i
cant from the server (127.0.0.1)
and i have put the dir 'fpdf' in 'lib'

any help
 
N

Nick

found my problem

forgot the header stuff

def pdf

if @request.env['HTTP_USER_AGENT'] =~ /msie/i
@headers['Pragma'] = ''
@headers['Cache-Control'] = ''
else
@headers['Pragma'] = 'no-cache'
@headers['Cache-Control'] = 'no-cache, must-revalidate'
end


send_data gen_pdf, :filename => "robbyonrails-fpdf-test.pdf", :type =>
"application/pdf"
end
 

Members online

No members online now.

Forum statistics

Threads
474,183
Messages
2,570,967
Members
47,517
Latest member
Andres38A1

Latest Threads

Top