title: Remove objects like table row before rendering
body: <p>I am generating a document with itext7 in vb.net. The document is a payment reminder. The document contains 1 to many positions (I do not know how many positions the document will have at the end). Sometimes it could happen, that a position contains no amount. And I want to remove this position.</p>
  
  <p>The reminder positions looks for example like this:</p>
  
  <pre><code>CustomerName   |      Amount |
  ---------------|-------------|
  Jupiter Jones  |    1,100.12 |
  Peter Crenshaw |        0.00 |
  Bob Andrews    |      231.02 |
  ---------------|-------------|
  Sum            |    1,331.14 |
  </code></pre>
  
  <p>The lines are added to the table with </p>
  
  <pre><code>table.AddCell(cell1)
  table.AddCell(cell2)
  </code></pre>
  
  <p>This example is very simplified...sadly it is because of the data structure and the calculations that have to be made, that I do not know whether the position line has to be printed before starting the line (the first cell of the line) or not.</p>
  
  <p>So is it possible to "remember" a kind of index or handle or anything else, so that I am able to remove certain objects from the itext7 document before I "send" it to the renderer?</p>
  
  <p>The table should look like this after the "removement":</p>
  
  <pre><code>CustomerName   |      Amount |
  ---------------|-------------|
  Jupiter Jones  |    1,100.12 |
  Bob Andrews    |      231.02 |
  ---------------|-------------|
  Sum            |    1,331.14 |
  </code></pre>
  
  <p>I hope you understand, what I mean...</p>
  
  <p>To clarify some facts and answer the questions blow:</p>
  
  <p>I wrote a wrapper-class (dll) for itext7 to create different types of pdfs with it. A whole table-creation contains of</p>
  
  <pre><code>obj.TableBegin({Cell1Width, Cell2Width})
  while objMySqlDataReader.Read
      Dim calculatedAmount as Single = 0
      //do some calculations
      objCell1.Text = objMySqlDataReader("CustomerName")
      objCell2.Text = calculatedAmount
      obj.TableCreateRow({objCell1, objCell2})
  End While
  obj.TableEnd()
  </code></pre>
  
  <p>Method TableBegin</p>
  
  <pre><code>Private Sub TableBegin(ByVal ColWidths as Single())
      table = new Table(ColWidths)
      //some formattings and so on
  End Sub
  </code></pre>
  
  <p>Method TableCreateRow</p>
  
  <pre><code>Private Sub TableCreateRow(byval arrCells as MyOwnCellType())
      For Each varCell As MyOwnCellType In arrCells
          Dim c As Cell = New Cell()
          Dim p As Paragraph = New Paragraph(varCell.Text)
          c.Add(p)
          //followed by some formatting lines like c.SetBackgroudColor
          //or c.SetBorder
          table.AddCell(c)
      Next
  End Sub
  </code></pre>
  
  <p>Method TableEnd</p>
  
  <pre><code>Private Sub TableEnd()
      document.Add(table)
  End Sub  
  </code></pre>
  
  <p>The moment when I know whether a row as to be printed or not is variable. Sometimes I know it just after "printing" both cells of the row. But it could happen that I want to remove a table-row after the table has been "finished".</p>
  
  <p>In another "document-type" a have a very similar problem, but there I need to remove a whole page of the document including Paragraphs, Tables, Images....</p>
  
  <p>My utopian idea was, that I "save" the handle of each "possible to be removed object" in a list or array and after recognizing wheter the objects have to be printed or not I can either clear this array or remove all objects within this array by something like <code>document.remove(handle)</code></p>
  
  <p>Another utopian idea was, that I "collect" all "possible to be removed / printed objects" in any kind of array or list and after recognizing whether printing or not I can "push" these objects to the document or discard them.</p>
  
  <p>It is difficult to discribe and even much more difficult to understand why I do not know "printing or not" <strong>before</strong> printing. But believe me - I do not know earlier. ;-)</p>
  
  <p>Any idea or help is very appreciated.</p>