Free Support Forum - aspose.com

Url wrap in table cell without tooltip break

Hi Team,

I’m having some troubles with url tooltip breaking when the same is wrapped inside the table cell.
I am using Aspose.Words.dll version 14.12.0.0

Please check the below code and advice:

    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.Writeln();
    builder.CellFormat.ClearFormatting();
    builder.StartTable();
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(100);
    builder.CellFormat.Borders.Color = Color.LightGray;
    builder.Write("View Name: Test");
    builder.EndRow();
    builder.EndTable();

    builder.CellFormat.ClearFormatting();
    builder.StartTable();
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(25);
    builder.Write("Name");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(75);
    builder.Write("1");
    builder.EndRow();
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(25);
    builder.Write("Type");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(75);
    builder.Write("2");
    builder.EndRow();
    builder.EndTable();

    builder.CellFormat.ClearFormatting();
    builder.StartTable();
    builder.InsertCell();
    builder.Write("Section: Columns");
    builder.EndRow();
    builder.EndTable();

    builder.CellFormat.ClearFormatting();

    builder.CurrentParagraph.ParagraphFormat.SpaceAfter = 0;
    builder.CurrentParagraph.ParagraphFormat.SpaceBefore = 0;

    builder.CurrentParagraph.ParagraphBreakFont.Size = 1;
    builder.InsertParagraph();

    builder.CellFormat.ClearFormatting();
    Table tbl = builder.StartTable();
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
    builder.Write("Attribute");        
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
    builder.Write("Width");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
    builder.Write("Format");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
    builder.Write("Format1");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
    builder.Write("Format2");
    builder.InsertCell();
    builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
    builder.Write("Visible");
    builder.EndRow();
    builder.CellFormat.ClearFormatting();
    for (int j = 1; j <= 3; j++)
    {
        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);

        builder.Write("http://www.google.com/");
        
        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);

        builder.Write("https://www.microsoft.com/en-in/");

        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);

        builder.Write("https://www.aspose.com/");

        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(20);
        builder.Write("https://www.aspose.com/");

        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
        builder.Write(j.ToString());

        builder.InsertCell();
        builder.CellFormat.PreferredWidth = PreferredWidth.FromPercent(10);
        builder.Write(j.ToString());
        builder.EndRow();
    }
    builder.EndTable();
   
    tbl.AutoFit(AutoFitBehavior.FixedColumnWidths);
    doc.Save("c:/pdffile.pdf"); 

Screen shot below for reference:

image.png (26.0 KB)

Please advise how I can solve the issue ?

Thanks in anticipation.

Tushar

@tushar_608-1,

Thanks for your inquiry. Please use CellFormat.WrapText property to wrap the text of cell. You can set its value to false if you do not want to wrap text inside table’s cell. If you still face problem, please ZIP and attach your expected output document here for our reference. We will then provide you more information about your query.

i tried your solution for Wrap cell but it is not working. still tool tip on URL is breaking the text. please suggest. attached the PDF for issue.PdfFileeeeeeee25.pdf (44.7 KB)

@ManishJhs,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you create the same document using MS Word and convert it to PDF, you will get the same output.