xml to formatted text

Hi

I have a XML file and I want to transform it in a formatted text (ps, RTF... no HTML) ready to be printed. I want to put tables and bold text in this document.

I have already seen SAX in Java but I only find examples to transform XML in HTML or XHTML...

Could someone help me please?

Thanx in advance

Elena

[346 byte] By [elea] at [2007-10-3 3:27:02]
# 1

Elena,

RTF is a Microsoft propietary format: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnrtfspec/html/rtfspec.asp, I suggest use some standard like PDF, you can generate PDF using Java & XSL-FO:

http://www.antennahouse.com/XSLsample/XSLsample.htm

http://www.onjava.com/pub/a/onjava/2002/10/16/fop.html

Rulasa at 2007-7-14 21:20:18 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

My main problem is that I have to convert in ps a very large number of data, so I found XSL-FO but also Java Printer Service (javax.print):

http://java.sun.com/j2se/1.4.2/docs/guide/jps/index.html

I could have a HTML input source and then transform it into ps.

Now the problem is I can't locate a suitable factory:

/* Use the preEdefined flavor for a GIF from an InputStream */

DocFlavor flavor = DocFlavor.INPUT_STREAM.TEXT_HTML_US_ASCII;

/* Specify the type of the output stream */

String psMimeType = DocFlavor.BYTE_ARRAY.POSTSCRIPT.getMimeType();

/* Locate factory which can export a GIF image stream as Postscript */

StreamPrintServiceFactory[] factories = StreamPrintServiceFactory.lookupStreamPrintServiceFactories(flavor, psMimeType);

if (factories.length == 0)

{

System.err.println("No suitable factories");

System.exit(0);

}

What do you think?

Thank you very much!

Elena

elea at 2007-7-14 21:20:18 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

Write code for print formmated documents is a hard work ! ... i.e. on my systems, a PDF document is generated, then my clients print it on your preferred PDF Viewer: Evince, Kpdf, Acrobat Reader ...

Anyway .. about your problem, that depends of your Hardware Printer Capabilities, read javax.print.PrintService ... maybe your hardware, driver effect it ....

Rulasa at 2007-7-14 21:20:18 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...