RE: Example for XSL-FO to RTF

"Madhavan Srinivasan" <[email protected]> Fri, 21 Feb 2003 12:23:34 -0800
Newsgroups gmane.text.xml.jfor.general
Message-ID <A89F357607E0F840811C68801E8853990745ADC5@mcexchange.massconnections.com>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C2D9E7.1B795C2A
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi
=20
Here's the code to convert xml to rtf using jfor.
(If you have a static word doc, you can save it as an html & using WH2FO =
tool you can create xml and xsl for your reference.)
=20
-Madhavan
=20
import org.jfor.jfor.converter.*;
import org.xml.sax.InputSource;
import java.io.*;
& other imports
public void formatWordDocument(String strXML) {
try {
//final String xslInput =3D "multiple-page-sequences.fo.xml";
final String xslInput =3D strXML;
final String rtfOutput =3D "C:/word/docs/test100.rtf";
String userDir =3D "C:/word/source";
setUserDir (userDir);
final InputSource input =3D new InputSource(xslInput);
final Writer output =3D new BufferedWriter(new FileWriter(rtfOutput));
new Converter(input,output,Converter.createConverterOption ());
} catch (Exception ex) {
logger.debug("Error:"+ex.getMessage());
System.out.println(ex.getMessage());
}
}
/** System.setProperty function (java 1.1 compatibility) */
private static void setUserDir (String dir)
{
if (dir =3D=3D null)
{
System.out.println ("relative image path is not supported");
return;
}
Properties p =3D System.getProperties ();
p.put ("user.dir", dir);
System.setProperties (p);
}
-----Original Message-----
From: Jasmin Mehta [mailto:[email protected]]
Sent: Monday, February 17, 2003 1:58 PM
To: [email protected]
Subject: [jfor-users] Example for XSL-FO to RTF


Hi,
=20
I am fresh user for jfor. I have used FOP to convert XML to PDF. I have =
used it in servlet. Now the way I am opening PDF file from JSP page =
link, I want to open RFT file same way.
=20
It will be great if I can get the step by step information about how to =
do it along with sample code of servlet. I am using JRun4 as my =
application server. I don't know at all, how to do it?=20
=20
Can somebody please help?
=20
Thanks
Jasmin
-----Original Message-----
From: Jasmin Mehta [mailto:[email protected]]
Sent: Monday, February 17, 2003 1:58 PM
To: [email protected]
Subject: [jfor-users] Example for XSL-FO to RTF


Hi,
=20
I am fresh user for jfor. I have used FOP to convert XML to PDF. I have =
used it in servlet. Now the way I am opening PDF file from JSP page =
link, I want to open RFT file same way.
=20
It will be great if I can get the step by step information about how to =
do it along with sample code of servlet. I am using JRun4 as my =
application server. I don't know at all, how to do it?=20
=20
Can somebody please help?
=20
Thanks
Jasmin

------_=_NextPart_001_01C2D9E7.1B795C2A
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns=3D"http://www.w3.org/TR/REC-html40" xmlns:o =3D=20
"urn:schemas-microsoft-com:office:office" xmlns:w =3D=20
"urn:schemas-microsoft-com:office:word"><HEAD>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Diso-8859-1">


<META content=3DWord.Document name=3DProgId>
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<META content=3D"Microsoft Word 10" name=3DOriginator><LINK=20
href=3D"cid:[email protected]" rel=3DFile-List><!--[if gte =
mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:EnvelopeVis/>
  =
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEve=
ry>
  =
<w:DisplayVerticalDrawingGridEvery>0</w:DisplayVerticalDrawingGridEvery>
  <w:UseMarginsForDrawingGridOrigin/>
  <w:Compatibility>
   <w:FootnoteLayoutLikeWW8/>
   <w:ShapeLayoutLikeWW8/>
   <w:AlignTablesRowByRow/>
   <w:ForgetLastTabAlignment/>
   <w:DoNotUseHTMLParagraphAutoSpacing/>
   <w:LayoutRawTableWidth/>
   <w:LayoutTableRowsApart/>
   <w:UseWord97LineBreakingRules/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
<STYLE>@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.25in 1.0in =
1.25in; mso-header-margin: .5in; mso-footer-margin: .5in; =
mso-paper-source: 0; }
P.MsoNormal {
	FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; =
mso-style-parent: ""; mso-pagination: widow-orphan; =
mso-fareast-font-family: "Times New Roman"
}
LI.MsoNormal {
	FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; =
mso-style-parent: ""; mso-pagination: widow-orphan; =
mso-fareast-font-family: "Times New Roman"
}
DIV.MsoNormal {
	FONT-SIZE: 10pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Times New Roman"; =
mso-style-parent: ""; mso-pagination: widow-orphan; =
mso-fareast-font-family: "Times New Roman"
}
A:link {
	COLOR: blue; TEXT-DECORATION: underline; text-underline: single
}
SPAN.MsoHyperlink {
	COLOR: blue; TEXT-DECORATION: underline; text-underline: single
}
A:visited {
	COLOR: purple; TEXT-DECORATION: underline; text-underline: single
}
SPAN.MsoHyperlinkFollowed {
	COLOR: purple; TEXT-DECORATION: underline; text-underline: single
}
SPAN.EmailStyle17 {
	COLOR: windowtext; FONT-FAMILY: Arial; mso-style-type: =
personal-compose; mso-style-noshow: yes; mso-ansi-font-size: 10.0pt; =
mso-bidi-font-size: 10.0pt; mso-ascii-font-family: Arial; =
mso-hansi-font-family: Arial; mso-bidi-font-family: Arial
}
DIV.Section1 {
	page: Section1
}
</STYLE>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */=20
 table.MsoNormalTable
	{mso-style-name:"Table Normal";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0in 5.4pt 0in 5.4pt;
	mso-para-margin:0in;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>
<![endif]--></HEAD>
<BODY lang=3DEN-US style=3D"tab-interval: .5in" vLink=3Dpurple =
link=3Dblue>
<DIV>
<DIV><SPAN class=3D297290320-21022003><FONT face=3DArial color=3D#0000ff =

size=3D2>Hi</FONT></SPAN></DIV>
<DIV><SPAN class=3D297290320-21022003><FONT face=3DArial color=3D#0000ff =

size=3D2></FONT></SPAN>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003>Here's the code to convert xml to rtf using=20
jfor.</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003>(If you have a static word doc, you can save =
it as an=20
html&nbsp;<SPAN class=3D590501120-21022003>&amp;</SPAN> using <FONT=20
face=3D"Courier New" color=3D#000000 size=3D3><FONT =
size=3D2>WH2FO</FONT><STRONG>=20
</STRONG><FONT face=3DArial color=3D#0000ff size=3D2>tool you can create =
xml and xsl=20
for your reference.)</FONT></FONT></SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003>-Madhavan</SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003></SPAN></FONT></FONT></FONT>&nbsp;</DIV>
<DIV><FONT size=3D+0><FONT size=3D+0><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003><B><FONT color=3D#7f0055>
<P><FONT face=3DArial size=3D2>import</FONT></B></FONT><FONT =
face=3DArial=20
color=3D#000000 size=3D2> org.jfor.jfor.converter.*;</FONT></P><B><FONT=20
color=3D#7f0055>
<P><FONT face=3DArial size=3D2>import</FONT></B></FONT><FONT =
face=3DArial=20
color=3D#000000 size=3D2> org.xml.sax.InputSource;</FONT></P><B><FONT =
color=3D#7f0055>
<P><FONT face=3DArial size=3D2>import</FONT></B></FONT><FONT =
face=3DArial=20
color=3D#000000 size=3D2> java.io.*;</FONT></P>
<P><SPAN class=3D297290320-21022003><FONT face=3DArial color=3D#000000 =
size=3D2>&amp;=20
other imports</FONT></SPAN></P></SPAN></FONT></FONT></FONT></DIV>
<DIV><FONT face=3DArial><FONT size=3D2><FONT color=3D#0000ff><SPAN=20
class=3D297290320-21022003><B><FONT color=3D#7f0055 size=3D2>
<P>public</B></FONT><FONT color=3D#000000 size=3D2> </FONT><B><FONT =
color=3D#7f0055=20
size=3D2>void</B></FONT><FONT color=3D#000000 size=3D2> =
formatWordDocument(String=20
strXML) </FONT><FONT size=3D2>{</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>try</B></FONT><FONT =
size=3D2> {</P>
<P></FONT><FONT color=3D#3f7f5f size=3D2>//final String xslInput =3D=20
"multiple-page-sequences.fo.xml";</P></FONT><FONT size=3D2>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>final</B></FONT><FONT =
size=3D2> String=20
xslInput =3D strXML;</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>final</B></FONT><FONT =
size=3D2> String=20
rtfOutput =3D </FONT><FONT color=3D#2a00ff=20
size=3D2>"C:/word/docs/test100.rtf"</FONT><FONT size=3D2>;</P>
<P>String userDir =3D </FONT><FONT color=3D#2a00ff=20
size=3D2>"C:/word/source"</FONT><FONT size=3D2>;</P>
<P>setUserDir (userDir);</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>final</B></FONT><FONT =
size=3D2>=20
InputSource input =3D </FONT><B><FONT color=3D#7f0055 =
size=3D2>new</B></FONT><FONT=20
size=3D2> InputSource(xslInput);</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>final</B></FONT><FONT =
size=3D2> Writer=20
output =3D </FONT><B><FONT color=3D#7f0055 size=3D2>new</B></FONT><FONT =
size=3D2>=20
BufferedWriter(</FONT><B><FONT color=3D#7f0055 =
size=3D2>new</B></FONT><FONT size=3D2>=20
FileWriter(rtfOutput));</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>new</B></FONT><FONT =
size=3D2>=20
Converter(input,output,Converter.createConverterOption ());</P>
<P>} </FONT><B><FONT color=3D#7f0055 size=3D2>catch</B></FONT><FONT =
size=3D2>=20
(Exception ex) {</P>
<P>logger.debug(</FONT><FONT color=3D#2a00ff =
size=3D2>"Error:"</FONT><FONT=20
size=3D2>+ex.getMessage());</P>
<P>System.out.println(ex.getMessage());</P>
<P>}</P>
<P></P>
<P>}</P></FONT></SPAN></FONT></FONT></FONT></DIV>
<DIV><SPAN class=3D297290320-21022003><FONT face=3DArial color=3D#0000ff =
size=3D2><FONT=20
size=3D2>
<P></FONT><FONT color=3D#3f5fbf size=3D2>/**</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#3f5fbf size=3D2>System.setProperty</FONT><FONT size=3D2> =
</FONT><FONT=20
color=3D#3f5fbf size=3D2>function</FONT><FONT size=3D2> </FONT><FONT =
color=3D#3f5fbf=20
size=3D2>(java</FONT><FONT size=3D2> </FONT><FONT color=3D#3f5fbf=20
size=3D2>1.1</FONT><FONT size=3D2> </FONT><FONT color=3D#3f5fbf=20
size=3D2>compatibility)</FONT><FONT size=3D2> </FONT><FONT =
color=3D#3f5fbf=20
size=3D2>*/</P></FONT><FONT size=3D2>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>private</B></FONT><FONT =
size=3D2>=20
</FONT><B><FONT color=3D#7f0055 size=3D2>static</B></FONT><FONT =
size=3D2>=20
</FONT><B><FONT color=3D#7f0055 size=3D2>void</B></FONT><FONT size=3D2> =
setUserDir=20
(String dir)</P>
<P>{</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>if</B></FONT><FONT size=3D2> =
(dir =3D=3D=20
</FONT><B><FONT color=3D#7f0055 size=3D2>null</B></FONT><FONT =
size=3D2>)</P>
<P>{</P>
<P>System.out.println (</FONT><FONT color=3D#2a00ff size=3D2>"relative =
image path is=20
not supported"</FONT><FONT size=3D2>);</P>
<P></FONT><B><FONT color=3D#7f0055 size=3D2>return</B></FONT><FONT =
size=3D2>;</P>
<P>}</P>
<P>Properties p =3D System.getProperties ();</P>
<P>p.put (</FONT><FONT color=3D#2a00ff size=3D2>"user.dir"</FONT><FONT =
size=3D2>,=20
dir);</P>
<P>System.setProperties (p);</P>
<P>}</P></FONT></FONT></SPAN></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Jasmin Mehta=20
  [mailto:[email protected]]<BR><B>Sent:</B> Monday, February 17, 2003 =
1:58=20
  PM<BR><B>To:</B> [email protected]<BR><B>Subject:</B>=20
  [jfor-users] Example for XSL-FO to RTF<BR><BR></FONT></DIV>
  <DIV class=3DSection1>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Hi,<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I am fresh user for =
jfor. I have=20
  used FOP to convert XML to PDF. I have used it in servlet. Now the way =
I am=20
  opening PDF file from JSP page link, I want to open RFT file same=20
  way.<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">It will be great if I =
can get the=20
  step by step information about how to do it along with sample code of =
servlet.=20
  I am using JRun4 as my application server. I don&#8217;t know at all, =
how to do it?=20
  <o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Can somebody please=20
  help?<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Thanks<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Jasmin<o:p></o:p></SPAN></FONT></P></DIV></BLOCKQUOTE></DIV>
<BLOCKQUOTE dir=3Dltr style=3D"MARGIN-RIGHT: 0px">
  <DIV class=3DOutlookMessageHeader dir=3Dltr align=3Dleft><FONT =
face=3DTahoma=20
  size=3D2>-----Original Message-----<BR><B>From:</B> Jasmin Mehta=20
  [mailto:[email protected]]<BR><B>Sent:</B> Monday, February 17, 2003 =
1:58=20
  PM<BR><B>To:</B> [email protected]<BR><B>Subject:</B>=20
  [jfor-users] Example for XSL-FO to RTF<BR><BR></FONT></DIV>
  <DIV class=3DSection1>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Hi,<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">I am fresh user for =
jfor. I have=20
  used FOP to convert XML to PDF. I have used it in servlet. Now the way =
I am=20
  opening PDF file from JSP page link, I want to open RFT file same=20
  way.<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">It will be great if I =
can get the=20
  step by step information about how to do it along with sample code of =
servlet.=20
  I am using JRun4 as my application server. I don&#8217;t know at all, =
how to do it?=20
  <o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: Arial">Can somebody please=20
  help?<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial"><o:p>&nbsp;</o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Thanks<o:p></o:p></SPAN></FONT></P>
  <P class=3DMsoNormal><FONT face=3DArial size=3D2><SPAN=20
  style=3D"FONT-SIZE: 10pt; FONT-FAMILY: =
Arial">Jasmin<o:p></o:p></SPAN></FONT></P></DIV></BLOCKQUOTE></BODY></HTM=
L>

------_=_NextPart_001_01C2D9E7.1B795C2A--


-------------------------------------------------------
This SF.net email is sponsored by: SlickEdit Inc. Develop an edge.
The most comprehensive and flexible code editor you can use.
Code faster. C/C++, C#, Java, HTML, XML, many more. FREE 30-Day Trial.
www.slickedit.com/sourceforge