igor-alexandrov/wisepdf

How to render a pdf from object returned from Writer.new

jersinghaus opened this issue · 2 comments

Hello,

Forgive me as this is not really an issue, but I store html in a database and am using wisepdf to convert to pdf format. But I don't know how to render the pdf back to the browser.

I'm doing something like this in my controller:

def index
respond_to do |format|
format.pdf do
my_pdf = PdfTable.find_by_code('my_pdf')
pdf = Wisepdf::Writer.new.to_pdf(my_pdf)
send_data pdf, type: 'application/pdf', disposition: 'inline'
end
end
end

But my tab opened in ff (using pdf ff addon) is blank.

How would I render the string pdf returned from Writer.new?

Thanks

Hmm, maybe you are missing something here:

template = PdfTable.find_by_code('my_pdf')
pdf = Wisepdf::Writer.new.to_pdf(template.content)

I mean, that you forget to pass some attribute from your PdfTable instance object to Wisepdf::Writer.new.to_pdf.

Yep, sorry, I'm an idiot. I was overwriting the 'template' variable. Doh!

Thanks for the quick reply though! :)