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, the compiled DLL seems to be incomplete. For example, I cannot instantiate FopFactory object as:
using org.apache.fop.apps;
namespace Utils
{
public class PdfRender
{
public void Render()
{
FOUserAgent foUserAgent = fop.getUserAgent();
FopFactory fopFactory = FopFactory.newInstance();
}
}
}
Apache™ FOP It is a Java application that reads a formatting object (FO) tree and renders the resulting pages to a specified output. Output formats currently supported include PDF, PS, PCL, AFP, XML (area tree representation), Print, AWT and PNG, and to a lesser extent, RTF and TXT. The primary output target is PDF.
FOP is open source software, and is distributed under the Apache License 2.0.
Multithreading FOP FOP is not currently completely thread safe.
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();
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With