0

I'm using Python.NET to create wrapper for iText.net (https://github.com/itext/itext7-dotnet).

The dll is named itext.kernel.dll and the python script is in the samne folder of all the itext dlls.

With Jetbrain dotPeek I see that itext.kernel has various namespaces; the namespace iText.Kernel.Pdf is what I need, in particular the public class PdfReader.

Here's what I'm doing (from the docs on https://pythonnet.github.io/):

import clr
clr.AddReference('itext.kernel')
sys.path.append(os.getcwd())  # the script is currently in the dll folder
from iText.Kernel.Pdf import PdfReader

But this gets me a "ModuleNotFoundError: No module named 'iText'" error.

I can't understand what it's wrong, can someone point me to the right direction? Thanks.

edit: I can import and use iTextSharp just fine, it seems iText7 has something different.

VeryStrange
  • 61
  • 1
  • 5

1 Answers1

2

Well, long story short I really wanted this to work... and solved my issue!

I tried using older builds, and I found out that build 7.0.8 worked fine.

I compared it with build 7.1.11 (the one I was having problems with) using dotPeek, and noticed it has some references, namely BouncyCastle.Crypto, Common.Logging and Common.Logging.Core.

I did put them in the project folder, but still no dice... until I noticed I was using BouncyCastle.Crypto build 1.8.6, while the itext.kernel referred build 1.8.5! Replacing with that version solved the issue.

Basically the newer builds of iText7 have 3 referenced libs, that must be present in the exact same version (at least to be imoported by pythonnet).

I hope this can help someone that has issues similar to mine.

VeryStrange
  • 61
  • 1
  • 5