在 .NET 应用程序中使用 ApacheFOP v1.0
有人成功地将 Apache FOP v1.0 库编译为 .NET DLL 吗?我正在使用 http://onjava.com 中找到的 IKVM 语法/pub/a/onjava/2004/08/18/ikvm.html;然而,编译后的DLL似乎不完整。例如,我无法将 FopFactory 对象实例化为:
using org.apache.fop.apps;
namespace Utils
{
public class PdfRender
{
public void Render()
{
FOUserAgent foUserAgent = fop.getUserAgent();
FopFactory fopFactory = FopFactory.newInstance();
}
}
}
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();
}
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
(由 FOP 用户组的人员提供)
先决条件:已安装 IKVM 0.44.0.5。
C:\Fop\Build\
ikvmc -target:library -reference:IKVM。 OpenJDK.Core.dll -recurse:C:\Fop\Build\\*.jar -version:1.0 -out:C:\Fop\fop.dll
的引用fop.dll
、IKVM.OpenJDK.*.dll
和IKVM.Runtime.dll
(Courtesy of the folks on the FOP Users Group)
Prerequisite: IKVM 0.44.0.5 installed.
C:\Fop\Build\
ikvmc -target:library -reference:IKVM.OpenJDK.Core.dll -recurse:C:\Fop\Build\\*.jar -version:1.0 -out:C:\Fop\fop.dll
fop.dll
,IKVM.OpenJDK.*.dll
andIKVM.Runtime.dll
我尝试了 ClayB 建议的方法,但没有成功。
我使用了 IKVM 0.44 和 0.46 与 FOP 0.95 和 1.0 的组合。但没有任何作用!有一些 java 库丢失并导致错误。还发生了 .net 异常:无法在 System.Security 命名空间中加载类型。我什至尝试按照 Avik Sengupta 在 http://onjava.com/pub/a/onjava/2004/08/18/ikvm.html,但卡在 lib\batik-all-1.7.jar 上。除非有人有任何进一步的解决方法,否则我确信这种方法不再适用于最新的套件。
然而,我发现了一种不同的方法,允许从 .net 调用 FOP。我希望这会对某人有所帮助:
请阅读原始文章:http://www.ptperalta.net/index.php/technology/using-apache-fop-in-net.html
I tried the approach suggested by ClayB without any success.
I used the combinations of IKVM 0.44 and 0.46 with FOP 0.95 and 1.0. But nothing worked! There're some java libs are missing and causing errors. There's also an .net exception occured: could not load type in System.Security namespace. I even tried to compile each .jar file to a dll as suggested by Avik Sengupta at http://onjava.com/pub/a/onjava/2004/08/18/ikvm.html, but got stuck on lib\batik-all-1.7.jar. Unless anyone have got any further workrounds, I'm convinced this approach is no longer working with the latest kits.
However, I found a different approach which allows one to call FOP from .net. I hope this will help someone:
Please read the original article at: http://www.ptperalta.net/index.php/technology/using-apache-fop-in-net.html
我知道这是一个旧线程,但仍然需要一些研究才能使其正常工作。现在,它可以在 Visual Studio 2013 中通过 NuGet 获得。NuGet 包称为 Crispin.fop。在下面的代码中,我传入一个“fop”文件和我想要创建的新 PDF 文件,然后“瞧”,它就创建好了。
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.
我知道这是一篇旧文章,但这篇文章没有针对 .Net Core 的解决方案。我创建了一个在
.Net Core
中运行的Apache FOP 版本 2.8
的开源纯端口。看看:FOP.NetCore
https://github.com/sorcerdon/FOP.NetCore
这是核心:
由于这是一个纯移植,这意味着它可以执行 Apache FOP 可以执行的任何操作。
I know this is an old post, but this post does not have a solution for .Net Core. I have created an open-source pure port of
Apache FOP version 2.8
that runs in.Net Core
. Check it out:FOP.NetCore
https://github.com/sorcerdon/FOP.NetCore
Here is the nuget:
Since this is a pure port, that means that it can do anything that Apache FOP can do.
ClayB 为我工作过。请记住第 2 点“将所有 JAR 文件复制到 C:\Fop\Build\”。
“全部”非常重要。请参阅此处我需要的 jar 列表:
- fop.jar
- avalon-framework-4.2.0.jar
- 蜡染-all-1.7.jar
- commons-io-1.3.1.jar
- commons-logging-1.0.4.jar
- 序列化器-2.7.0.jar
- xalan-2.7.0.jar
- xercesImpl-2.7.1.jar
- xml-apis-1.3.04.jar
- xml-apis-ext-1.3.04.jar
- xmlgraphics-commons-1.4.jar
除 fop 之外的所有 jar 都可以在文件夹“lib”中找到。
ClayB's worked for me. Please keep in mind point 2 "Copy all JAR files to C:\Fop\Build\".
"all" is very important. See here the list of jar's I needed:
- fop.jar
- avalon-framework-4.2.0.jar
- batik-all-1.7.jar
- commons-io-1.3.1.jar
- commons-logging-1.0.4.jar
- serializer-2.7.0.jar
- xalan-2.7.0.jar
- xercesImpl-2.7.1.jar
- xml-apis-1.3.04.jar
- xml-apis-ext-1.3.04.jar
- xmlgraphics-commons-1.4.jar
All the jar's other than fop you will find in folder "lib".
ClatB 也在这里工作过。请记住将所有 IKVM 库添加到您的项目中(使用 Fop 1.1 和 IKVM 7.2.4630.5)。
ClatB`s worked here too. Just remmeber to add ALL IKVM libs to your project (Worked with Fop 1.1 and IKVM 7.2.4630.5).