Hello,
I have noticed differences when saving as DOCX and PDF. The column widths differ in the output formats. The column widths should fit to the content, this does not work in PDF. The bug occurs when cells are merged.
Tested with Aspose.Words for Java 18.7 and 20.3.
Steps to Reproduce:
Using the following code:
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);Font font = builder.getFont();
font.setSize(9);
font.setName(“Arial”);builder.insertCell();
builder.write(“Part Number”);builder.insertCell();
builder.write(“Description”);builder.insertCell();
builder.write(“Qty”);builder.insertCell();
builder.write(“Unit List Price”);builder.insertCell();
builder.write(“Unit Contract Price”);builder.insertCell();
builder.write(“Unit\nDiscounted\nPrice”);builder.insertCell();
builder.write(“Extended Discounted Price”);builder.endRow();
builder.insertCell();
builder.write(“”);// Whenever a cell is merged, the bug occurs
builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.FIRST);
builder.write(“”);builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);builder.insertCell();
builder.getCellFormat().setHorizontalMerge(CellMerge.PREVIOUS);// the following has no effect
Table table = (Table)doc.getChild(NodeType.TABLE, 0, true);
table.autoFit(AutoFitBehavior.AUTO_FIT_TO_CONTENTS);doc.save(“.\test.docx”);
doc.save(“.\test.pdf”);
For example, the text in the first column is wrapped in the PDF.
Maybe the same problem as in (I cannot open the example to verify it):
Best regards
Ingo