I am trying to understand how the fonts are embedded when generating documents then saving them as PDFS. I have to work with fonts such as Tiro Bangla and DFKai-SB but the people proofing the documents are telling me that there is something wrong with the fonts. I am specifically trying to break the process to understand how this works and to ensure it is okay after I fix it. Here’s my test and results. I have made sure my source document does not have embedded fonts and it’s set to primarily use Tiro Bangla, I have enabled the font substitution warnings, I have deleted Tiro Bangla from the pc that is used to generate the documents (it does not have Word either). When I generate the document from my c# code I get an error “Font ‘Tiro Bangla’ has not been found. Using ‘Arial’ font instead. Reason: font info substitution.” so how then is the document produced with the correct font?
Could you please provide more information about the specific Aspose product you are using and the exact code snippet you are working with? This will help us provide a more accurate answer.
Aspose.Words Version 23.4
This is the class I implemented to be notified of Font Substitutions:
public class DocumentSubstitutionWarnings : IWarningCallback
{
public void Warning(WarningInfo info)
{
if (info.WarningType == WarningType.FontSubstitution)
{
FontWarnings.Warning(info);
if (info.Description.ToString().ToUpper().Contains("FONT"))
{
Console.WriteLine(info.Description.ToString());
}
}
}
public WarningInfoCollection FontWarnings = new WarningInfoCollection();
}
and here’s an excerpt from the document building code: Aspose.Words.Document doc = new Aspose.Words.Document(template);
foreach (StructuredDocumentTag sdt in doc.GetChildNodes(NodeType.StructuredDocumentTag, true))
{
//Console.WriteLine(sdt.SdtType.ToString());
if (sdt.Tag == "tagname")
{ System.Diagnostics.Debug.Print(sdt.Tag.ToString()); }
}
Aspose.Words.Fields.FormFieldCollection formFields = doc.Range.FormFields;
foreach (var formfield in formFields)
{
PropertyInfo property = cure.GetType().GetProperty(formfield.Name);
var fieldType = formfield.GetType();
//Console.WriteLine("on this field now...." + formfield.Name + " of type " + formfield.Type.ToString());
if (property != null)
{
var value = property.GetValue(cure)?.ToString() ?? string.Empty;
if (value == string.Empty)
{
//Console.WriteLine("field not found: " + formfield.Name);
}
if (formfield.Type.ToString() == "FieldFormCheckBox") { formfield.Checked = bool.Parse(value); }
else { formfield.Result = value; }
}
}
Do you mean the PDF is still produced with ‘Tiro Bangla’? I am not sure this is possible. Could you please attach your test input and output documents here for testing? You can learn more about font substitution process in our documentation:
https://docs.aspose.com/words/net/manipulating-and-substitution-truetype-fonts/#font-availability-and-substitution