docx4j.NET installation issue

694 views Asked by At

I've installed docx4j.NET 3.0.1 from Nuget with vs2012. When I try to use the library with this call

WordprocessingMLPackage.load(inputS, ""); 

I receive this error:

System.TypeInitializationException: 
The type initializer for 'org.docx4j.openpackaging.packages.OpcPackage' threw an exception.
---> System.IO.FileNotFoundException: Could not load file or assembly 'slf4j-api,
Version=1.7.6.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies

The version of slf4j-api in the docx4j.net 3.0.1 distribution is 1.7.5.0.

Is there a problem in the distribution of package?

1

There are 1 answers

0
JasonPlutext On

Check that the list of referenced DLLs in your VS project includes slf4j-api. If not, add it.

If you have the DLL properly referenced, then as per the sample code in say https://github.com/plutext/docx4j.NET/blob/master/docx4j.NET/src/samples/c%23/Docx4NET/DocxToHTML.cs, you might need something like (note the bottom line):

        // Programmatically configure Common Logging
        // (alternatively, you could do it declaratively in app.config)
        NameValueCollection commonLoggingproperties = new NameValueCollection();
        commonLoggingproperties["showDateTime"] = "false";
        commonLoggingproperties["level"] = "INFO";
        LogManager.Adapter = new Common.Logging.Simple.ConsoleOutLoggerFactoryAdapter(commonLoggingproperties);


        ILog log = LogManager.GetCurrentClassLogger();
        log.Info("Hello from Common Logging" );

        // Necessary, if slf4j-api and slf4j-NetCommonLogging are separate DLLs
        ikvm.runtime.Startup.addBootClassPathAssembly(
            System.Reflection.Assembly.GetAssembly(
                typeof(org.slf4j.impl.StaticLoggerBinder)));