Hello, to convert files from XSL-FO format to PDF format, use the following code that works with connected IKVM and FOP packages:
using org.apache.fop.tools; using org.apache.fop.apps; using org.xml.sax; using java.io; public void PDF(string 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(new java.io.File(inpFile)); javax.xml.transform.Result res = new javax.xml.transform.sax.SAXResult(fop.getDefaultHandler()); transformer.transform(src, res); } catch (Exception ex) { throw ex; } finally { os.close(); } } The variable inpFile passes the path to the XSL-FO file. How to make inpFile transfer a file via a MemoryStream to a StreamSource?
UPD: I mean, how to implement stream transfer when the parameter value in the method has already been assigned the type Memorystream, i.e. worth PDF (Memorystream inpFile, string pdfFile). And if you simply pass it to javax.xml.transform.stream.StreamSource (inpFile), then an error is output because This class requires the string value of the parameter.