Free Support Forum - aspose.com

HorizontalMerge PDF output

When using HorizontalMerge, rendering to PDF doesn’t produce the correct output. See the two sample documents attached. The Word output renders correctly. They were created using the following code:

        Builder.StartTable()

Builder.InsertCell()
Builder.CellFormat.Width = ConvertUtil.InchToPoint(5)
Builder.CellFormat.HorizontalMerge = CellMerge.First

Builder.Write(“Long text…”)

Builder.InsertCell()
Builder.CellFormat.ClearFormatting()
Builder.CellFormat.HorizontalMerge = CellMerge.Previous

Builder.EndRow()


Builder.CellFormat.ClearFormatting()

Builder.InsertCell()
Builder.CellFormat.Width = ConvertUtil.InchToPoint(2.5)

Builder.Write(“1”)

Builder.InsertCell()
Builder.CellFormat.Width = ConvertUtil.InchToPoint(2.5)

Builder.Write(“2”)



Builder.EndRow()

Builder.EndTable()

Hi Jesse,

Thanks for your inqury.

I believe this happening because you are setting the width of both cells in the top row to 5 inches, as set with the code Builder.CellFormat.Width = ConvertUtil.InchToPoint(5);
This call will set both cells each to 5 inches making the entire top row 10 inches long. When opened in Word the table is automatically resized to the page width but upon rendering there is no such autofitting taking place so the content runs off the page.

To fix this I believe you need to set the above line of code to 2.5 instead of 5.

If you have any further queries feel free to ask.

Thanks,