Code: Select all
pages = Magick::Image.from_blob(book.to_pdf.render){ self.density = 300 }
page = pages[0]
image_file = Tempfile.new(['preview_image', '.png'])
image_file.binmode
image_file.write( page.to_blob { |opt| opt.format = "PNG" } )
I've scoured the net, including this forum, for older posts that might apply to the older version to try and figure out how to generate the transparent PNGs. It's surely supported, but, so far I haven't been able to figure out the right combination of settings.
To verify that it wasn't the PDF generation that was the problem, I downloaded a PDF generated on Heroku and successfully converted it using the above code (slightly modified to read the file in instead of generate it) to a transparent PNG.
Some of the things I've tried in various combinations are:
Code: Select all
page.matte = true
Code: Select all
page.format = "PNG32"
Code: Select all
page.background_color = "none"
Code: Select all
page.transparent_color = "white"
Code: Select all
page.transparent("white")
I'm also investigating including a compiled binary of a more up to date Imagemagick on Heroku.
Any help is appreciated.