Hi Aspose support,
In our product we have functionality that converts SmartArts to images and replace SmartArt shape with resulted image shape.
Similar to what MS Word do when converts DOCX document with SmartArts into DOC/RTF format.
After testing this approach we were faced with the different issues. Please see the list:
Case#1:
Wrong fill color of SmartArt and text highlighting is not applied for text in SmartArt.
Please see screen shot of the problem (left side - how it was converted with Word, right side - with Aspose):
SmartArtColorIssue.png (276.0 KB)
Original document:Case#3.zip (34.7 KB)
Document with problem after conversion:Case#3_Converted.zip (127.4 KB)
Expected result: SmartArt fill colors and text highlighting (in converted image) should stay the same as in original SmartArt (like Word does)
Case#2:
Wrong 3D styles of SmartArts and text issues.
After conversion SmartArt to image, SmartArt loses 3D style and text inside does not fit to text box or has incorrect color, see screen shot:
3DStyleIssue.png (112.3 KB)
Source document:SmartArt 3D.zip (18.5 KB)
Resulted document after conversion:SmartArt 3D_Converted.zip (28.5 KB)
Expected result: Converted SmartArt should have 3D style and text should look the same as in original document;
-Problem with fitting text into shape bounds:
TextSizeIssue.png (54.1 KB)
Source document:TextSize.zip (15.5 KB)
Resulted document after conversion:TextSize_Converted.zip (22.0 KB)
Expected result: Text should fit to SmartArt bounds, as in original document;
-Text color problem:
TextColorIssue.jpg (212.7 KB)
Source document:TextColor.zip (333.5 KB)
Resulted document after conversion:TextColor_Converted.zip (729.4 KB)
Expected result: Text should have the same color as in original SmartArt;
Case#3:
Wrong text orientation after conversion SmartArt to image:
WrongTextOrientation.png (50.4 KB)
Source document:Case#3.zip (21.4 KB)
Converted document: Case#3_Converted.zip (20.3 KB)
Expected result: Text in converted to image SamrtArt should have the same orientation as in original document/SmartArt.
Conversion whole document to DOC format does not work for us and it does not solve the problem. Format should stay the same, but SmartArts should become images.
Tested on Aspose.Words.dll v19.8
Code sample:
ImageSaveOptions optionsPng = new ImageSaveOptions(SaveFormat.Png);
optionsPng.Scale = 2;
DocumentBuilder builder = new DocumentBuilder(_doc);
ReplaceShapes(_doc, optionsPng, builder);
private void ReplaceShapes(Document doc, ImageSaveOptions options, DocumentBuilder builder)
{
NodeCollection shapes = doc.GetChildNodes(NodeType.Shape, true);
// Loop from last one to first one
for (int i = shapes.Count - 1; i >= 0; i--)
{
try
{
Shape shape = (Shape)shapes[i];
if (!(shape.HasChart || shape.HasSmartArt)) continue;
using (MemoryStream stream = new MemoryStream())
{
shape.GetShapeRenderer().Save(stream, options);
shape.AnchorLocked = true;
builder.MoveTo(shape);
InsertImage(builder, stream, shape);
shape.Remove();
}
}
catch (Exception e)
{
}
}
}
private Shape InsertImage(DocumentBuilder builder, Stream imgContent, Node sourceNode)
{
Shape image = null;
Shape sourceShape = (Shape)sourceNode;
if (sourceShape.IsInline)
{
image = builder.InsertImage(imgContent, sourceShape.Width, sourceShape.Height);
}
else
{
image = builder.InsertImage(imgContent, sourceShape.RelativeHorizontalPosition, sourceShape.Left,
sourceShape.RelativeVerticalPosition, sourceShape.Top, sourceShape.Width, sourceShape.Height,
sourceShape.WrapType);
}
return image;
}
Please help with these problems.
Thanks.