Creating a PDF on the fly

A friend and I are just in the process of trying to create PDFs on the fly. This isn't in itself too hard, but we have some repeating images that are being put in over and over again. It's increasing file size too much unfortunately.

Does anyone know the best way to ensure file size is kept to a minimum for this scenario? We know about linking to a URI, but the problem with that is that if the PDF gets sent elsewhere, we have to send the linked images with it.

Any help would be appreciated.



If you're using PDF::Writer, then it's trivial to reuse images that are repeating. You just have to do it right (and the demo chunkbacon.rb shows how).

If you're not using PDF::Writer, then you need to be more specific about your problem.


That's helpful thanks. I hadn't found the "demo" section because I was looking for "examples" :slight_smile: I have actually looked at the gem code to figure out how to load the image only once. Figured it out now, so thanks. Really helpful.