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

Free Support Forum - aspose.com

Problem with RowSpan for Cell in First Row of Table

I am attempting to Span a Cell over 2 rows and I can do it without issue if the cell is not on the first row of the table, but as soon as I set RowSpan = 2 on a cell in the first row an exception is thrown in the Save Method. This code is copied from a response on this forum regarding RowSpan that I have altered to to provide an example:



var document = new Document();
var page = document.Pages.Add();
page.PageInfo.Height = 711f + 9f + 9f;
page.PageInfo.Width = 468f + 9f;
//page.MediaBox = new Rectangle(0,0,477,729);
//page.BleedBox = new Rectangle(9, 9, 477, 720);
page.TrimBox = new Rectangle(9f, 720f, 468f + 9f, 9f);
page.PageInfo.Margin = new MarginInfo { Bottom = 0, Top = 0, Left = 0, Right = 0 };
var tab1 = new Table();
//Add the table in paragraphs collection of the desired page
page.Paragraphs.Add(tab1);

//Set with column widths of the table
tab1.ColumnWidths = “120 120 120”;

//Set default cell border using BorderInfo object
tab1.DefaultCellBorder = new BorderInfo(BorderSide.All, 0.1F, Color.Red);
//Set table border using another customized BorderInfo object
tab1.Border = new BorderInfo(BorderSide.All, 1F, Color.Blue);

//Create MarginInfo object and set its left, bottom, right and top margins
var margin = new MarginInfo();
margin.Top = 5f;
margin.Left = 5f;
margin.Right = 5f;
margin.Bottom = 5f;
//Set the default cell padding to the MarginInfo object
tab1.DefaultCellPadding = margin;

var row1 = tab1.Rows.Add();
var cell1 = new Cell();
cell1.Paragraphs.Add(new TextFragment(“Column 1” ));
row1.Cells.Add(cell1);
//Create rows in the table and then cells in the rows
row1.Cells.Add(“col2”);
row1.Cells.Add(“Should span 2 Rows”);
row1.Cells[2].RowSpan = 2;

var row2 = tab1.Rows.Add();
row2.Cells.Add(“item1”);
row2.Cells.Add(“item2”);
row2.Cells.Add(“item3”);

var row3 = tab1.Rows.Add();
// set the default cell border for row as None
row3.DefaultCellBorder = new BorderInfo((int) BorderSide.None);
row3.Cells.Add(“item1”);
row3.Cells[0].IsNoBorder = true; //Set the border for cell0 as None
row3.Cells.Add(“item2”);
row3.Cells.Add(“item3”);
row3.Cells[2].IsNoBorder = true; //Set the border for cell2 as None
//row3.Cells[2].RowSpan = 2;

var row4 = tab1.Rows.Add();
row4.Cells.Add(“item1”);
row4.Cells.Add(“item2”);
row4.Cells.Add(“item3”);

document.Save(myDir+@“RowSpan_Border_Test.pdf”);

Thanks in advance.

Jon

Hi Jon,


Thanks for your inquiry. I've managed to reproduce the issue at my end and logged it as PDFNEWNET-35211 in our bug tracking system for further investigation and resolution. You will be notified via this thread as soon as it is resolved.


Sorry for the inconvenience faced.


<span style=“font-size:10.0pt;line-height:115%;font-family:“Arial”,“sans-serif”;
mso-fareast-font-family:Calibri;mso-ansi-language:EN-US;mso-fareast-language:
EN-US;mso-bidi-language:AR-SA”>Best Regards,

Hi Jon,


Thanks for your patience.

I am pleased to share that the issue reported earlier has been resolved and its hotfix will be included in upcoming release of Aspose.Pdf for .NET 8.1.0, which is planned to release within current week. In order to create a correct output, please try using the following code snippet.

[C#]

Document doc = new
Document();<o:p></o:p>

Page page = doc.Pages.Add();

page.PageInfo.Height = 711f + 9f + 9f;

page.PageInfo.Width = 468f + 9f;

page.PageInfo.Margin = new Aspose.Pdf.MarginInfo();

page.PageInfo.Margin.Bottom = 0;

page.PageInfo.Margin.Left = 0;

page.PageInfo.Margin.Right = 0;

page.PageInfo.Margin.Top = 0;

Aspose.Pdf.Table tab1 = new Aspose.Pdf.Table();

//Add the table in paragraphs collection of the desired page

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "120 120 120";

//Set default cell border using BorderInfo object

tab1.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 0.1F, Aspose.Pdf.Color.Red);

//Set table border using another customized BorderInfo object

tab1.Border = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.All, 1F, Aspose.Pdf.Color.Blue);

//Create MarginInfo object and set its left, bottom, right and top margins

Aspose.Pdf.MarginInfo margin = new Aspose.Pdf.MarginInfo();

margin.Top = 5f;

margin.Left = 5f;

margin.Right = 5f;

margin.Bottom = 5f;

//Set the default cell padding to the MarginInfo object

tab1.DefaultCellPadding = margin;

Aspose.Pdf.Row row1 = tab1.Rows.Add();

Aspose.Pdf.Cell cell1 = new Aspose.Pdf.Cell();

cell1.Paragraphs.Add(new TextFragment("Column 1"));

row1.Cells.Add(cell1);

//Create rows in the table and then cells in the rows

row1.Cells.Add("col2");

row1.Cells.Add("Should span 2 Rows");

row1.Cells[2].RowSpan = 2;

Aspose.Pdf.Row row2 = tab1.Rows.Add();

row2.Cells.Add("item1");

row2.Cells.Add("item2");

// row2.Cells.Add("item3");

Aspose.Pdf.Row row3 = tab1.Rows.Add();

// set the default cell border for row as None

row3.DefaultCellBorder = new Aspose.Pdf.BorderInfo(Aspose.Pdf.BorderSide.None);

row3.Cells.Add("item1");

row3.Cells[0].IsNoBorder = true; //Set the border for cell0 as None

row3.Cells.Add("item2");

row3.Cells.Add("item3");

row3.Cells[2].IsNoBorder = true; //Set the border for cell2 as None

row3.Cells[2].RowSpan = 2;

Aspose.Pdf.Row row4 = tab1.Rows.Add();

row4.Cells.Add("item1");

row4.Cells.Add("item2");

doc.Save(“c:/pdftest/RowSpanIssue.pdf”);

The issues you have found earlier (filed as PDFNEWNET-35211) have been fixed in Aspose.Pdf for .NET 8.1.0.


This message was posted using Notification2Forum from Downloads module by Aspose Notifier.