Using Aspose.Words (22.5.0) and Aspose.Words.Shaping.HarfBuzz (22.5.0) with .net core 6. I have added these packages by NuGet package manager.
In order to enable OpenType feature i added the below snippet as per LayoutOptions.TextShaperFactory | Aspose.Words for .NET
doc.LayoutOptions.TextShaperFactory = HarfBuzzTextShaperFactory.Instance;
But it is throwing error in this line only:
The type initializer for ‘Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory’ threw an exception.
TypeLoadException: Could not load type ‘Aspose.Words.Shaping.BasicTextShaperCache’
from assembly 'Aspose.Words, Version=22.5.0.0
@23manognya Thank you for reporting this problem to us. For a sake of correction it has been logged as WORDSNET-23906. We will keep you informed and let you know once it is resolved.
Thank you. Hope it gets resolved.
@23manognya I gave this issue the highest priority. We will keep you informed and let you know once it is resolved.
I am having the same issue.
Using LinqPad 7 to prototype code.
void Main()
{
var inFile = @"C:\temp\Test.docx";
var doc = new Document(inFile);
doc.LayoutOptions.TextShaperFactory = Aspose.Words.Shaping.HarfBuzz.HarfBuzzTextShaperFactory.Instance;
doc.GetChildNodes(NodeType.Any, true)
.Where(n => n.HasProperty("Font"))
.Select(n => new { typeName = n.GetType().Name, Font = n.GetPropertyValue<Font>("Font")?.Name, Text = n.GetText() })
.Dump();
doc.WarningCallback = new HandleDocumentSubstitutionWarnings();
doc.Save(Path.ChangeExtension(inFile, ".out.pdf"), new PdfSaveOptions
{
EmbedFullFonts = false,
FontEmbeddingMode = PdfFontEmbeddingMode.EmbedNonstandard
});
}
// You can define other methods, fields, classes and namespaces here
public class HandleDocumentSubstitutionWarnings : IWarningCallback
{
/// <summary>
/// Called every time a warning occurs during loading/saving.
/// </summary>
public void Warning(WarningInfo info)
{
if (info.WarningType == WarningType.FontSubstitution)
{
info.Dump();
}
}
}
static class Helpers
{
public static bool HasProperty(this object source, string methodName)
{
var type = source.GetType();
return type.GetProperty(methodName) != null;
}
public static T GetPropertyValue<T>(this object source, string methodName) where T : class
{
if(source == null) return null;
var type = source.GetType();
var prop = type.GetProperty(methodName);
if(prop == null) return null;
return prop.GetValue(source) as T;
}
}
@vbwizardry We will keep you informed and let you know here in this thread one the version with a fix is available. Please accept our apologizes for your inconvenience.
The issues you have found earlier (filed as WORDSNET-23906) have been fixed in this Aspose.Words for .NET 22.6 update also available on NuGet.