Free Support Forum - aspose.com

How to add Blank Cell in a Row

I am trying to add a blank Cell in a row. Basically I am trying replicate the following html scenario using Aspose.

1) 799.4 CACHEXIA  

Is there a way to add a blank Cell just the way I have for my second

in the html.

Thanks,

Saikat

I am trying to add a blank Cell in a row. Basically I am trying replicate the following html scenario using Aspose.

<tr>

<td width="33%">1) 799.4 CACHEXIA</td>

<td width="33%"> </td>

<td width="33%">

Is there a way to add a blank Cell just the way I have for my second

in the html.

Thanks,

Saikat

Hi Saikat,


Thanks for contacting support.

In order to accomplish your requirement, please try using the following code snippet. Please note that every table cell contains one of more paragraph objects and in case you want to add a blank table cell, you may ignore adding any paragraph inside it. Text is treated a paragraph level object.

For your reference, I have also attached the resultant PDF file generated over my end.

[C#]

//Instantiate Document object by
calling its empty constructor
<o:p></o:p>

Aspose.Pdf.Document doc = new Aspose.Pdf.Document();

// add page to Document object

Aspose.Pdf.Page page= doc.Pages.Add();

//Instantiate a table object

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

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

page.Paragraphs.Add(tab1);

//Set with column widths of the table

tab1.ColumnWidths = "130 50 80";

//Set default cell border using BorderInfo object

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

//Set table border using another customized BorderInfo object

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

//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;

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

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

row1.Cells.Add("1) 799.4 CACHEXIA");

row1.Cells.Add("");

row1.Cells.Add("3rd Column");

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

row2.Cells.Add("item1");

row2.Cells.Add("item2");

row2.Cells.Add("item3");

//Save the Pdf

doc.Save("c:/pdftest/TableResult_DOM.pdf");

Thanks, it worked.

how to ask question regarding pdf?

@kritisuman,

Thanks for contacting support.

You can freely ask any query related to Aspose.Pdf product family and we will love to answer it.