I'm looking for a library to compress large PDFs i...
# lucee
a
I'm looking for a library to compress large PDFs in Lucee (5.4.4.38); think 40MB PDF with lots of figure images and text. Quick research suggested iText, or a paid library like Aspose PDF. Anyone got a recommendation? Thanks!
g
I suggest iText it is widely used and I have used it personallly
m
a
Thanks to both of you. Will look into ghostscript for sure. on the iText front - just calling the base optimize command didn't make a material difference to the size. I needed to iterate over the embedded images and resize all those too. I found some Java code in the top answer here that looked really promising https://stackoverflow.com/questions/20614350/compress-pdf-with-large-images-via-java and used chatGPT to convert to CFScript, but I could not get past the part where is stated using Buffered Images like here
Copy code
BufferedImage img = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
AffineTransform at = AffineTransform.getScaleInstance(FACTOR, FACTOR);
I will have another go at converting that code. I got stuck trying to figure out how to import java.awt.Image. I am running with JDK 11, so I was surprised that wasn't just available to me. I need to read more.