Free Support Forum - aspose.com

Anway to detect and fix the table width- table is flowing past the right edge of the document

would like to find tables that overflow the page (right border) and fix them

Hi

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

Thanks for your request. Could you please attach your document for testing? I will investigate the issue and provide you more information.

Best regards.

here's the document

Hi

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

Thank you for additional information. There is preferred width of the table is set in your document. Unfortunately, there is no way to change this value using Aspose.Words yet. This is the issue #907 in our defect database.

However, if preferred width of the table is not specified, you can try using the following code to resize the table:

//Open document

Document doc = new Document(@"Test072\dil.doc");

//Loop through all sections in the document

foreach(Section sect in doc.Sections)

{

//Calculate width of the page of current section

double pageWidth = sect.PageSetup.PageWidth - sect.PageSetup.LeftMargin - sect.PageSetup.RightMargin - sect.PageSetup.Gutter;

//Loop throught all tables in the current section

foreach (Table tab in sect.Body.Tables)

{

//Calculate width of the table

//This will work only if widht of each cell is fixed

double tabWidth = 0;

foreach (Cell cell in tab.FirstRow.Cells)

tabWidth += cell.CellFormat.Width;

//If width of the table is greater than width of the page

//We should resize it

if (pageWidth < tabWidth)

{

//Calculate ratio

double ratio = pageWidth / tabWidth;

//Resize each cell

foreach (Row row in tab.Rows)

{

foreach (Cell cell in row.Cells)

{

cell.CellFormat.Width = cell.CellFormat.Width * ratio;

}

}

}

}

}

//Save output document

doc.Save(@"Test072\out.doc");

Unfortunately, I cannot guaranty that the code will work in all cases.

Best regards.

I am experiencing the same issue as detailed in this thread. After merging a document, tables are flowing beyond the right margin. I tried using the code listed in the thread to resize tables - but it has no effect.

Table width change does not happen when using Word functionalty to merge the same document.

Aspose.Words 6.4.0.0 was used to merge the document.

Is there some way to ensure that table and cell widths remain unchanged. This could be a show-stopper to our project - altering the layout of the original document is not a feasible option.

I've attached the original template and a view of the merged document.

Hi

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

Thanks for your request. I cannot reproduce the problem using the latest version of Aspose.Words (7.0.0). Could you please provide me sample code, which will allow me to reproduce the problem on my side or maybe, create sample application? I will check the issue and provide you more information.

Best regards,

The issues you have found earlier (filed as 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.
(61)