Copying rows


I need to be able to copy a row in a table in my xml and add it to the table programatically, changing the values in the cells of each row. I’ve tried the code below, but the only row that shows up on my pdf with any data in it is the last row that I add. It’s not that the rows aren’t getting added, it’s that I keep overwriting my segment values on each iteration. Can anyone help me out? Here’s what I have so far:




Insured Value


while (dr.Read())
Row newRow = new Row(tAircraftFormat);
newRow.Cells = rAircraftFormat.Cells;
Segment sMake = PDFHelper.FindSegment(newRow, “sMake”);
if (sMake != null)
sMake.Content = dr[“makeModel”].ToString();
Segment sSerial = PDFHelper.FindSegment(newRow, “sSerial”);
if (sSerial != null)
sSerial.Content = dr[“serial”].ToString();
Segment sInsuredValue = PDFHelper.FindSegment(newRow, “sInsuredValue”);
if (sInsuredValue != null)
sInsuredValue.Content = dr[“insuredValue”].ToString();


public static Segment FindSegment(Row row, string segmentID)
foreach (Cell cell in row.Cells)
foreach (Paragraph p in cell.Paragraphs)
Type pType = p.GetType();
if (pType.ToString() == “Aspose.Pdf.Text”)
Text pText = (Text) p;
foreach (Segment s in pText.Segments)
if (s.ID == segmentID)
return s;
return null;


Sorry, these two lines go before the while loop above:

Table tAircraftFormat = (Table) page1.Paragraphs[“tAircraftFormat”];
Row rAircraftFormat = tAircraftFormat.Rows[0];


Dear pcoulter,

Thanks for your consideration.

You are using the following code:

newRow.Cells = rAircraftFormat.Cells;

That code creates allof the new rows with the same cells. That’s why the only row that shows up in your pdf with any data in it is the last row that you add.

Copying rows is not directly supported, curremtly. However, to solve this problem, you may add your own AddRow() and AddCell() method (please see our demos). You can use the clone() method of the Table, Row and Cell class also, but the clone() method clones only the format but not contents of them.


Is there a demo where clone is used to add the row… the ones I see don’t.


Dear jendicot,

Thanks for your consideration.

Please download hot fix here.


Ok now I have the dll which supports copying rows… my question was about examples, or a tutorial.


Dear jendicot,

Thanks for your consideration.

The example is here with topic “Fix Released!”. Haven’t you found it?