I am running this on CF10 -
action = "optimize"
source = "original.pdf"
algo = "nearest_neighbour"
pages = "*"
destination = "new.pdf"
overwrite = "true">
Instead of optimizing the PDF file, it creates a larger file.
I noticed the issue is happening only when my PDF contains images.
Anyone having the same issue?
The best method of removing ColdFusion's PDF bloat that I've found is to use CFExecute and GhostScript.
In May 2014, I tweeted "#GhostScript reduced #ColdFusion CFDocument PDF filesize by 88% (631 PDFs; 14gb reduced to 1.7gb)" and the visual results of the files looked the same.
You can test GhostScript out by installing their portable executables to your PC and optimizing a couple PDFs:
GS.exe -sDEVICE=pdfwrite -dNOPAUSE -dQUIET -dBATCH -sOutputFile=C:\PDFTest\Ghostscript_small.pdf C:\PDFTest\Ghostscript.pdf
NOTE: You can also use a BAT file to auto-convert all PDFs within a source directory.
FOR %%Z IN (*.pdf) DO gswin64 -sDEVICE=pdfwrite -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -sOUTPUTFILE=d:\GhostScript\PDFOUT\%%Z %%Z
If Jamo's answer doesn't help, I would wonder first what update of 10 you are on. Next, since it is no longer supported (since May of this year), it may be useful for you to at least test whether the problem happens on CF11 or CF2016 (and their latest updates). Even if you didn't want to move to it, you could install, test against, and uninstall it in less than 10 minutes.
That or post an example PDF file that demonstrates the problem for you that then one of us could try, to see if we confirm the problem.
I was going to suggest the same thing as Charlie, to try it on different versions of CF - 11 and then 2016. You could use commandbox to quickly spin instances and test to see if you get the same results.
Have you tried a PDF "transform" action on your result PDF? I've found this can make a massive difference to the file size. eg:
<cflock name="PerformTransform" timeout="160" throwontimeout="yes" type="exclusive">
<cfpdf action="GetInfo" name="GetPDFInfo" source="mydocument.pdf" password="ifrequired">
<cfloop index="p" from="1" to="#NumberOfPages#" step="1">
<cfpdf action="transform" source="mydocument.pdf" pages="#p#" overwrite="yes" destination="reducedsize.pdf" password="ifrequired">