The prolog of an xml document is the bit before the root element and may
only contain the xml declaration and/or the doctype declaration (both are
optional). I've seen this error before when whitespace has be output to the
top of an xml file
I'd assume the problem here is that you're trying to parse a Word doc as if
its a well formed xml/xhtml document, which ain't gunna work


2009/3/9 Anthony Hixon, Jr. <[email protected]>

> Thanks Paul.
> I added that and after it still didn't work I expanded on Chris' suggestion
> of dumping my scopes (which I should have done earlier) one by one to see
> where I was dying and it turned out the content variable was coming up empty
> plus there was an extra argument being passed to convertToPDF both of which
> were killing it.
>
> After fixing the extra argument, I tried a text document instead of the
> Word file and it converted perfectly. I know the problem is with the Word
> file and I've tried different character sets but I get this error
> consistently:
>
>  *struct*
>
> detail
>
> [empty string]
>
> errorcode
>
> errorCode.javaException
>
> extendedinfo
>
> [empty string]
>
> javaexception
>
> org.xml.sax.SAXParseException
>
> message
>
> Content is not allowed in prolog.
>
> tagcontext
>
> *array [empty]*
>
> type
>
> org.xml.sax.SAXParseException
>
> Anyone got any tricks for reading in Word files with the Flying Saucer
> code? Unfortunately that's the exact file I need to convert for this
> application. I'm going to research this on the Flying Saucer site as well
> but thought someone on this list may have already figured it out.
>
> Thanks for the help everyone!
>
> On Mon, Mar 9, 2009 at 2:44 PM, Paul Bonfanti <[email protected]> wrote:
>
>>  In your CFDocument class you need to define the method convertToPDF() as
>> static as shown below:
>>
>>
>>
>> public void static convertToPDF(…)
>>
>>
>>
>> Either that or in your CFML code you need to call init() on the object.
>>
>>
>>
>> Paul
>>
>>
>>
>> *From:* [email protected] [mailto:[email protected]] *On
>> Behalf Of *Anthony Hixon, Jr.
>> *Sent:* Monday, March 09, 2009 1:51 PM
>> *To:* openbd
>> *Subject:* [OpenBD] PDF Question
>>
>>
>>
>> Ok, this will semi-lengthy so I want to start by saying I'm not a Java
>> programmer yet as I'm still learning.
>>
>>
>>
>> That said, I'm trying to get PDF generation working (sans cfpdf) using the
>> methods shared in earlier posts with flying saucer.
>>
>>
>>
>> So, I took some the shared Java code and compiled into a jar in Eclipse
>> (Hope I did it right):
>>
>>
>>
>> package com.hmc.CFWrapper;
>>
>> import java.io.*;
>>
>> import javax.xml.parsers.*;
>>
>> import org.xhtmlrenderer.pdf.ITextRenderer;
>>
>> import org.w3c.dom.Document;
>>
>> import org.xml.sax.*;
>>
>> /**
>>
>>  * @author jeanbaptiste
>>
>>  *
>>
>>  */
>>
>> public class CFDocument {
>>
>>         public void convertToPDF(OutputStream os,String html)
>>
>>                 throws Exception {
>>
>>                 DocumentBuilder builder =
>> DocumentBuilderFactory.newInstance().newDocumentBuilder();
>>
>>                 StringReader reader = new StringReader(html);
>>
>>                 Document doc = builder.parse(new InputSource(reader));
>>
>>                 ITextRenderer renderer = new ITextRenderer();
>>
>>                 renderer.setDocument(doc, null);
>>
>>                 renderer.layout();
>>
>>                 renderer.createPDF(os);
>>
>>         }
>>
>> }
>>
>>
>>
>> I then dropped the produced jar in the main lib directory of the Ready2Run
>> bundle, restarted Jetty, and proceeded to run this test code:
>>
>>
>>
>> <cfset test_pdf = "#expandpath('Resume.doc')#">
>>
>>
>>
>> <cfset f.pdf = createobject("component","components.pdf") />
>>
>> <cffile action="READ" file="#test_pdf#" variable="local.content"
>> charset="iso-8859-1" />
>>
>> <cfset f.pdf.encode(local.content,test_pdf) />
>>
>> <cffile action="WRITE" file="#test_pdf#" output="#local.content#"
>> charset="iso-8859-1" />
>>
>>
>>
>> The pdf.cfc contains:
>>
>>
>>
>> <cfcomponent displayname="htmlToPdf" output="true">
>>
>> <cffunction name="encode" access="public" output="true" returntype="void"
>> >
>>
>>             <cfargument name="content" type="string" required="true">
>>
>>             <cfargument name="pdffile" type="string" required="true">
>>
>>             <cfargument name="downloadFile" type="Boolean"
>> required="false" default="0">
>>
>>
>>
>>             <cfset local.outputPath =
>> GetDirectoryFromPath(arguments.pdffile)>
>>
>>             <cfset local.outputFile = GetFileFromPath(arguments.pdffile)>
>>
>>             <cfset local.outputFile =
>> replace(arguments.pdffile,listLast(local.outputFile,'.'),'pdf','ALL')>
>>
>>
>>
>>
>>             <cfset CFDocument =
>> Createobject("java","com.hmc.CFWrapper.CFDocument") />
>>
>>             <cfset objOutput = CreateObject("java",
>> "java.io.FileOutputStream" ).Init(CreateObject("java", "java.io.File"
>> ).Init(JavaCast("string", local.outputFile))) />
>>
>>             <cfset
>> CFDocument.convertToPDF(objOutput,arguments.content,"#expandpath('.')#/") />
>>
>>
>>
>>             <cfif arguments.downloadFile>
>>
>>               <cfcontent type="application/pdf" file="#local.outputFile#"
>> reset="yes">
>>
>>               <cfheader name="Content-Disposition"
>> value="filename=#getFileFromPath(local.outputFile)#">
>>
>>             </cfif>
>>
>>
>>
>> </cffunction>
>>
>> </cfcomponent>
>>
>>
>>
>>
>>
>> I get the error that the method convertToPDF cannot be found which I know
>> lives in the jar (or should anyway). Now, does that mean that the jar loaded
>> properly and it just can't access the method or the jar didn't load at all?
>> Where can I look to troubleshoot this? I'm just not familiar enough with
>> loading custom java classes to figure this one out without some help.
>>
>>
>>
>> Thanks!
>>
>>
>> --
>> Anthony Hixon, Jr.
>> Certified Advanced ColdFusion MX 7 Developer
>> Mobile: (706) 639-3617
>> [email protected]
>>
>>
>>
>>
>>
>
>
> --
> Anthony Hixon, Jr.
> Certified Advanced ColdFusion MX 7 Developer
> Mobile: (706) 639-3617
> [email protected]
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
Open BlueDragon Public Mailing List
 http://groups.google.com/group/openbd?hl=en
 official site @ http://www.openbluedragon.org/

!! save a network - trim replies before posting !!
-~----------~----~----~----~------~----~------~--~---

Reply via email to