Forum: Ruby on Rails Gruff with PDF::Writer

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
C728d93eb5205cf20cac0c2928b0ad62?d=identicon&s=25 RJ (Guest)
on 2007-03-27 11:53
Hello all

Has anyone managed to embed gruff graphs into a PDF document using

The easy way (as far as I can see) would be to just save the gruff graph
as a temporary file then read that file in pdf::writer. I was wondering
if anyone had managed to get them working together directly?

153107d9ef8352ea7f787d2090d81666?d=identicon&s=25 Marston A. (Guest)
on 2007-03-27 14:02
(Received via mailing list)
I'm definitely looking for a solution to the same thing as well.
320b651f98fa44b807d99bd7f4aac40d?d=identicon&s=25 unknown (Guest)
on 2007-04-12 03:29
(Received via mailing list) too.
3726bda7f0d852f7e8296fb0d69aa9e0?d=identicon&s=25 Andy Triboletti (Guest)
on 2007-04-12 04:00
(Received via mailing list)
I did this pretty easily using the technique RJ described earlier
with writing a temp file.  It's kind of a hack but it works.

What I'm doing is:

First generating the gruff graphs and storing it as file, then
loading that file in as a blob in the db
Then generate the pdf by pulling the graphs out of the db, store them
as temp files, then load that  file using the pdf image method.

Ecff2e8d01672a7b3d26a3c4c962fc5b?d=identicon&s=25 Mikhail Shalai (stwoland)
on 2010-01-13 15:07
There is a much easier workaround.
You may just set opacity to zero. Here's how I did it:

require "gruff"
class Chart < Gruff::StackedBar
  def opacity
  def opacity=( value )
    @base_image.opacity = value

  def draw
    self.opacity = 0

Or, you may re-open the image and save it again:
  g = 640 )
  # ...
  i = unique_filename
  g.write( i )

  image = i ).first
  image.opacity = 0
  image.write( i )

  pdf =
  ( pdf.image i ) && File.delete( i )
This topic is locked and can not be replied to.