I want to create a PDF file with our department logo. When I try to use the WickedPdf class in my controller (using the method described in https://github.com/mileszs/wicked_pdf ):
def some_action image_tag_string = image_tag('logo.jpg') pdf = WickedPdf.new.pdf_from_string(image_tag_string) save_path = Rails.root.join('testpdfs','logotest.pdf') File.open(save_path, 'wb') do |file| file << pdf end end
... the application saves the PDF to the target directory, but has a blue and white color ?? mark where the image should be.
If I do this instead:
image_tag_string = wicked_pdf_image_tag('logo.jpg') pdf = WickedPdf.new.pdf_from_string(image_tag_string)
I get the following error:
NoMethodError: undefined method `wicked_pdf_image_tag' for #<...
It looks like my Rails application is also missing / not related to the helper file belonging to the wicked-pdf gem.
Answers to similar questions on StackOverflow recommend writing a special "image-tag" helper to find an image or install wkhtmltopdf. For me, the image tag shows the logo only perfectly when placed in the View (whatever.html.erb). "logo.jpg" is already in both the asset pipeline and in # {RailsRoot} / public / images. Finally, I use wkhtmltopdf 0.9.9, wicked-pdf 0.11.0 and rails 4 on Ubuntu 14.04.
In short - what am I doing wrong that causes WickedPDF to not display the image?
source share