Ruby on Rails Tuesday, July 1, 2014

My goal is the create a model method that will generate a pdf of a
html.erb form as a delayed job task.

What I have tried:
I have tried using PDFKit with the middleware to render a PDF from the
url of the view. AKA

pdf = PDFKit.new("www.mysite.com/models/1/othermodels/1.pdf")

However, my site rests behind authentication. So in this case the pdf
that is generated is just my authentication challenge.

I attempted to use WickedPDF, PDFKit, and Prawn to generate the pdf in
the background using templates (require 'erb') etc. However, this
results in issues with converting each do blocks into strings.

ie.

content = File.read("#{Rails.root}/path/to/file.html.erb")
template = ERB.new(content)
kit = PDFKit.new(template.result(binding))

which results in error

..(( @model.othermodelss.each do |om| ).to_s); _erbout.concat
"\n\t\...
... ^
(erb):311: syntax error, unexpected end-of-input, expecting ')'
; _erbout.force_encoding(__ENCODING__)


I am just trying to get on the right track. Any pointers or advice would
be greatly appreciated.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/d9eabd612bbf9ba529c4130ad1155c78%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment