We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Text is wrapped in table's cell when document is saved to PDF using .NET

Hi there,

I can still reproduce this isse in Aspose.Words for.NET Version 20.6.0 using the following code:

internal static void Run()
{
    var builder = new DocumentBuilder();
    var table = builder.StartTable();

    #region header row
    var cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("Column header 1");

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("Column header 2");

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("Column 3");

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = false;
    builder.Write("Column value");
    builder.EndRow();
    #endregion

    #region row 1 
    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("column 1 description of content \n comes from A".Replace(@"\n", ControlChar.LineBreak));

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("column 2 description of content \n comes from B".Replace(@"\n", ControlChar.LineBreak));

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Left;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = true;
    builder.Write("Column 3");

    cell = builder.InsertCell();
    cell.FirstParagraph.ParagraphFormat.Alignment = ParagraphAlignment.Right;
    cell.CellFormat.PreferredWidth = PreferredWidth.Auto;
    cell.CellFormat.WrapText = false;
    builder.Write("EUR 155,499,357");
    builder.EndRow();
    #endregion

    table.Style = builder.Document.Styles[StyleIdentifier.TableNormal];
    table.AllowAutoFit = true;
    table.StyleOptions = TableStyleOptions.FirstRow | TableStyleOptions.RowBands;
    table.PreferredWidth = PreferredWidth.Auto;
    table.Alignment = TableAlignment.Left;

    builder.EndTable();
    builder.InsertBreak(BreakType.ParagraphBreak);

    builder.Document.Save("output.docx", SaveFormat.Docx);
    builder.Document.Save("output.pdf", SaveFormat.Pdf);
}

As You will see, the Text in the 4th column of 1st row wraps in PDF output.

Thanks for your help,
Peter

@pmischo

We have tested the scenario and have managed to reproduce the same issue at our side. For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-20710 . You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.