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:
XML
----------------------------------
Code
---------------------------------
…
while (dr.Read())
{
Row newRow = new Row(tAircraftFormat);
tAircraftFormat.Rows.Add(newRow);
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();
}
…
(PdfHelper.FindSegment)
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;
}