Epub creation - text box not converting correctly

ParagraphResolverEmptyParagraphs from https://forum.aspose.com/t/62838

using this code to convert…

Document doc = new Document(_sourceFilePath);
ParagraphResolverEmptyParagraphs resolver = new ParagraphResolverEmptyParagraphs();
doc.Accept(resolver);
doc.Range.Replace("\v", string.Empty, false, false);

NodeCollection paragraphs = doc.GetChildNodes(NodeType.Paragraph, true);
foreach(Paragraph paragraph in paragraphs)
{
    paragraph.ParagraphFormat.Alignment = ParagraphAlignment.Justify;
}
doc.Save(_destinationFilePath, SaveFormat.Epub);

attached is the source doc and converted epub(had to add the.zip to upload)
I have a number of text-boxes in my source file. On the first page the text is black. On the second page the last few lines of text are black. All other text-boxes have white text.

In the converted epub the text is outside the text-box area for all text-boxes.
In the cases of white text because of the page background they are invisible.

What options are available to ensure that text-boxes convert properly?

Thanks in advance.

Hi Brian,
Thanks for your inquiry.
You are correct, at the moment text boxes export the text content separately from the box. We are working on this issue and will fix it in a future version. We will keep you informed of any developments.
In the mean time as a work around you can convert text boxes to tables, which will retain almost all of the formatting when exporting to HTML based formats. The code can be found at the end of this post. You can use it like this:

Node[] docNodes = doc.GetChildNodes(NodeType.Shape, true).ToArray();
foreach(Shape shape in docNodes)
{
    if (shape.ShapeType == ShapeType.TextBox)
    {
        ConvertTextboxToTable(shape);
    }
}
///
/// Converts a textbox to a table by copying the same content and formatting across.
/// Export to HTML will render the border of textboxes separately to the text so we convert these
/// textboxes to tables so background shading and borders can be retained around text
///
private static void ConvertTextboxToTable(Shape textbox)
{
    Document doc = (Document) textbox.Document;
    DocumentBuilder builder = new DocumentBuilder(doc);
    builder.MoveTo(textbox.ParentParagraph);
    // Create a table to replace the textbox and transfer the same content and formatting to it.
    Table table = builder.StartTable();
    builder.InsertCell();
    builder.EndRow();
    builder.EndTable();
    // If the textbox was not the child of a table we should set the tables indent
    // to match the position that the textbox was on the page
    if (textbox.GetAncestor(NodeType.Cell) == null)
        table.FirstRow.RowFormat.LeftIndent = textbox.Left;
    table.FirstRow.FirstCell.CellFormat.Borders.Color = textbox.StrokeColor;
    table.FirstRow.FirstCell.CellFormat.Borders.LineWidth = textbox.StrokeWeight;
    table.FirstRow.FirstCell.CellFormat.Shading.BackgroundPatternColor = textbox.Fill.Color;
    table.FirstRow.RowFormat.HeightRule = HeightRule.Exactly;
    table.FirstRow.RowFormat.Height = textbox.Height;
    table.FirstRow.FirstCell.CellFormat.Width = textbox.Width;
    table.FirstRow.RowFormat.AllowAutoFit = false;
    table.FirstRow.FirstCell.FirstParagraph.Remove();
    // Append all content to the new table
    Node[] textBoxNodes = textbox.GetChildNodes(NodeType.Any, false).ToArray();
    foreach(Node node in textBoxNodes)
    {
        table.FirstRow.FirstCell.AppendChild(node);
    }
    textbox.Remove();
}

Thanks,

The issues you have found earlier (filed as 18390) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.