8 Replies Latest reply on Nov 23, 2017 1:09 PM by DarthGuybrushOz

    cfpdf optimize

    ctreeves

      I am uploading pdf files to our server and want to save space.  I am trying to use cfpdf to optimize the file size.  The one I am testing on is 1.25MB, so it's not a big file.  When I reduce it using desktop Acrobat it takes less than 1 second.  When I use Coldfusion it times out after several minutes.

       

      The file is first uploaded to it's own directory, then I use this to try to reduce it.

       

      <cfpdf

          action = "optimize"

          source = "H:\Inetpub\Wwwroot\MySite.com\newsletters\files\#Section#\#issue#.pdf" 

          algo = "bilinear" />

       

      I'm sure it's something I've done wrong, please advise.

        • 1. Re: cfpdf optimize
          ctreeves Level 1

          Bump 

          • 2. Re: cfpdf optimize
            BKBK Adobe Community Professional & MVP

            It should take seconds, not minutes. When I tested, using the following code on a 2MB PDF, it took 8 seconds.

             

            <cfpdf

                action = "optimize"

                source =  "C:\ColdFusion11\cfusion\wwwroot\workspace\cfTest\pdf\myDoc.pdf"

                algo = "bilinear"

                pages = "*"

                destination =  "C:\ColdFusion11\cfusion\wwwroot\workspace\cfTest\pdf\myDoc_optimized.pdf" 

                overwrite = "true">

               Done optimizing.

            • 3. Re: cfpdf optimize
              ctreeves Level 1

              Thank you, I tried your code to see if I could reduce one file directly on the server as compared to while I am uploading it.  The pdf is not protected and does have many images embedded.

               

              I get this error:

              An error occurred during OPTIMIZE operation in the cfpdf tag.

              Error: com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException: Undefined filter - JPXDecode
              • 4. Re: cfpdf optimize
                BKBK Adobe Community Professional & MVP

                Your Coldfusion version?

                • 5. Re: cfpdf optimize
                  ctreeves Level 1

                  Version: 9,0,0,251028

                  • 6. Re: cfpdf optimize
                    BKBK Adobe Community Professional & MVP

                    ctreeves wrote:

                     

                    Thank you, I tried your code to see if I could reduce one file directly on the server as compared to while I am uploading it.  The pdf is not protected and does have many images embedded.

                     

                    I get this error:

                    An error occurred during OPTIMIZE operation in the cfpdf tag.

                    Error: com.adobe.internal.pdftoolkit.core.exceptions.PDFCosParseException: Undefined filter - JPXDecode

                    In my opinion, you have found a bug in ColdFusion 9. You should create a bug report, attaching the PDF file to it.

                    • 7. Re: cfpdf optimize
                      ctreeves Level 1

                      Thank you, I submitted a bug.  I may be able to migrate to CF10 in the next 6 months to a year, but this is disappointing for now.  Maybe they'll fix my bug today? 

                       

                      I appreciate your help!

                      • 8. Re: cfpdf optimize
                        DarthGuybrushOz Level 1

                        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">

                                <cfset NumberOfPages=GetPDFInfo.TotalPages>
                           
                                <cfloop index="p" from="1" to="#NumberOfPages#" step="1">
                           
                                    <cfpdf action="transform" source="mydocument.pdf" pages="#p#" overwrite="yes" destination="reducedsize.pdf" password="ifrequired">
                           
                                </cfloop>

                            </cflock>