You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by Raúl Trepiana <rt...@co-de.com> on 2003/04/09 09:10:28 UTC

New!!!! WordDocumentReader

					
 I´m working on '*.doc' to 'XSLFO Tree' transformer . I start with 'org.apache.poi.hdf.extractor.WordDocument' and I make a new class that makes same translation but this new class don´t write directly to an 'java.io.OutputStream', instead it implements 'org.xml.sax.XMLReader' so you have more much flexibility with result of translation. If you need serialize it to a file or to a 'java.io.OutputStream' , you can do it like this :

WordDocumentReader reader = new WordDocumentReader();
TransformerFactory f = TransformerFactory.newInstance();
Transformer t = f.newTransformer();
t.setOutputProperty( OutputKeys.INDENT , "yes" );
t.setOutputProperty( OutputKeys.ENCODING , "ISO-8859-1" );
SAXSource src = new SAXSource ( reader, new InputSource ( stream ) );
File foFile = File.createTempFile( "XXXX" , ".fo" );
t.transform( src , new StreamResult ( new FileWriter( foFile ) ) );

Note that by this way you can transform 'XSLFO Tree' to an HTML file without intermediate step of save it to a 'java.io.OutputStream' , so you avoid step of parse 'XSLFO Tree'.

I attach this class, I hope you like it and add it to POI proyect.

Thanks.

__________________________________________
Raúl Trepiana (Dpto. I+D)
Consulting and Development, S.A.
c/Los Herrán 7 · 01004 · Vitoria
Tlfno: +34 945 121010
Fax: +34 945 121011