Some special characters in text boxes in Word documents are not rendered correctly.
My system:
macOS 10.14.3, dotnet 2.2, Aspose.Words 19.2.0
eg. This text box in a Word document contains less-than, greater-than and asterisk characters:
original.jpg (4.6 KB)
When I load the document and save the shape using the ShapeRenderer they are all invalid:
shape_Textfeld 2.png (1.5 KB)
I am using this code to render it:
try
{
var stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ShapeRenderer.Shape.docx");
var document = new Document(stream);
var shape = document.GetChildNodes(NodeType.Shape, true).ToArray().First() as Shape;
var shapeRenderer = shape.GetShapeRenderer();
var imageSaveOptions = new ImageSaveOptions(SaveFormat.Png)
{
Resolution = 96.0f, DmlRenderingMode = DmlRenderingMode.DrawingML, UseGdiEmfRenderer = false,
UseAntiAliasing = true, UseHighQualityRendering = true, DmlEffectsRenderingMode = DmlEffectsRenderingMode.Fine,
MetafileRenderingOptions = {RenderingMode = MetafileRenderingMode.VectorWithFallback},
};
var renderedFileName = $"/tmp/shape_{shape.Name}.png";
shapeRenderer.Save(renderedFileName, imageSaveOptions);
Console.WriteLine($"Rendered shape can be found at {renderedFileName}");
}
catch (Exception exception)
{
Console.WriteLine($"Cannot render image: {exception.Message}");
}
This is my test project with the Word document:
ShapeRenderer.zip (25.0 KB)
Thanks in advance for your help.