Convert a document with printer metrics layout settings to PDF in Java

We are using GroupDocs.Conversion java to convert Microsoft doc files to pdf. It runs in to problem when the doc file has “Use printer metrics to lay out document” setting. GroupDocs.Conversion uses WindowsNativeCall_x64.dll which needs Microsoft Visual C++ Redistributable Packages. Can you tel me the exact version of Microsoft Visual C++ Redistributable Packages needed. When on my local machine I have Microsoft Visual C++ 2012 Redistributable, it fails to convert with following error.

java.lang.UnsatisfiedLinkError: com.groupdocs.conversion.internal.c.a.w.hU.createGlobalPrinterDC(Ljava/lang/String;)V
at com.groupdocs.conversion.internal.c.a.w.hU.createGlobalPrinterDC(Native Method)
at com.groupdocs.conversion.internal.c.a.w.hU.(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.hU.a(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.fT.(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.abC.a(Unknown Source)
Truncated. see log file for complete stacktrace

When I remove Microsoft Visual C++ 2012 Redistributable. It converts the file but does not uses Microsoft Visual C++ Redistributable and it throws following error.

Please make sure you have “Visual C++ Redistributable Packages” installed (see https://www.microsoft.com/en-us/download/details.aspx?id=30679)
java.lang.UnsatisfiedLinkError: C:<Some path>WindowsNativeCall\WindowsNativeCall_x64.dll: Can’t find dependent libraries
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1941)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1824)
at java.lang.Runtime.load0(Runtime.java:809)
at java.lang.System.load(System.java:1086)
at eB.zzvh(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.hU.(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.fT.(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.abC.a(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.abC.a(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.abC.a(Unknown Source)
at com.groupdocs.conversion.internal.c.a.w.abC.jl(Unknown Source)

It will be fine for me if converts the file but does not uses Microsoft Visual C++ Redistributable. But in the prduction system we don’t have Microsoft Visual C++ 2012 Redistributable but still the conversion fails also I don’t have a luxury to experiment on the production system. Is there a way to disable this feature so that GroupDoc will not look for any dll? Can you provide any information so that doc documents will be converted when “Use printer metrics to lay out document” is set.

1 Like

@ibmtivoli,

We need following details in order to investigate this issue:

  • GroupDocs.Conversion for Java API version
  • Problematic file(s)
  • OS details (version)

Please share the above details and we’ll surely help you out.

sorry for the delay. We have * GroupDocs.Conversion for Java API version 1.3.0

testFile.zip (5.3 KB)
Uploaded the the problematic file basically it is a .doc file when “Use printer metrics to lay out document” is set . Tested it on Windows 10.

1 Like

Actually we can’t remove Microsoft Visual C++ 2012 Redistributable from one of our machine because some other software uses that. Microsoft Visual C++ 2012 Redistributable is the recommended version so we want to know why it is not working.

@ibmtivoli,

Thanks for sharing the details.

You are using a very old version of API that has been obsoleted. Please use GroupDocs.Conversion for Java latest version 19.6.2. We have a lot of support material for your ease.
Download our open source example project here.

  • Put the source file here: \Data\SourceFiles
  • Open the project in your preferred IDE, un-comment below piece of code in MainClass.java:
    Conversion.convertToPdfAsFilePath("Source file name.docx");
  • Run the application
  • You will get output here: \Data\OutputFiles.

Get more details form the documentation
API offers a lot of helpful features such as adding watermark in the converted file, set zoom level. See more here.
This is the output generated using problematic file that you shared - output.pdf (11.7 KB)
We’d recommend you to go through the supporting material and share feedback.

@atirtahir3

Thanks for your quick replies.

I am unable to make 19.6.2 version to work correctly. Let me write the issue I am having.

If I run it the way you wrote, it works and converts the doc file correctly but throws the following warning.

SLF4J: Failed to load class “org.slf4j.impl.StaticLoggerBinder”.
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
Converted file path is: com.groupdocs.conversion.handler.ConvertedDocument@539090c0

This means it is looking for SLF4J and could not find it. The project where we use GroupDocs had SLF4J. So I copied SLF4J and log4j jar files to the path. Now I get following error.

Exception in thread “main” java.lang.IncompatibleClassChangeError
at org.slf4j.c.OR(Unknown Source)
at org.slf4j.c.bf(Unknown Source)
at com.joestelmach.natty.i.(Unknown Source)
at com.groupdocs.conversion.domain.documents.PdfDocument.parse(Unknown Source)
at com.groupdocs.conversion.domain.documents.PdfDocument.dp(Unknown Source)
at com.groupdocs.conversion.domain.documents.PdfDocument.a(Unknown Source)
at com.groupdocs.conversion.domain.documents.PdfDocument.a(Unknown Source)
at com.groupdocs.conversion.domain.documents.PdfDocument.a(Unknown Source)
at com.groupdocs.conversion.domain.DocumentBase.load(Unknown Source)
at com.groupdocs.conversion.domain.DocumentLoader.a(Unknown Source)
at com.groupdocs.conversion.domain.DocumentLoader.load(Unknown Source)
at com.groupdocs.conversion.domain.DocumentLoader.load(Unknown Source)
at com.groupdocs.conversion.operations.f.aK(Unknown Source)
at com.groupdocs.conversion.operations.F.execute(Unknown Source)
at com.groupdocs.conversion.converter.pdf.PdfConverter.convert(Unknown Source)
at com.groupdocs.conversion.converter.pdf.PdfConverter.convert(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.aJ(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.convert(Unknown Source)
at com.groupdocs.conversion.handler.ConversionHandler.convert(Unknown Source)
at com.groupdocs.conversion.examples.Conversion.convertToPdfAsFilePath(Conversion.java:420)
at com.groupdocs.conversion.examples.MainClass.main(MainClass.java:60)

I deployed GroupDocs 19.6.2 to our project and got the exact same error. Removing slf4j from our project is not possible because some other code use that. Do you have a solution for our situation?

1 Like

@ibmtivoli,

We are investigating this scenario at our end. Your investigation ticket ID is CONVERSIONJAVA-747. As we have any further update, you’ll be notified.

@atirtahir3, do you have any update on this? Did you able to reproduce the issue?

@ibmtivoli,

Issue CONVERSIONJAVA-747 is still under investigation.