Font rendering doesnt match the actual one displayed in MSWord

Hi,
Attached is the screenshot of the differences between aspose generated and actual MSWord rendering. The font doesn’t seem to be the same though they are available for use in the system(Times New Roman,Symbol,Arial,Arial Black,Courier New). Aspose based rendered fonts are kind of thin than actual. Attached screenshot and test document for reference. I used below code to achieve the same.

Document doc = new Document("/Users/doc/00-Blank.doc");

for (int page = 0; page < doc.getPageCount(); page++)
{
    Document extractedPage = doc.extractPages(page, 1);
    extractedPage.save("/Users/temp/"+String.format("Output_%d.jpg", page + 1));
}

00-Blank.doc.zip (16.6 KB)

@maheibm Actually you are using not quite efficient code to convert document to images. You are using Document.extractPages method, which is designed to extract content as a flow document. If your goal is to convert document to images, it is better to use Document.save method:

Document doc = new Document("C:\\Temp\\in.doc");
    
ImageSaveOptions opt = new ImageSaveOptions(SaveFormat.JPEG);
for (int page = 0; page < doc.getPageCount(); page++)
{
   opt.setPageSet(new PageSet(page));
   doc.save("C:\\Temp\\"+String.format("Output_%d.jpg", page + 1), opt);
}

Output_1.jpg (72.8 KB)
Output_2.jpg (6.6 KB)

The problem on your side might occur because the fonts used the documents are not available in the environment where documents are converted. To build an accurate document layout the fonts are required. If Aspose.Words cannot find the fonts used in the document the fonts are substituted. This might lead into the layout differences due to differences in fonts metrics. You can implement IWarningCallback to get a notification when font substitution is performed.
The following articles can be useful for you:
https://docs.aspose.com/words/java/specify-truetype-fonts-location/
https://docs.aspose.com/words/java/install-truetype-fonts-on-linux/

Hi,
Thanks for the quick response. Even in the output files you shared the fonts are still not right. Its the same and not closer to MSWord. I did try the IwarningCallback and no subsitution was made as fonts were available to use.

@maheibm Unfortunately, I do not see the problem. As I can see the document is rendered the same way as it looks in MS Word on my side. I have also compared document rendered by MS Word and Aspose.Words (the same layout engine is used for rendering document to PDF and Image) and the result is identical:
Aspose.Words: out.pdf (56.5 KB)
MS Word: ms.pdf (32.7 KB)

You can compare yourself the output of Output_1.jpg and out.pdf and let me know. Attached screenshot too

@maheibm Unfortunately, I do not see the problem:


There is slight difference that might be caused by the font interpretation by PDF consumer application.