@saurabhmauryabu
The output issue is not related to Aspose.Words rather it is related to Console.WriteLine. You may use Console.OutputEncoding property to avoid this. You can also save the output text to .txt file as shown below. Hope this helps you.
StringBuilder sb = new StringBuilder();
var document = new Document(MyDir + "Sample_Doc.docx");
GetDocumentWarnings missingfonts = new GetDocumentWarnings();
document.WarningCallback = missingfonts;
document.Save(new MemoryStream(), SaveFormat.Pdf);
foreach (Run run in document.GetChildNodes(NodeType.Run, true))
{
if (missingfonts.warnings.Contains(run.Font.Name))
sb.Append(run.Font.Name + "- " + run.Text).Append(Environment.NewLine);
}
File.WriteAllText(MyDir + "missing fonts.txt", sb.ToString());
You can use LayoutCollector.GetStartPageIndex method to get the page number of text.
var document = new Document(MyDir + "Sample_Doc.docx");
GetDocumentWarnings missingfonts = new GetDocumentWarnings();
document.WarningCallback = missingfonts;
document.Save(new MemoryStream(), SaveFormat.Pdf);
LayoutCollector collector = new LayoutCollector(document);
foreach (Run run in document.GetChildNodes(NodeType.Run, true))
{
if (missingfonts.warnings.Contains(run.Font.Name))
sb.Append("Page number : " + collector.GetStartPageIndex(run) + " - "+ run.Font.Name + "- " + run.Text).Append(Environment.NewLine);
}
Unfortunately, there is no direct API to get the line number of text. However, you can find the page number and line number of text using DocumentLayoutHelper class. You can build your logic to achieve your requirement using this class.
https://github.com/aspose-words/Aspose.Words-for-.NET