Extract Images from Word DOCX Document using Java over CentOS 7 | Preserve Font while Extracting Images

Dear Team
I am facing an issue in fonts while extracting an image.I had attached a document file ,by extracting an image it extracted correctly in windows without any font changes but while extracting in centos 7 font style had been changed i had attached a output document (extracted in centos 7).kindly go through and provide some solution .
input::input.zip (24.3 KB)
Output::output.zip (21.8 KB)
Thank you

@jan.kathir,

You can solve this problem by simply copying following font files from Windows machine into the CentOS machine:

  • Times New Roman
  • Calibri
  • Microsoft Sans Serif

Copying latest versions of these fonts from Windows machine into CentOS machine should resolve this problem. Please upgrade to the latest 20.8 version of Aspose.Words for Java API. Also, please refer to the following sections of documetnation:

@awais.hafeez
Thanks for reply.
Actually i have few doubts which i had listed out below ,
1)By referring the document which you had mentioned i found some java code for setting the font, where I should include this code while saving pdf or some other place?
2)The document file which i had provide to you contains the font style of Times new roman which i had already installed in Centos7 again it shows different style in PDF file can i know the reason for this ?
3)Is there any path should i want to mention in my source code ( fonts path present in centos7 should mention in my source code).?

please clarify me in detail so that i can resolve the issue.

Thankyou

@jan.kathir,

Sometimes document does not render correctly on a machine because old version of font is installed on that machine. You can just copy latest versions of required fonts (e.g. from Windows 10 machine) to some custom folder(s) in CentOS machine and then use the following method to set those folders for Aspose.Words to look for TrueType fonts during rendering etc:

public void setFontsFolders(java.lang.String[] fontsFolders, boolean recursive)

Moreover, if Aspose.Words is still unable to locate fonts in default or custom folders (double check the correctness of path and directory permissions) then it will issue warnings that you can capture using IWarningCallback Interface.