Is there a way to insert HTML fragment with FontFamily into a document, Font not available for Aspose without changing it with Arial or other subtitutes?
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.insertHtml("<p style=\"margin-top:0pt; margin-bottom:0pt; font-size:11pt\"><span style=\"font-family:Calibri\">Text</span></p>");
doc.save("C:\\Temp\\out.docx");
But if you save the document to fixed document format such as PDF, the font will be substituted if the specified font is not available. The fonts are required to build document layout. If Aspose.Words cannot find the font used in the document, the font is substituted . This might lead into fonts mismatch and document layout due to the different fonts metrics. You can implement IWarningCallback to get notifications when font substitution is performed.
Please see our documentation to learn where Aspose.Words looks for fonts: https://docs.aspose.com/words/java/specifying-truetype-fonts-location/
Even if I save it to docx the font is substiuted.
In my case I do not need to save it in any case, I use a document just to re-extract the HTML.
I try to explain it better…
I extract the HTML regarding a specific namedRange from an xlsx document using Aspose.cells, let’s call it ExcelHTML
The ExcelHTML is complicated, with javascript a css I don’t need.
I noticed that if I use that ExcelHTML inserting it into a document and then I extract it again like:
Ok, it makes sense.
So the problem seems to happen only if HTML produced by Aspose.cells expresses font-family in the form “Font1, Font2;” and Font1 (or maybe both) is not available for Aspose.words.
Well, I’ll try to ask Aspose.cells team about this.
Thanks for now