1

Im trying to PDF an image, my image size is 1MB, the final PDF is 20 MB. I have already compressed the image to its minimum usable size. What Can I do?

<cfdocument format="pdf" scale="50" overwrite="yes" localUrl="true" filename="result.pdf">
    <cfoutput>
        <img src="small.jpg" height="90%" width="90%" />
    </cfoutput>
</cfdocument>

UPDATE: As has been pointed out, this question has been asked before. I dont want to delete it for posterity, but have voted to close it myself.

Community
  • 1
  • 1
Sajjan Sarkar
  • 3,900
  • 5
  • 40
  • 51
  • What do you plan to do with the pdf once you have created it that you can't do with the image file? – Dan Bracuk May 02 '16 at 16:14
  • @DanBracuk Its a business need. I need a PDF which is not 20 tims bigger than the image! – Sajjan Sarkar May 02 '16 at 16:18
  • 2
    @SajjanSarkar - As mentioned in other threads, cfdocument tends to generate bloated files. If you must stick with cfdocument, try `` or [an external tool](http://stackoverflow.com/questions/30463886/compressing-a-pdf-document-generated-by-coldfusion#30650477) – Leigh May 02 '16 at 16:40
  • Which is your coldfusion version? – rrk May 02 '16 at 19:10
  • 1
    Since there are already several threads [suggesting alternatives](http://stackoverflow.com/questions/30463886/compressing-a-pdf-document-generated-by-coldfusion#30650477), one of them [quite recently](http://stackoverflow.com/questions/36967017/coldfusion-cfdocument-pdf-alternatives/36968149#36968149), I'm voting to close as a duplicate. – Leigh May 02 '16 at 20:26
  • @RejithRKrishnan CF11 update 7 – Sajjan Sarkar May 03 '16 at 13:56
  • @Leigh Ok, if u feel so. – Sajjan Sarkar May 03 '16 at 13:57
  • My experience w/CFDocument has been that it generates bloated PDFs. I'd be interested in seeing comparison of the same HTML w/JPG being converted to a PDF using CF9, 10, 11, 2016, WKHTMLTOPDF and then optionally reduced using GhostScript to compare the visual results & file sizes. – James Moberg May 03 '16 at 14:30
  • @SajjanSarkar - It is certainly a valid question, but it seems like the same question has been asked an answered .. a few times :). Sadly, the problem is that cfdocument tends to generate big pdf's. Not a whole lot you can do about it other than try and "optimize" afterward, or use one of the external tools suggested in the other threads. However, if you have already tried them, and they still do not resolve the problem, feel free to update your question with more details. – Leigh May 03 '16 at 22:15
  • @Leigh your point is fair and well made. I have not tried the other solutions other than because using another software/plugin/exe requires approval from the server guys. I was hoping that there's be a "purer" CF approach. Unfortunately (and bewilderingly because Adobe is the premier PDF producer in the world) there seem to be none, as u said. I will close the post myself. Thank you for your time. – Sajjan Sarkar May 04 '16 at 14:31

1 Answers1

1

Whenever CFDocument fails me with weird issues like this, I've always had success using WKHTMLTOPDF as a backup. If you're able to install this on your server, it's easy to send commands with CFExecute:

http://wkhtmltopdf.org/

CFMLBread
  • 734
  • 3
  • 7