I believe, if I haven't completely forgotten all of
this, that you actually have call document.open()
before trying to use the xml conversion.  Otherwise,
iText is attempting to write to a closed document.  

Before a document is open is when you can add the
properties, encryption, etc.  So try adding a call to
Document.open() before attempting to run the xml/xslt
conversions.

Hope this helps a little.
--- quokka quokka <[EMAIL PROTECTED]> wrote:
> Hello,
> 
> I am just starting to use iText.  I have implemented
> a
> few tests with success.  Now I am trying to convert
> an
> XML file to PDF, very similar to example 0703.  In
> fact if I use the 0703 xml and tagmap files, I have
> no
> problem with the conversion.  However, if I use my
> own
> (very simple) files, I get the following error:
> 
> Testing conversion of XML to PDF file
> ExceptionConverter: ExceptionConverter:
> com.lowagie.text.DocumentException: The
> document is not open yet; you can only add Meta
> information.
>         at
>
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1111)
>         at
>
org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1139)
>         at com.lowagie.text.xml.XmlParser.go(Unknown
> Source)
>         at
> com.lowagie.text.xml.XmlParser.parse(Unknown Source)
>         at xmlToPdf.main(xmlToPdf.java:30)
> The document is not open yet; you can only add Meta
> information.
> The xml file is as follows:
> <?xml version="1.0"?>
> 
> <GREETING>
>    <TEXT>Hello World PDF Test</TEXT>
> </GREETING>
> 
> The tagmap file is:
> <tagmap>
>    <tag name="iText" alias="GREETING" />
>    <tag name="newpage" alias="NEWPAGE" />
>    <tag name="paragraph" alias="TEXT">
>       <attribute name="leading" value="14" />
>       <attribute name="size" value="10" />
>       <attribute name="style" value="italic" />
>       <attribute name="align" value="left" />
>    </tag>
> </tagmap>
> I am not sure if I have developed the tagmap files
> correctly but from the examples it seemed close.  I
> have tried a few other forms without success as
> well. 
> But it appears to me that the problem is probably
> not
> with the tagmap file anyway.
> 
> The java file (excerpt) is:
>    public static void main(String[] args) {
> 
>       System.out.println("Testing conversion of XML
> to
> PDF file");
> 
>       // Step 1: Create a document object
>       Document document = new Document();
> 
>       try {
> 
>          // Step 2: Create a writer that listens to
> the document
>          // and directs a XML-stream to a file
>          PdfWriter.getInstance(document, new
> FileOutputStream("test/HWTest.pdf"));
> 
>          // Step 3: Parse the document
>          XmlParser.parse(document,
> "test/HWTest.xml",
> "test/tagmapHWTest.xml");
>       }
> 
>       catch (Exception e) {
>          e.printStackTrace();
>          System.err.println(e.getMessage());
>       }
>    }
> I have also used SAXParser with the same results.
> 
> A final note is that the file is created but is
> empty.
>  Does anyone have any ideas?
> 
> Thanks,
> 
> Marie
> 
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Autos - Get free new car price quotes
> http://autos.yahoo.com
> 
> 
>
-------------------------------------------------------
> This sf.net email is sponsored by: Jabber - The
> world's fastest growing 
> real-time communications platform! Don't just IM.
> Build it in! 
> http://www.jabber.com/osdn/xim
> _______________________________________________
> iText-questions mailing list
> [EMAIL PROTECTED]
>
https://lists.sourceforge.net/lists/listinfo/itext-questions


__________________________________________________
Do You Yahoo!?
Yahoo! Autos - Get free new car price quotes
http://autos.yahoo.com


-------------------------------------------------------
This sf.net email is sponsored by: Jabber - The world's fastest growing 
real-time communications platform! Don't just IM. Build it in! 
http://www.jabber.com/osdn/xim
_______________________________________________
iText-questions mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Reply via email to