0
votes

I am using prawn to generate pdf files which have lots of images so they come out quite large. I can open the file in Adobe Acrobat and then save it using the "reduce file size" option, and a 164MB file shrunk to 7MB and retained all of the image quality. I would like to replicate this compression in Ruby. I have tried using the compression settings which prawn offers and they have not had any effect on the file size. I suspect there must be a way to do it with RMagick, but I haven't figured it out yet.

I apologize for not including any code samples showing what I have tried, but I removed the prawn compression settings when they didn't have any effect, so I don't have anything to show.

1
You're asking us to recommend ways to solve the problem, without showing us what you tried. That means we toss out ideas, you say you tried those, we give more ideas, you say you tried those. That's not how SO works. "minimal reproducible example" and meta.stackoverflow.com/questions/261592 describe the process. - the Tin Man
I tried enabling both compress and optimize_objects on the prawn document. Anything else you recommend will be new ideas. Is there somewhere you would recommend me asking a conceptual question rather than here? I am looking for ideas, and didn't know where else to ask. - Brandon

1 Answers

0
votes

Have you tried simply making a copy of the PDF with RMagick? That is, read in the PDF and write it back out again.

Also, check with the ImageMagick folks at https://www.imagemagick.org/discourse-server/. Any advice they offer you can be implemented via RMagick.