Issue exporting AUTO_FIT_TO_CONTENTS table inside text box to PDF

Hello,

We have identified a width difference between identical tables inside and outside text box with AUTO_FIT_TO_CONTENTS enabled when exporting to PDF. This works correctly (no visible width difference) when exporting to DOCX. Can you please investigate?

Code snippet:

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

//Insert a table
builder.startTable();
builder.insertCell();
builder.write("Table");
builder.endRow();
builder.endTable();
builder.insertParagraph();

//Insert a text box
Shape shape = new Shape(document, com.aspose.words.ShapeType.TEXT_BOX);
shape.setAnchorLocked(true);
shape.setHeight(100d);
shape.setWidth(100d);
builder.insertNode(shape);

Paragraph paragraph = new Paragraph(document);
shape.appendChild(paragraph);

builder.moveTo(paragraph);

//Insert a table in side the textbox
builder.startTable();
builder.insertCell();
builder.write("Table");
builder.endRow();
builder.endTable();

Table table1 = (Table) document.getChild(NodeType.TABLE, 0, true);
//adding borders seems to highlight and increase the difference between the two tables
table1.setBorders(LineStyle.SINGLE, 3.0, Color.BLACK);
table1.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);

Table table2 = (Table) document.getChild(NodeType.TABLE, 1, true);
table2.setBorders(LineStyle.SINGLE, 3.0, Color.BLACK);
table2.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);

PDF export:

Aspose.WORDS version: 24.9
Aspose.PDF version: 22.2

@dfinsolutions

You have shared a code snippet where you are using Aspose.Words only and it looks like the query is also related to it. We are moving your inquiry to the respective forum category where you will be assisted accordingly.

1 Like

@dfinsolutions
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.

Issue ID(s): WORDSNET-27620

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.