java - How to transfer MemoryStream to StreamSource in FopFactory? -
i using following code in fopfactory running connected packages ikvm , fop:
using org.apache.fop.tools; using org.apache.fop.apps; using org.xml.sax; using java.io; public void pdf(memorystream inpfile, string pdffile) { outputstream os = new bufferedoutputstream(new fileoutputstream(new java.io.file(pdffile))); try { fopfactory fopfactory = fopfactory.newinstance(); fop fop = fopfactory.newfop("application/pdf", os); fouseragent fouseragent = fop.getuseragent(); javax.xml.transform.transformerfactory factory = javax.xml.transform.transformerfactory.newinstance(); javax.xml.transform.transformer transformer = factory.newtransformer(); javax.xml.transform.source src = new javax.xml.transform.stream.streamsource(inpfile); javax.xml.transform.result res = new javax.xml.transform.sax.saxresult(fop.getdefaulthandler()); transformer.transform(src, res); } catch (exception ex) { throw ex; } { os.close(); } }
how transfer memorystream inpfile javax.xml.transform.stream.streamsource in fopfactory?
i found solution problem. used class dotnetinputstream here. in code, added:
java.io.inputstream streamfile = new dotnetinputstream(inpfile);
and transfer inputstream streamsource in fopfactory:
javax.xml.transform.source src = new javax.xml.transform.stream.streamsource(streamfile);
Comments
Post a Comment