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

Free Support Forum - aspose.com

Text wrapping capabilities in a PDF table cell


I have an issue when converting of HTML page to PDF: contents of the table cells do not wrap and tables become clipped in the resulting PDF document.
I believe it’s because Aspose doesn’t support “word-break: break-all” HTML table cell style and as a result long character sequences without white spaces just expand table beyond PDF page boundaries.
This is just a guess, please confirm.
Is there any chance this capability will be introduced in the later releases?
Thank you.


<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your request. Could you please attach your input and output documents here? I will investigate the issue and provide you more information.

Best regards,

I’ve attached two files in a zip archive: sample1.htm is a source and sample1.pdf is a conversion result. You will notice that character sequences in html file are wrapped in table cells thanks to break-all style and the table in PDF gets clipped.

Thank you.

Hi Sergey,

Thanks for your inquiry.

This appears to be happening because the width attribute as percent is not fully supported when HTML is imported. We are in the process of reworking the HTML import system and this feature may be included. We will keep you informed of any developments.

In the mean time you can however fit the table to the page with only one change to your existing HTML. You can call the FitTableToPageWidth method below which will autofit the table to the page width.

public static void FitTableToPageWidth(Table table)<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />


// First run simply gets the table size (the widest row). This is used to calculate the ratio below instead of just each row length

// as the last cell in one row could be shorter than the last cell in the other row. This will preserve these different sizes when fitting.

// Set the intial table width. Let's assume no properly formed row will be less than this size.

double tableWidth = 0;

foreach (Row row in table.Rows)


double rowWidth = 0;

foreach (Cell cell in row.Cells)

rowWidth += cell.CellFormat.Width;

// If this row is larger than previous set this width as the longest row.

tableWidth = Math.Max(tableWidth, rowWidth);


// Get the page settings from the section where the table occurs, as each section can have different page settings, therefore different page sizes and margins.

Section section = (Section)table.GetAncestor(NodeType.Section);

// Calculate the width of the page

double pageWidth = section.PageSetup.PageWidth - (section.PageSetup.LeftMargin + section.PageSetup.RightMargin);

// In the second run set each cell in the row proportionally to the width of the page

foreach (Row row in table.Rows)


foreach (Cell cell in row.Cells)


// Calculate the ratio of each cell to the row width and translate this ratio to the page width.

double cellRatio = cell.CellFormat.Width / tableWidth;

cell.CellFormat.Width = (cellRatio * pageWidth);




The method should be called for the tables in your document before saving like this:

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))




However, in order for this method to work you will need to remove the width attribute from your first table. i.e <table width="100%" border="5">. This is needed because the code resizes each cell to fit the table to the page. When a width is set for a table then these changes in cell size are ignored. Currently there is no public property to remove this table width property. We will also look into making this public. We will inform you of any developments.


This workaround is very helpful. Thank you very much.

The issues you have found earlier (filed as WORDSNET-352;WORDSNET-581) have been fixed in this .NET update and in this Java update.

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

The issues you have found earlier (filed as WORDSNET-3989) have been fixed in this .NET update and in this Java update.

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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan