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

Free Support Forum - aspose.com

Wrap the long URL in table cell using C#

Dear Ladies and Gentlemen,

I have a little Problem with URL wrapping in aspose.words.

I create a word document with aspose.words. Then I’d like to add a table with some text to the word document. This text can contains urls. Unfortunaly the URL isn’t wrapped automatically. So the right part of the created pdf file is cut off. How can I enable url wrapping?

Here is the sample code:



Dim doc As New Aspose.Words.DocumentBuilder
doc.StartTable()

doc.InsertCell()
doc.Write(“ThisIsAVeryVeryLongWord”)

doc.InsertCell()
doc.Write(“Here is the URL: http://example.org?param1=this+is+a+param&param2=moreparam&param3=1234567”)

doc.InsertCell()
doc.Write(“ThisIsAVeryVeryLongWord”)

doc.EndRow()
doc.EndTable()

doc.Document.Save(“C:\wegdamit\test.pdf”)

Sincere regards,

Björn

								<br><br>

Hi Björn,

Thanks for your query. You are trying to add text without space like (ThisIsAVeryVeryLongWord). If you do the same by using MS Word, the table’s width will be greater then page width and the last cell come out from the page.

For your kind reference, please visit following links. Please let me know, If you have any further queries.

Specifying Table and Cell Widths
CellFormat.WrapText Property

Thank you for your answer.

tahir.manzoor:

Thanks for your query. You are trying to add text without space like (ThisIsAVeryVeryLongWord). If you do the same by using MS Word, the table’s width will be greater then page width and the last cell come out from the page.

In my tests MS Word is going to wrap the url.

tahir.manzoor:

For your kind reference, please visit following links. Please let me know, If you have any further queries.

I have fixed the problem. Setting the following paramters solves the problem:
table.AllowAutoFit = False
table.PreferredWidth = PreferredWidth.FromPercent(100)

Hi Björn,

I am really thankful to you for correcting me. We always admire the positive feedback and active participation from our customers.