.NET Version

Even though PDFBox is written in Java, there is also a .NET version that is available. It utilizes IKVM to create a fully functioning PDF library for the .NET framework. The released version contains a bin directory with all of the required DLL files. For the command line applications that are available in the Java version a native windows executable is also included. This page contains information that is specific to using the .NET version of PDFBox.

How to Build for .Net

The Apache Ant build supports building for .NET via IKVM. At present, the Maven build does not.

  • Download and install version 0.42 of the IKVM binaries. Unfortunately, our build script is version-specific. It is designed for 0.42 (at the time of this writing the latest release version). It will not work with 0.38 or earlier.
  • Edit your build.xml file for the Apache Ant build to set the ikvm.dir property to the path in which you installed IKVM. You're looking for the line that says "<property name="ikvm.dir" value="."/>"
  • Type ant build.NET to build.

How to Strong-name Your PDFBox Assembly

Assuming the basic build process above is working, strong-naming is not difficult.

  • Create your .snk file using the sn program that comes with MS Visual Studio.
  • Edit your build.xml file to add <arg value="-keyfile:pdfbox.snk" /> to each of the <exec executable="${ikvmc}"> sections building a DLL. Those building EXE's do not need them.
  • Type ant build.NET to build.

Other Userful IKVM Build Options

  • To assign a version number to your DLL include the -version argument with a 4-part version number, e.g. <arg value="-version:1.2.0.2" />
  • To generate debug information include <arg value="-debug" />

log4j

PDFBox no longer requires log4j! Older versions used to require you to configure log4j before using it in .NET

Lucene

The way that IKVM works is that DLLs are only compatible when used with the dependent DLLs that are used to build them. For example, in order to build the PDFBox DLL, a lucene DLL needs to be built, then the PDFBox DLL. The PDFBox DLL now depends on that *exact* lucene DLL. This means that if you build your own version of the lucene DLL then you also need to rebuild the PDFBox DLL. Your best bet is to use the lucene/pdfbox that is shipped with PDFBox.