Wrong conversion from Docx To Png with SaveAs in Aspose.Words.Java

Hello,
I found a Docx that saved as PNG via Document.SaveAs gives a bad result: all words seems in bold. If I convert same docx, in pdf conversion is fine.
Attached docx, png and pdf.

Hi there,

Thanks for your inquiry. We have tested the scenario and have not found the shared issue. Please check the attached output Png.

Could you please share which PngSaveOptions you are using? We will investigate the issue on our side and provide you more information.

Hello,
we did many tests and found out that the issue is not related specifically to DOCX, but to Verdana Font.
If we create a document with Verdana Font and then we use Aspose.Words.Java via NetBeans saving as PNG, the document is rendered correctly and all the four Verdana.ttf are correctly retrieved from dir C:\Windows\Font (see SShot-NetBeans.PNG from ProcessExplorer in attached zip). If instead we use our program always loading Aspose.Words.Java to save same document (on same PC) as PNG, the image created miss font Verdana Regular but has the other 3 (see SShot-DesktopFonts.PNG from ProcessExplorer in attached zip).
Do you know why Aspose in this case is not able to find Verdana Regular font? In both case seems it reaches correctly directory C:\Windows\Font, but in second case seems it doesn’t look for the Regular one.
Thank you for support

Hi there,

Thanks for your inquiry.

renato.mauro:
If instead we use our program always loading Aspose.Words.Java to save same document (on same PC) as PNG, the image created miss font Verdana Regular but has the other 3 (see SShot-DesktopFonts.PNG from ProcessExplorer in attached zip).

Please note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats (JPEG, PNG, PDF or XPS). You need to install fonts on the machine where you’re converting documents to Png. Please refer to the following articles:

How Aspose.Words Uses True Type Fonts
How to Specify True Type Fonts Location
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

Moreover, we suggest you please upgrade to the latest version of Aspose.Words for Java 15.10.0. Hope this helps you. If you still face problem, please share your input document for which you are getting this issue and code example for further investigations. We will investigate the issue on our side and provide you more information.

Hello,
we already implemented use of TrueTypeFont, their localization is reached but no warning for the problematic font is given back from Aspose.
We also tried the newAspose.Words for Java 15.10.0, but the issue is still there.
Attached you can see the visualization we do with our code via Aspose of a document without Verdana that is working fine but gives back warnings on use of table (DocWithWarning.PNG).
And the visualization of the problematic document with Verdana font that doesn’t issue any warning (DocVerdanaWithoutWarning.PNG).
A detail I missed to give is that our program is written in C++ and use AsposeWords.Java through JNI. Since it consist of some layers it will take me a while to produce you a code sample.
I will do it ASAP.
Thank you.

Hi there,

Thanks for your inquiry. It would be great if you please share following detail for investigation purposes.

  • Please embed the fonts inside your input document and share it
  • Please create a standalone Java application (source code without compilation errors) that helps us reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information to
us we’ll start our investigation into your issue.

Hello,
we can provide a sample C++ that calls Aspose.Words.Java via JNI. Attached you find: the input document and the .cpp that can be compiled ( it use only aspose-words-15.10.0-jdk16.jar).
We have compiled and reproduced the issue through it.
We run on a Windows 7 machine 64 bit, but we compiled everything at 32 bit using jre1.8.0_65 (32 bit).
The Verdana font is a system windows font, so there should be no need to embed it.
Thank you for support.

Hi there,

Thanks for your inquiry. We suggest you please upgrade to the latest version of Aspose.Words for Java 15.11.0. Hope this helps you. If you still face problem, please share PngSaveOptions which you are using in your code. We will investigate the issue on our side and provide you more information.

Hello,
just tried with latest version 15.11.0 but the issue is still there.
I could not give you the PngSaveOption because the last test we send you, does directly a Save without SaveOptions (Aspose documentation/com/aspose/words/Document.html#save(java.lang.String)), passing directly the filename with extension.

We only open the input file (TestDocx.docx) and save it as Png (TestDocxConverted.png). We did this in the C++ we attached previously (main.zip) that uses Aspose.Java via JNI. In the output PNG the Verdana Normal is not present and it is substituted by Verdana Bold.

Thank you for support.

Hi there,

Thanks for your inquiry. We have tested the scenario at Windows 8.1 and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-12788. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Could you please share which operating system and Jdk version you are using?

Hi Tahir.

Thanks for your help to reproduce this issue.

The OS is Windows 7 64 bit.
The example attached in the previous post is a pure jni file (thus C/C++), so no JDK is needed; it has been built with Visual Studio 2008 9.0.30729.1 SP fully up-to-date and then run with JRE 1.8.0_66.

Anyway, in other cases, to build some Java code, the JDK is 1.8.0_66 with target 1.6, both on Windows 7 64 bit and SLES 9 and 11 32 bit.

Thank you,

Renato

Hi Renato,

Thanks for sharing the detail. We will inform you via this forum thread once this issue is resolved.

Hi Renato,

Thanks for your patience. Please use Aspose.Words for Java 15.11.0 and execute the following code example with same ImageSaveOptions at your side and share the output png here for our reference.

Please use the same ImageSaveOptions in your JINI application and share the output png.

Moreover, note that Aspose.Words requires TrueType fonts when rendering documents to fixed-page formats. Please implement IWarningCallback as shown in following link and share if you are getting any font substitution.
How to Receive Notification of Missing Fonts and Font Substitution during Rendering

Document doc = new Document(MyDir + "TestDocx.docx");
ImageSaveOptions options = new ImageSaveOptions(SaveFormat.PNG);
options.setPageIndex(0);
options.setPageCount(1);
options.setResolution(100);
doc.save(MyDir + "Windows 7 - Out.png", options);

Hello,
attached the result you required using Aspose.Words for Java 15.11.0 and ImageSaveOptions.
Main.cpp is our sample test updated with ImageSaveOption and TestDocxConverted.png is the output it produces (still not working fine).
TestDocxConvertedFromJava-Windows7.png is the output produced by the NetBeans/Java environment using the Java snippet you provided, that is working fine.

I confirm that in our complete C++ application we have already implemented successfully
IWarningCallback (for some other samples we receive warnings from Aspose), but in this specific case Aspose is not raising any warnings.

Thanks once more.
Best regards

Hi Renato,

Thanks for your feedback. Could you please share your Visual Studio 2008 complete JNI (C++) project here for further testing purposes? We will prepare the required platform to simulate the environment as of yours. As soon as everything is setup, we will test your issue on our end and will post the results here for your kind reference. Thanks for your cooperation.

Hi Tahir,
of course attached the Visual Studio 2008 solution, with project and c++ file.
We use it with Studio 2008 9.0.30729.1 SP and run with JRE 1.8.0_65 and aspose-words-15.11.0-jdk16.jar.

Best regards.

Hi Renato,

Thanks for sharing the detail. We are working over your query and will get back to you soon.

Hi Renato,

Thanks for your patience. We have tested the scenario using latest version of Aspose.Words for Java 15.11.0 and shared C++ code example at Windows 7 (64 bit), Jdk 1.8 and have not found the shared issue. We have attached the output Png with this post for your kind reference.

Hi Tahir.

Thanks for your help.
Summarizing:

  • we still reproduce the problem on Windows 7 64 bit, calling Aspose-Word-Java 15.11.0 from a C++ JNI program, either running a 32 bit or a 64 bit process, building with VS2008; this happen on every machine we tested;
  • you reproduced the same issue only on Windows 8 and have logged this problem in your issue tracking system as WORDSNET-12788.

So, we are still looking for a solution and hope that solving the issue on Windows 8 will solve it for our Windows 7 too.

Could you please confirm that WORDSNET-12788 is still pending?

Do you have any suggestion or request to make us help you investigate further (VNC session, code samples, etc.)?

Thanks again and regards,

Renato

Hi Renato,

Thanks for your inquiry. The issue (WORDSNET-12788) is not a bug. The Png file generated at Windows 8.1 has 300 resolution. The text seems to be bold but it is not bold. So, we closed this issue as ‘Not a Bug’.

We tested the scenario at Windows 7 (64 bit), Jdk 1.8 (32 bit) using same code example with Visual Studio 2015. Please let us know if we are missing anything. We are setting up Visual Studio 2008 and will test the same scenario and share our findings here for your reference. We apologize for your inconvenience.