Hi, about RowFormat.AllowAutoFit I’ve made some test and there are different results with documenti builder and native method.
This 2 snippet make the same thing, but only the native method produce an effective AutoFit.
Native Method:
Dim doc As New Document()
Dim tb As New Table(doc)
Dim c As Cell
Dim rw As Row
'First row
rw = New Row(doc)
rw.RowFormat.AllowAutoFit = True
c = New Cell(doc)
c.AppendChild(New Paragraph(doc))
c.FirstParagraph.AppendChild(New Run(doc))
rw.Cells.Add(c)
c = New Cell(doc)
c.AppendChild(New Paragraph(doc))
c.FirstParagraph.AppendChild(New Run(doc, "Long text in the second cell"))
rw.Cells.Add(c)
tb.Rows.Add(rw)
'Second row
rw = New Row(doc)
c = New Cell(doc)
c.AppendChild(New Paragraph(doc))
c.FirstParagraph.AppendChild(New Run(doc, "Native"))
rw.Cells.Add(c)
c = New Cell(doc)
c.AppendChild(New Paragraph(doc))
c.FirstParagraph.AppendChild(New Run(doc))
rw.Cells.Add(c)
tb.Rows.Add(rw)
doc.FirstSection.Body.Tables.Add(tb)
doc.Save("D:\nativedemo.docx", SaveFormat.Docx)
Document builder method
Dim doc As New Document()
Dim db As New DocumentBuilder(doc)
db.StartTable()
db.RowFormat.AllowAutoFit = True
'Firs Row
db.InsertCell()
db.Write("")
db.InsertCell()
db.Write("Long text in the second cell")
db.EndRow()
'Second Row
db.InsertCell()
db.Write("Doc builder")
db.Write("")
db.EndRow()
db.EndTable()
doc.Save("D:\demodocbuild.docx", SaveFormat.Docx)
Where am I wrong in document builder demo ?