Replace iText with OpenPDF

In this Blog, i will show what steps are required to replace the PDF-Library used in BIRT. Incredibly enough, BIRT uses iText 2.1.7 which dates back to 2009.

OpenPDF comes in very handy as it is a fork from iText4 and claims to be (and proved so in this project) a drop-in replacement. At the time of writing, OpenPDF is not available on Eclipse Orbit. So you have to get OpenPDF on maven repository.

Unfortunatly, OpenPDF imports sun.misc which obviously can’t be found by Eclipse. So we have to build a System-Bundle that exports sun.misc from the JDK like this:
/usr/lib/jvm/jdk1.8.0_271/bin/jar -cfm ch.adiinfo.system.extensions-0.0.1.jar”

The manifest-File being:

Bundle-ManifestVersion: 2
Bundle-SymbolicName: ch.adiinfo.system.extensions
Bundle-Version: 0.0.1
Fragment-Host: system.bundle; extension:=framework
Bundle-Name: Framework Extension
Bundle-Description: Bundle exporting Sun's sun.misc
Export-Package: sun.misc

These two Bundles ( ch.adiinfo.system.extensions-0.0.1.jar and OpenPDF.jar) must be made available in a Repo. One can’t use a local directory as this will work in Eclipse IDE, but not for the Build with the Maven-Tycho plugin. Tycho does not accept directories as bundle source.

I will show in a separate Blog how to build a Repository as this step is needed as well for Apache Batik.

Furthermore, you have to change dependencies in the Eclipse project and replace the iText.jar with the OpenPDF.jar in MANIFEST.MF (package

Regarding the build environment, there is also work to do:

Step one:
Search for plugin-id’s in the project’s XMl-Files referencing “com.lowagie.text” and replace them with your new OpenPDF id. Most likely, this will be “com.github.librepdf.openpdf” if you did not explicitly renamed it to another id.

Step two:
The Maven-Tycho-Plugin has the source-code option activated. So unless you want to include the source in you OpenPDF Bundle, we have to exclude this Bundle from the source-code option.

Look out for POM-Files an add this to the maven-tycho-plugin:

    <!-- provide plug-ins not containing any source code -->
    <plugin id="com.github.librepdf.openpdf" />

So the result will look like this:

      <plugin id="com.github.librepdf.openpdf" />

0 Kommentare

Schreiben Sie einen Kommentar

Ihre E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.