views:

782

answers:

2

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 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.

A: 

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.

Nick
Thanks Nick, Looks like they havent updated sourceforge to their latest release, there is a 1.0 release but sourceforge lists .7.3 as the latest. http://pdfbox.apache.org/download.html#pdfboxMy issue is that 1.0 no longer includes the IKVM DLLs and using IKVM 'from scratch' to generate them doesnt appear to work correctly.I was hoping to use 1.0 as this is for a production system but I will try .7.3
Evan
@Evan - I am using 0.7.3 in a production system right now, and at least for what I use it for, it works just fine. Your mileage may vary.
Nick
+1  A: 

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);
Randal