I'm trying to generate a PDF with Wicked PDF. So far it's going fine, but when I try to add images all I get are blank boxes. My images are in both ../app/assets/images/foo.png
and ../public/images/foo.png
for testing purposes.
From what I understand, wicked_pdf_image_tag('foo.png')
will output <img src="file:///home/users/my_username/my_app_name/public/images/foo.png">
so being that I have my images in /public/images
the following code should work:
<%= wicked_pdf_image_tag("foo.png", width: 100, height: 100) %>
...but it just doesn't, it only gives me a blank box. I've also all of the following tried:
<%= image_tag Rails.root.join("app/assets/images/foo.png"), width: 100, height: 100 %>
<img src="<%= Rails.root.join("app/assets/images/foo.png")%>" width="100" height="100">
<%= image_tag Rails.root.join("public/images/foo.png"), width: 100, height: 100 %>
<img src="<%= Rails.root.join("public/images/foo.png")%>" width="100" height="100">
<%= wicked_pdf_image_tag("foo.png", width: 100, height: 100) %>
<img src="<%= "images/foo.png"%>" width="100" height="100">
All what's generated is this
Any help is appreciated. Thanks in advance
UPDATE:
I think it's important to mention that the Rails application is API-only. That being said, I added the following code on my .erb file:
<%= image_tag image_url("foo.png"), width: 100, height: 100 %>
This alone doesn't work, but it does if I change the application_controller.rb class from:
class ApplicationController < ActionController::API
to:
class ApplicationController < ActionController::Base
That's the ONLY way I have discovered to make an image appear yet. If someone can give insight on this, I would appreciate it.