aspose file tools*
The moose likes XML and Related Technologies and the fly likes Converting RTF to XSL-FO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Converting RTF to XSL-FO" Watch "Converting RTF to XSL-FO" New topic
Author

Converting RTF to XSL-FO

Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
Hello Everyone,
I am looking for a API which can convert a RTF file to XSL-FO file format.
Please give me a solution as early as possible.

I am currently exploring JFO API. Is there any one here who uses JFO for the same task?



Thank you all in advance.
Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
Can anyone please tell me if it is possible or not at least? I need a solution as early as possible.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
Converting RTF to XSL-FO doesn't really make sense. RTF files contain the text and pictures of a document, plus the its style information. XSL-FO contains no text, just instructions on how to format a document in the abstract. So what is it you're really trying to do?


Ping & DNS - my free Android networking tools app
Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
Thank you Ulf Dittmer,

What you are saying is right.
Our requirement is in such a way that we have to find a solution to convert a RTF or DOC file to xml-fo.

We are actually doing this manually (Donkey's work) and storing it in one of the table column as CLOB column type. From this column our program will fetch the XSL-FO data and render it in to a PDF file using other API's. Hope this makes sense to you now.

Please give me your ideas if you have any.

Regards,
Rajan S
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
Actually, it still doesn't make sense to me. You've just repeated that you want to convert an RTF document to an XSL-FO document. I'll repeat that that makes no sense in the general case. What should happen to the text (and possibly images) in the RTF? XSL-FO makes no provisions for those. Should the contents go into an XML file, so that you can use the XSL-FO file to render it to some other format?

In RTF, every page can have a different style. That's generally not the case with XSL-FO files, which tend to have lots of repeated content. So how are your documents structured?

Knowing the answers to these questions would give us a better chance at helping you.
Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
What should happen to the text (and possibly images) in the RTF?
A. The text in the RTF will be converted in to XSL-FO with the text only. Fortunately we don't have any images coming up in the RTF we get. So nothing to worry about images.

Should the contents go into an XML file, so that you can use the XSL-FO file to render it to some other format?
A. Yes, the MS word does the job of converting the RTF file in to an XML first and we use the MS office XSL plug-in and convert the XML file to an XSL-FO wiht the help of the XSL files from Microsoft. After this we use this XSL-FO data to create an PDF file by using some external API's Like Apache FOP.

Our requirement is very simple if you ask me.
The clients will give us some letters in RTF or DOC format. We have to just save this in the database. Our application has to convert this in to a PDF format and attach it with the other PDF documents and generate an output as one PDF file. Since XSL:FO is the general format to convert in to a PDF file we are converting the RTF file in to an XSL-FO format and converting in turn in to a PDF to get the output.

Regards,
Rajan S
Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
Ulf Dittmer,

Hope it gives you a clear picture of what exactly I am trying to get.
Please feel free to share your thoughts about the same.

Regards,
Rajan S
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18566
    
    8

Originally posted by Rajan Samraj:
Our requirement is very simple if you ask me.
The clients will give us some letters in RTF or DOC format. We have to just save this in the database. Our application has to convert this in to a PDF format and attach it with the other PDF documents and generate an output as one PDF file.
Yes, that is straightforward. You have an RTF document and you want to convert it to a PDF document.
Since XSL:FO is the general format to convert in to a PDF file we are converting the RTF file in to an XSL-FO format and converting in turn in to a PDF to get the output.
This is where I lost track, too. I couldn't understand what the purpose of the intermediate XSL-FO step was. If you need to convert RTF to PDF, why not just convert straight to PDF? Converting to XSL-FO would be like converting your RTF to a Java program that produced a PDF file.
Rajan Samraj
Greenhorn

Joined: Sep 20, 2007
Posts: 6
Hello Paul Clapham,


quote:
This is where I lost track, too. I couldn't understand what the purpose of the intermediate XSL-FO step was. If you need to convert RTF to PDF, why not just convert straight to PDF? Converting to XSL-FO would be like converting your RTF to a Java program that produced a PDF file.

Hello


My application has to generate some reports based on some values dynamically and create these reports in PDF format.
The letters are all in the form of xsl-fo in one of the table columns. which were created by our team manually with the help of MS Word and the plug-in.
Now there is a new requirement where the client will come up with a new letter to be added to the same list. Now this new letter should also be saved in the same column in the form of xsl-fo to be picked up dynamically by our program and create a single pdf file along with the other previously generating files.



The clients want me to create a maintenance page in JSP to store the new letter in the same table column. Therefore I now have to just convert this RTF or DOC file in to a xsl-fo and save in the table column under the old list of records just by a click of a button.

Hope this makes easy to understand the work around.

Please let me know your thoughts about my requirement. I need to solve this issue at a high priority. Please do help me out.


Thank you,

Rajan S
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41816
    
  62
Now things are getting clearer. You don't want to convert the RTF into an XSL-FO stylesheet (which doesn't contain text), you want to convert it into an XSL-FO document (which does contain text).

The JFO API you mentioned claims to do that. I'm not aware of any other API that does that, and certainly no open source one. Automating page layout in this manner is not an easy task.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting RTF to XSL-FO