mileszs / wicked_pdf

PDF generator (from HTML) plugin for Ruby on Rails
http://www.mileszs.com/wicked-pdf-plugin
MIT License
3.53k stars 642 forks source link

Fon't won't be included in the PDF generated by wicked_pdf #544

Open kamaladel opened 8 years ago

kamaladel commented 8 years ago

I've included <%= wicked_pdf_stylesheet_link_tag "application", media: "all"%>

In template, layout, and header aswell.

Bootstrap divs and table styles are loaded, fon't are not, however they are working fine in other normal views in the application, only the generated PDF is fontless.

unixmonkey commented 8 years ago

Try using regular stylesheet_link_tag, wicked_pdf_stylesheet_link_tag does some optimization that I've seen break when big frameworks are included.

doooby commented 8 years ago

maybe related to my issue with rails: the path to the file resolves to '../public/stylesheets/..' although assets on production are at '../public/assets/stylesheets/..'. I've solved it using stylesheet_link_tag as it inserts a tag with source's url instead of embedding the content within html tag as in case of wicked_pdf_stylesheet_link_tag. Looks like there's no issue with linking it instead embedding. Anyway I find it weird why the code explicitly states to search at css_dir = WickedPdfHelper.root_path.join('public', 'stylesheets') - maybe it could be configurable?

unixmonkey commented 8 years ago

@doooby I think that code path should only be hit on Rails version 3.0 or less, or 3.x if Rails.configuration.assets.enabled is false, otherwise it will use read_asset which searches with Rails.application.assets.find_asset.

If you look at https://github.com/mileszs/wicked_pdf/blob/master/lib/wicked_pdf/railtie.rb, you'll see that WickedPdfHelper::Assets is included in modern Rails, while WickedPdfHelper is included for older ones. Let me know if this helps or not, and please provide more info about your environment.

doooby commented 8 years ago

So I took the time with byebug today: simply put, my issue wasn't related, so sorry for that. I would believe that I'd check last time that it somehow ends in WickedPdfHelper#wicked_pdf_stylesheet_link_tag but it's not the case :-( .

I feel stupid even more, because I've just found out we simply have never had Rails.application.config.assets.precompile << 'twitter/bootstrap.css' - but only recenty we've removed config.assets.compile = true from our production env. It's just that the asset isn't there. Then again how come stylesheet_link_tag makes it work? I guess that's not important, since it may be due to some other really messy config. To much time spent already.