Issue while rendering converted HTML from docx on another page

Hi Team,
After converting docx to html we are embeding generated html page on our application.
This generated html is causing issues with existing text on page it is making few of the characters bold and few of them as it is e.g. Test 123

To debug this issue we removed base64 from generated font-faces and it was working.
Can you please have a look into this issue?

E.x.
Generated font-face which is causing issues.

@font-face {  font-family: 'Arial';  font-style: italic;  font-weight: normal;  src: local(''), url('data:application/x-font-woff;[huge base64 of font data]');}

After changing above font-face to below we didn’t saw the issue

@font-face {  font-family: 'Arial';  font-style: italic;  font-weight: normal;  src: local('');}

@Vishaldekar

It seems that you are using Aspose.Words. To ensure a timely and accurate response, please attach the following resources here for testing:

  • Your input document.
  • Please attach the output file that shows the undesired behavior.
  • Please attach the expected output file that shows the desired behavior.
  • Please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing.

As soon as you get these pieces of information ready, we will start investigation into your issue and provide you more information. Thanks for your cooperation.

PS: To attach these resources, please zip and upload them.

Thanks for the quick reply.
Please find the attached resources.
Issue is occurring when we are embedding generated html on other page which affects other fonts . Also this is very specific to this document only.
Let me know if you need any more information for my side.
resources.zip (317.7 KB)

@Vishaldekar

Your issue is related to Aspose.Words. So, we have moved it to Aspose.Words’ forum where you will be guided appropriately.

@Vishaldekar Most likely the problem occurs because when you export your document to HtmlFixed format font subset is embedded into the output CSS. Font subset means that only glyphs used in the exported document are present in the font. Once you insert the exported HtmlFixed document on your page, your page uses the font subset from HtmlFixed and if text on the page uses the same font there might be a situation when there is a glyph that does not exist in the font subset and alternative font is used.

You can resolve this by setting UseTargetMachineFonts option. In this case, Aspose.Words does not embed fonts into the output HtmlFixed document and fonts installed on the target machine are used.

It will be great if you can explain me how it is working without base64 part

Thanks

Also one thing we are using Aspose conversion in java and you sent me the link for .net
HtmlFixedSaveOptions.UseTargetMachineFonts | Aspose.Words for .NET

can you please check this once?

@Vishaldekar In Aspose.Words for Java API there is the same option HtmlFixedSaveOptions.setUseTargetMachineFonts(). When it is set to true fonts from target machine will be be used to display the document, just like in regular HTML. But you should note if the specified font is not available on the target machine, browser will select an alternative font and content might be displayed differently than the original.

Thanks a lot @alexey.noskov for quick responses

1 Like