Has anyone successfully complied the Apache FOP v1.0 library to a .NET DLL? I am using the IKVM syntax found at http://onjava.com/pub/a/onjava/2004/08/18/ikvm.html; however
I know this is an old thread but it still took some research to get this working. It is now available with NuGet in Visual Studio 2013. The NuGet package is called crispin.fop. In my code below, I pass in an "fop" file and the new PDF file I want created and "voila", it is created.
using org.apache.fop.tools;
using org.apache.fop.apps;
using org.xml.sax;
using java.io;
public void GeneratePDF(string foFile, 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(foFile));
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();
}
}