Hello, Alexey!
I have a problem with Word doc where lines are grouped and placed on a top of Text area. Till they are Ungrouped, getting error “Floating shape not allowed inside textbox.” Only after physically ungrouping it in MS Word doc, I can process this doc in Aspose. I have a lot of documents with this unnecessary grouping, which I would like to ungroup through the code. Do you have any ideas? Thank you in advance.
@molshans Could you please attach your problematic input document and code that will allow us to reproduce the problem? We will check the issue and provide you more information.
GroupedLines.docx (24.8 KB)
I was planning something like that, but nothing works:
public async Task<byte[]> UngroupAnchoredLinesAsync(byte[] documentBytes, CancellationToken cancellationToken)
{
using (var stream = new MemoryStream(documentBytes))
{
var document = new Document(stream);
// Get all shapes after ungrouping
var shapes = document.GetChildNodes(NodeType.Shape, true)
.Cast<Aspose.Words.Drawing.Shape>()
.ToList();
foreach (Shape shape in shapes)
{
try
{
if (shape.Name.Contains("Straight Connector"))
{
//shape.RelativeHorizontalSize = RelativeHorizontalSize.Default;
//shape.RelativeVerticalSize = RelativeVerticalSize.Default;
//shape.WrapType = WrapType.Inline;
//shape.ZOrder = 0;
//shape.BehindText = false;
//shape.AllowOverlap = true;
}
}
catch (Exception ex)
{
// Skip shapes that can't be modified due to constraints
continue;
}
}
return await document.ToByteArrayAsync(defaultWordFormat);
}
}
@molshans Thank you for additional information. Unfortunately, the problem is not reproducible on my side. Could you please provide your implementation of document.ToByteArrayAsync(defaultWordFormat);
method? Or create a simple console application that will allow us to preproduce the problem.