Title: Problem using org.xml.sax.InputSource with XmlParser

Hello, I'm a newbie with iText and I'm trying to create a CF custom tag to wrap around XML code in order to create a PDF.

I have the following script, where thisTag.generatedContent is a string containing the XML code,  which doesn't work...

<CFSCRIPT>

document = createObject("java","com.lowagie.text.Document").init();
pdfFile = createObject("java","java.io.FileOutputStream").init("/usr/local/web/intertest/test_itext.pdf");
writer = createObject("java","com.lowagie.text.pdf.PdfWriter").getInstance(document,pdfFile);

xmlCode = createObject("java","java.io.StringReader").init(thisTag.generatedContent);
xmlSource = createObject("java","org.xml.sax.InputSource").init(xmlCode);

tagStream = createObject("java","java.io.FileInputStream").init("/usr/local/web/intertest/test_xml2pdf_tagmap.xml");
tagMap = createObject("java","com.lowagie.text.xml.TagMap").init(tagStream);

document.open();
createObject("java","com.lowagie.text.xml.XmlParser").parse(document,xmlSource,tagMap);
document.close();

</CFSCRIPT>

The CF error I get is that the document has no pages.

However, I can get the following to work...

<CFSCRIPT>

document = createObject("java","com.lowagie.text.Document").init();
pdfFile = createObject("java","java.io.FileOutputStream").init("/usr/local/web/intertest/test_itext.pdf");
writer = createObject("java","com.lowagie.text.pdf.PdfWriter").getInstance(document,pdfFile);

xmlStream = createObject("java","java.io.FileInputStream").init("/usr/local/web/intertest/test_xml2pdf.xml");

tagStream = createObject("java","java.io.FileInputStream").init("/usr/local/web/intertest/test_xml2pdf_tagmap.xml");
tagMap = createObject("java","com.lowagie.text.xml.TagMap").init(tagStream);

document.open();
createObject("java","com.lowagie.text.xml.XmlParser").parse(document,xmlStream,tagMap);
document.close();

</CFSCRIPT>

It also works when I use "/usr/local/web/intertest/test_xml2pdf.xml" instead of xmlStream.

I'm not sure how I can check whether xmlSource is a valid SAX source, but I'm gussing there's something wrong with the way I'm converting the character string into org.xml.sax.InputSource.

Can anyone help me out with this?

Thanks,
Chris Stevenson
Web Administrator
[EMAIL PROTECTED]
61 2 6244 1029 P
61 2 6244 1299 F

Reply via email to