Font rendering issues with wkhtmltoimage - ruby-on-rails

I have a Rails app which uses wkhtmltoimage to render an image. The font used in the image is Lucida Grande, included via inline data-uris. On my local Mac everything works just fine, but on the remote server (Ubuntu 12.10) the font just looks weird. Both are using wkhtmltoimage 0.10.0 rc2.
The left one is generated on my Mac, the right one on the Ubuntu server.
Any ideas whats going on?

Unfortunately I haven't found a solution for this problem. But today I was lucky enough to find a workaround! :)
After reading Thomas Fuchs' Embedding Canvas and SVG charts in emails I went the radical way and completely replaced wkhtmltoimage with PhantomJS. I also used his gist to install some dependencies. And here are the results:
wkhtmltoimage local & remote:
PhantomJS local & remote:
Though there are still small differences, PhantomJS does its job quite good! So I will use this for now, and close this question :)

Related

wicked_pdf renders a tiny pdf image

I have added wicked_pdf to my rails app with default options following the readme file (with the deviation being that I installed wkhtmltopdf via the osx installer).
When I render my page with the .pdf?debug=true option, the page looks exactly as it should.
Then when I leave out the debug option, it produces a PDF with a tiny version of the page. Like 1/16 of the size.
I use no options or configuration. Where am I going wrong? Where should I be looking?
Solved it by changing the wkhtmltopdf version from 12.4 to an earlier version.
After a lot of googling others have reported a similar bug with version 12.4 on OSX.
Maybe the answer here saves someone else a few hours of googling.
It worked for me by changing the version to
gem 'wkhtmltopdf-binary', '~> 0.12.3.1'
reference here

discrepancy between development and production pdf generated

I've Iterated over the creation of a PDF with data in my RoR application. I am using wkhtmltopdf 0.9.9 locally and trying to use wkhtmltopdf-binary (0.9.9.1) gem on heroku.
My PDF looks exactly the way I want it to look locally but it looks like the heroku version is a zoomed out version of the local version effectively making the page on heroku left align when the development version is perfectly centered.
I'd like my production version to look exactly like my development version so that I don't have to iterate on my heroku instance.
Any help is appreciated!
I had the same problem, but setting DPI, while generating pdf via wkhtmltopdf, solved the problem.
--dpi 100

Twitter Bootstrap displays strange on local machine, fine in production

I've got a strange problem. My rails app looks fine in prod, but I recently started working on it on a different computer, and the front page seems to have forgotten about it's margins. When I commit everything and push it out to production, there are no problems.
I'm using twitter-bootstrap-rails and have not customized the stylesheets at all.
This picture has everything crammed against the left side of the browser, on my local machine
This picture shows production, where everything is properly aligned
This could be due to the mode you are running the server. My guess is that you will see the difference when you run rails s development vs rails s production.
I ran into this before, and it was an issue where my CSS was compiling incorrectly because I had some bad CSS floating around.
It can be pretty insidious to track down, so first look through your assets hierarchy and look for anything that is out of place. After that, you'll have to investigate using a browser and inspection tools like through Chrome.
Had similar issues with the fixed header bar which lost it's style. Looks like it was the update to the twitter-bootstrap-rails gem from 2.0.3, which I was using to the new 2.1.6.
With the update I then got an error about twitter-bootstrap-rails v2.1.6 break with error "rails app: method_missing': undefined methodless'
There has been a lot of discussion on the twitter-bootstrap-rails issue list: see v2.1.6 breaks app which explains a lot of the revised Gemfile configurations.
So far applying the suggestions hasn't resolved my issue of the header bar, which was dark, as per the Twitter Bootstrap examples, now appearing with a grey background like the LH nav bar. Suspect that it's something to do with the less compiling or linking of the assets.
I'm not sure exactly what the problem was still, but once I linked the app to Pow on my Mac everything displays normally. Strange. Anyway, I'm not having a problem anymore.

Rmagick SVG conversion different than ImageMagick

Here's a link to my test: http://pestnow.herokuapp.com/tester/svg The image on the left is SVG, the one on the right is the PNG conversion. Here's the extremely simple code for the conversion:
def self.svg_to_png(svg)
img = Magick::Image::from_blob(svg)
return img[0].to_blob {self.format = 'PNG'}
end
I've been struggling with this problem and had this answered question here: SVG to PNG Conversion with ImageMagick doesn't handle defs? That question had to do with getting IM to do the conversion properly. And it DOES, from the command line with a simple "convert test.svg test.png"
But the RMagick conversion doesn't work the same. On my local dev box, I do have ImageMagick compiled with RVG support, and that fixed the command line. But I have no clue how to make RMagick use it the same way.
Furthermore, I'm hoping its something I need to do in my code, and not some feature required on the server, because this app is hosted on heroku and I have no control over how they install IM.
I should have reported back.
Yes, Heroku has IM, but they don't support it. It's just there as part of the long term support version of (I believe) Ubuntu that they use. We talked back and forth a few times, and they have said that they might upgrade it in the future, along with other linux libs / utils, but that there was no definite timeframe. My guess is, maybe on the next stack.
Until then, I've stopped using symbols in my SVG and had to do a few tricks on order of transforms, but for the most part I have things working. Another piece of advice is to make sure you are using the EXACT version of IM that Heroku uses on your Dev box. Saves a lot of heartache.

Rails 3 compatible image uploading with no dependencies?

OK so I'm looking for a good image uploading gem that is Rails 3 compatible and has no dependencies. I was using attachment_fu, but it's Rails 3 compatibility seems to be in question. And I really wanted to use Paperclip, but it has an image majick dependency. I'm having a hard time finding other alternatives...
Stupid question #1: Shouldnt Rails have some "official" image uploading scheme thats baked into the framework? Every web app will need it at some point, and hunting around every time for some questionable third-party way of doing this gets old after awhile.
Stupid question #2: Why can't Paperclip have a no-dependency mode that doesnt make thumbnails or resize, and just stores images as they are uploaded?
As someone who has Rails with Paperclip running on both Linux, Mac and Windows, I can tell you: installing ImageMagic (or whatever spelling is) is not a problem.
In fact, my old linux hosting already had it, Mac laptop, IIRC, too. I expected some problems installing it on windows, but had to just download installer and specify correct path in rails. No problem whatsoever.
So, in your place, I would really give it a try.
edit
There's also a number of file upload plugins for Rails, but I didn't use them and can't really give advice there. Google will give you examples.

Resources