7 Replies Latest reply on May 6, 2006 1:52 AM by BKBK

    CONVERT WORD .DOC TO PDF W/CFDOCUMENT

    drforbin1970 Level 1
      Shouldn't the following generate a valid PDF file? Well, it does NOT, the format is PDF but the output is garbage. The entire output is 'crunched' into the first quarter of the first page of the PDF (for lack of a better description). Tried closing IE, rerunning, etc, etc, - no change.

      <cfdocument name="report" format="PDF" filename="temp.pdf" mimetype="application/msword" overwrite="yes" fontembed="Yes" pagetype="letter" encryption="40-bit" permissions="AllowPrinting,AllowCopy" margintop="0.1" marginleft="0.1" marginright="0.1">
      <cfinclude template="mywords.doc">
      </cfdocument>

      Any ideas????
        • 1. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
          Dan Bracuk Level 5
          No it shouldn't generate a valid pdf file. Nice try though.

          What you have to do is somehow, read the word file, save the content in a variable, and put the variable in your cfdocument. Or something like that.
          • 2. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
            Level 7
            or shell out 300 bucks and buy neevia.com docconverter. it's outstanding.
            we've been using it for over a year now for all to-from conversion when
            dealing with PDF. pretty easy API, too.

            "drforbin1970" <webforumsuser@macromedia.com> wrote in message
            news:e2120n$t85$1@forums.macromedia.com...
            > Shouldn't the following generate a valid PDF file? Well, it does NOT, the
            > format is PDF but the output is garbage. The entire output is 'crunched'
            > into
            > the first quarter of the first page of the PDF (for lack of a better
            > description). Tried closing IE, rerunning, etc, etc, - no change.
            >
            > <cfdocument name="report" format="PDF" filename="temp.pdf"
            > mimetype="application/msword" overwrite="yes" fontembed="Yes"
            > pagetype="letter"
            > encryption="40-bit" permissions="AllowPrinting,AllowCopy" margintop="0.1"
            > marginleft="0.1" marginright="0.1">
            > <cfinclude template="mywords.doc">
            > </cfdocument>
            >
            > Any ideas????
            >


            • 3. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
              Mr Black Level 1
              There is also thing called "SolidConverter". Cheap. Something like $40-$50. No API. Have to use command-line mode. Tricky and ugly, but works.
              • 4. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
                Level 7
                going from this:
                http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/cfobje28.htm
                One could save a file as html and then include it in the pdf.
                I've only tried simple docs. (CFMX 7, M$ Word needs to be on the machine)

                <CFTRY>
                <!--- If it exists, connect to it --->
                <CFOBJECT ACTION="CONNECT" CLASS="Word.Application" NAME="WordApp"
                TYPE="COM">
                <CFCATCH>
                <!--- The object doesn't exist, so create it --->
                <CFOBJECT ACTION="CREATE" CLASS="Word.Application" NAME="WordApp"
                TYPE="COM">
                </CFCATCH>
                </CFTRY>
                <!--- grab the content; add line breaks; few other fixes --->
                <cfscript>
                WordApp.Visible = FALSE;
                WordDoc = WordApp.Documents;
                newDoc =
                WordDoc.open('#GetDirectoryFromPath(GetBaseTemplatePath())#test.doc');
                //myRange = newDoc.Range(0);
                newDoc.saveAs('#GetDirectoryFromPath(GetBaseTemplatePath())#testdoctohtml.html',
                Val(8));
                //documentContent=myRange.text;
                newDoc.Close();
                WordApp.Quit();
                WordApp = "Nothing";
                //documentContent = Replace(documentContent, Chr(13), "<BR>", "ALL") ;
                //documentContent = Replace(documentContent, "�", "'", "ALL") ;
                //documentContent = Replace(documentContent, " � ", " - ",
                "ALL") ;
                // apostrophes are interpreted as =; change
                //documentContent = Replace(documentContent, "=s", "'s", "ALL") ;
                //documentContent = "<P>" & documentContent & "</P>" ;
                </cfscript>
                <cfsavecontent variable="thehtmldoc">
                <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

                <html>
                <head>
                <title>Untitled</title>
                </head>

                <body>
                <!--- <cfoutput>#documentContent#</cfoutput> --->
                <!--- <cfdump var="#newDoc#" > --->
                <cfinclude template="testdoctohtml.html">
                </body>
                </html>
                </cfsavecontent>
                <cfdocument name="report" format="PDF" filename="testdoctopdf.pdf"
                overwrite="yes" fontembed="Yes" pagetype="letter"
                encryption="40-bit" permissions="AllowPrinting,AllowCopy" margintop="0.1"
                marginleft="0.1" marginright="0.1">
                <cfdocumentsection ><cfoutput>#thehtmldoc#</cfoutput></cfdocumentsection>
                </cfdocument>
                <cfoutput>#thehtmldoc#</cfoutput>

                HTH,
                --
                Tim Carley
                www.recfusion.com
                info@NOSPAMINGrecfusion.com
                • 5. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
                  drforbin1970 Level 1
                  I also tried that using CFFILE to read the Word .doc, save in a variable and then put the variable in the CFDOCUMENT.

                  Didn't work. Same result.

                  I think I'll look into one of the suggestions here about having Word on the server to use it's object. I don't believe we have Word on the server box.

                  Thanks.

                  >No it shouldn't generate a valid pdf file. Nice try though.

                  >What you have to do is somehow, read the word file, save the content in a variable, and put the variable in your cfdocument. Or >something like that.
                  • 6. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
                    rupeshk
                    CFDocument is meant for creating dynamic documents. It generates PDF/Flashpaper from a given HTML content. It is not an universal to-from converter. So you can not use this tag to convert a word file into pdf. You might need to take a look at some other solution.

                    Mimetype attribute in the cfdocument tag is used to define the mimetype for the content that you would get in 'src' attribute. This is provided so that you can have plain text/ only image /HTML in the pdf.
                    • 7. Re: CONVERT WORD .DOC TO PDF W/CFDOCUMENT
                      BKBK Adobe Community Professional & MVP
                      From Coldfusion cfdocument documentation:
                      "The cfdocument tag does not support the Internet Explorer-specific HTML generated by Microsoft Word."