Just copying here what talked abut in the priority support (likely the subscription won’t be renewed).
Raise priority and fix WORDSJAVA-1249 - Font forced to be bold if DOCX or HTML saved to Image via JNI
Hello.
I’m very sorry to ask again for such issue (WORDSJAVA-1249), but actually the fix you kindly provided since version 16.4.0 of aspose-words for Java didn’t solved. Here the old thread.
This is a very critical problem, since currently we have to save the docx or html file to PDF and then use another tool to get the derired page as an image. This is a very slow process.
Linked a small project C++ reproducing the problem. Luckily, the issue now happens on every Windows 10 machine, whilst in the past I could only experiment on Window 7 machines and only on a few of them the issue was reproducible.
BTW, there are some issues still open since tenths of months, and I begin to have some difficulties explaining such delay, above all while the renewal is so closed.
Thank you so much for your help.
Regards,
Renato
Hello again.
Here attached you may find the sample C program that loads the JVM via JNI and save the input file. In the ‘debug’ folder there are the two input files (htm and docx) and some PNG generated with the sample program. It’s easy to see how fonts Verdana and Tahoma are rendered in bold instead of regular.
System: Windows 10 64 bit
JRE: always the last stable downloadable
aspose-words: from 16.4.0 up to 17.2.0
Visual Studio: VS 2008 and VS2015
Thank you again.
Regards,
Renato
Hello Renato,
Please notice we were not aware that the issue was not fixed for you. Sorry for the inconvenience.
I am trying to run the sample program, but after setting of paths and linker, I get the error on execution on line 25:
“Unhandled exception at 0x71AAD9C1 in TestAsposeJNI.exe: 0xC0000005: Access violation executing location 0x00000000.”
Please check the attached screenshot. I suppose you can execute the application on your side without error?
Thanks,
Boris Pazin
Enterprise Lead,
Aspose
Yes, please add to the environment path variable the path to the JVM.DLL of your JRE.
Then, please put the aspose-word jar in the solution folder.
Finally, please check the path to the input file.
Hi Renato,
Thank you for providing additional information.
We are working on this issue and will get back to you soon.
Thanks,
Boris Pazin
Enterprise Lead,
Aspose
Hi Boris.
Finally we find solved the problem: the JVM must be started passing also the option -Dfile.encoding=UTF-8.
Since 1) the C code instatiating the JVM didn’t pass it, it failed to convert Verdana fonts, and 2) running from NetBeans worked, we wrongly thought it was a JNI issue.
Then, we tried to run a jar from the command line (java.exe - jar …) and it failed with Verdana!
So finally we checked the command line of NetBeans and found that it passes such option.
Do you or your team have any consideration about such detail? And, is there any other option that it’s better (say, mandatory) to set to run aspose-words properly?
Thank you.
Regards,
Renato
Hi Renato,
I am glad you figured it out.
By default, character set for JVM is depending of operating system and that explains why it worked correctly on some computers, while didn’t work on others.
We had some rare cases where issues related to not supported encoding are resolved by adding -Dfile.encoding=UTF-8, but it’s not mandatory.
Best Regards,
Boris Pazin
Enterprise Lead,
Aspose
Hi Boris.
Yes, sure it was complex, and some questions arise:
we are wondering how Aspose is handling such subject. Is there any hint about it in the documentation?
does Aspose development team know exactly what is happening in our specific case, passing or not that option? Please, consider that there is no evidence of this kind of problems at run-time, such as exceptions or error messages.
since there were some similar, although rare, cases with the same solution, does Aspose have a guideline or a best practice about this aspect?
is there any further JVM option that Aspose advises to set, to avoid any other rare case?
Thank you for your time.
Regards,
Renato
Hi Renato,
Thank you for your questions.
-
We don’t have anything about this subject in documentation. Please notice that very few users are calling Java from C++.
-
Since it is probably encoding problem, it could be that font on problematic machine doesn’t have required glyphs, or in some other way can’t be used in default encoding. If Aspose.Words can’t use some font or only some glyphs for any reason (font is not available, doesn’t support certain encoding, not enough rights to load it etc.), they are replaced with other font. The font substitution explains why text looks different in output.
-
If certain encoding is not supported, we suggest to try it with -Dfile.encoding=UTF-8.
-
We don’t advise any JVM option to be set. Products should work with any settings. But in specific scenarios, it could be needed to adjust JVM options. Typical example is if you work with very large files, then you could use -Xms and -Xmx options to increase available memory.
Thanks,
Boris Pazin
Enterprise Lead,
Aspose
Hi Boris.
Thank you for your answers.
About question 1, please, consider that the problem occurs also running from pure JAVA.
I’d like to talk some more about point two. In this very case, what happens is different than a simple font substitution, for three reasons:
such substitution happens only saving as an image, whilst saving as PDF everything is OK. This makes us suppose that aspose-words has two different engines, also for the input parsing phase, and the image engine is less robust than the PDF one;
the font substitution does not happen as usual, in fact no font-substitution call back is called;
even assuming that the font substitution happens for some encoding or glyph problem, it’s very strange that the consequence is a style corruption, that makes a regular text run become bold.
So, it seems that the image engine, for whatever reason, does not split the input text into the right number of text runs. Sure, that option solves and this is good.
Thanks for the details shared in answer 4.
Regards,
Renato
Hi Renato,
Thank you for your comments.
I am sharing this with the team, and will get back to you when we have more details.
Thanks,
Boris Pazin
Enterprise Lead,
Aspose