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

Free Support Forum - aspose.com

The sum of the column widths are bigger than the page the table will overflow for PDF output

Hi Support,

If the table autosize is not set to “autofit to window” and the sum of the column widths are bigger than the page, the table will overflow for PDF output. Please reference the below test code. Notice that Word output looks very well. I wonder it is a defect of Aspose Word library, please clarification.

Thanks & regards.
Vincent

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

Table table = builder.startTable();

//first row
builder.getRowFormat().setHeight(0);
//first cell
Cell cell = builder.insertCell();
builder.getCellFormat().clearFormatting();
cell.getCellFormat().setWidth(150);
cell.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(150));
builder.write(“cell1”);
//second cell
cell = builder.insertCell();
builder.getCellFormat().clearFormatting();
cell.getCellFormat().setWidth(300);
cell.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(300));
builder.write(“Lorem ipsum dolor sit amet, consectetur adipiscing elit. Praesent vitae blandit lectus. Vestibulum nec dolor at leo consequat pellentesque. Ut euismod aliquet massa dapibus mattis. Nunc tristique eros nec quam feugiat vel euismod erat tincidunt. Suspendisse potenti. Quisque euismod vestibulum facilisis. Quisque tempus, lectus ut molestie fermentum, nisl purus mattis sapien, ut facilisis turpis nulla eget purus. Cras sit amet justo tortor. Curabitur sed tellus nec sem ultrices accumsan in vel est. Nunc feugiat laoreet purus, et mollis orci dictum a. Aliquam a ante risus. Integer feugiat posuere orci eu sagittis. Cras molestie diam et eros molestie interdum. Nam dignissim enim a velit fringilla a rhoncus ipsum iaculis. Cras varius orci et odio fermentum nec semper magna fermentum. Pellentesque tempor fermentum nibh ullamcorper consectetur.”);
//first cell
cell = builder.insertCell();
builder.getCellFormat().clearFormatting();
cell.getCellFormat().setWidth(200);
cell.getCellFormat().setPreferredWidth(PreferredWidth.fromPoints(200));
builder.write(“cell3”);
builder.endRow();

builder.endTable();
table.setAllowAutoFit(true);

builder.getDocument().save(“c:\test.doc”);
builder.getDocument().save(“c:\test.pdf”);

Hi Vincent,


Thanks for your inquiry. Using latest Aspose.Words 11.0.0, i managed to reproduce the problem on my side. I have logged this issue in our bug tracking system. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.

The issues you have found earlier (filed as WORDSNET-5801) have been fixed in this Aspose.Words for .NET 18.10 update and this Aspose.Words for Java 18.10 update.