Hi All,

Im having a probs of converting a FO File available as a C# string to a J# characterStream (java.io.Reader) or byteStream (java.io.InputStream), since the org.xml.sax.InputStream accepts only these 2 formats and the path of the fo file as a string. Im aware that i can generate the fo file and write it in a dir. and give the path. But, i want to do it without IO, since the org.xml.sax.InputStream accepts byteStream and characterStream objects.

Im using NFOP for converting FO file into PDF from ASP.NET and codebehind in C#, but the NFOP is using J#. So, ive imported the required J# libs and it works fine. But, i need to convert the c# string into java.io.InputStream / java.io.Reader objects to give it as a parameter, the FO file.

Ive given below the codebehind code in C# for converting FO file into PDF. Also, apache fop site gave the 2nd code snippet to give xml and xsl files as the input, not as a file path, but as as stream.

Yours,
Sankar.B

"Code Snippet to Convert a FO File by giving the FO File Path as a string : "

string strFoPath = "C:\\simple.fo";
org.xml.sax.InputSource inputFoFile = new org.xml.sax.InputSource(strFoPath);
java.io.ByteArrayOutputStream bos = new java.io.ByteArrayOutputStream();
org.apache.fop.apps.Driver dr = new org.apache.fop.apps.Driver(inputFoFile, bos);
dr.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
dr.run();
sbyte[] sBytes = bos.toByteArray();
byte[] getBytes = new byte[sBytes.Length];
for (int i=0; i < sBytes.Length - 1; i++)
{
getBytes[i] = (byte) sBytes[i];
}


Response.ContentType = "application/pdf";
Response.AddHeader("Content-disposition", "filename=ID.pdf");
Response.OutputStream.Write(getBytes, 0, getBytes.Length);
Response.OutputStream.Flush();
Response.OutputStream.Close();

"Code snippet to give XML and XSL file as input instead of give fo and instead of giving them as a File thru a File Path : "

// org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
// driver.setRenderer(Driver.RENDER_PDF);
// Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource("foo.xsl"));
// transformer.transform(xmlsource, new SAXResult(driver.getContentHandler()));


_________________________________________________________________
MSN Messenger V6.0. Give it a fun name. http://server1.msn.co.in/sp03/ilovemessenger/index.asp Win cool stuff!



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to