Forum: Ruby on Rails Adding image in pdf using pdf writer

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
3d9e26d3be3e7fcf93aca6574bc77a20?d=identicon&s=25 Tushar Gandhi (gandhi-tush)
on 2009-04-07 16:42
Hi,

I am using this code, but I am not able to add the image in pdf using
pdf writer.
Is there any wrong with code?

def pdf1
    _pdf = PDF::Writer.new
    _pdf.select_font "Times-Roman"
    _pdf.text "Hello, Ruby.", :font_size => 72, :justification =>
:center
    _pdf.image "http://localhost:3001/images/rails.png"
    send_data _pdf.render, :filename => "hello.pdf",
    :type => "application/pdf"
  end
I am getting this error:-
"PNG alpha channel transparency is not supported; only palette
transparency is supported."

Please help me to solve this problem.

Thanks,
Tushar
D877dec36ab3027ff7c9016e83cc1a4f?d=identicon&s=25 Jack Bauer (realmadrid2727)
on 2009-04-07 17:30
Pretty straightforward error. You need to make sure you're using a PNG
without alpha-transparency (24-bit uses them, 8-bit doesn't.)
3d9e26d3be3e7fcf93aca6574bc77a20?d=identicon&s=25 Tushar Gandhi (gandhi-tush)
on 2009-04-08 06:48
Jack Bauer wrote:
> Pretty straightforward error. You need to make sure you're using a PNG
> without alpha-transparency (24-bit uses them, 8-bit doesn't.)

Hi,
Is there no way to support those images?
Thanks,
Tushar
This topic is locked and can not be replied to.