开发者

How to use PDFBox 1.0 in .net / C# environment using IKVM

Id like to use PDFBox to generate PDF highlight files in my .net project. PDFBox states that it can be used in .net via IKVM http://www.pdfbox.org/userguide/dot_net.html

BUT running ikvmc (latest version) to generate the DLLs on PDFBOX.1.0.0.jar generates a whole lot of NoClassDefFound 开发者_JAVA百科warnings.

How should I fix this, and what other DLLs do I need to include in my project? It seems as though file names have changed from the older documentation/articles I have read on the matter.

thanks in advance.


I just came across this question while trying to figure out for myself how to get PDFBox 1.0 working. It appears that the NoClassFound errors are being generated because it can't find the referenced jars (which are in the folder titled "external"). Here's how I was finally able to get it working:

  1. Use the binaries from IKVM 0.30.00
  2. Put the pdfbox-1.0.0 jar file in the "external" folder (easier to reference)
  3. In command line, execute lkvmc.exe -target:library -out:"[Output Path]\netpdfbox.dll" "[PDFBox Path]\*.jar" <-- the *.jar tells IKVM to run include all jar files as one large assembly

You should be able to include the outputted .dll in your C# code. I was able to execute the following code without any issues:

PDDocument doc = PDDocument.load("test.pdf");
string output = new PDFTextStripper().getText(doc);


It depends on what version of PDFBox you are using. The latest releaesd version (0.7.3) uses IKVM 0.30.00. There are other versions of IKVM out there as well, and not all are backwards compatible. There is also another beta PDFBox that I believe uses a newer version of IKVM.

I'm pretty sure that the IKVM libraries that are required for each versioned release of PdfBox are in the release zip file. Be sure you use the one that comes with the release, and not the latest version of IKVM because they may not be compatible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜