title: Get number of rows a cell occupies Itextsharp
body: <p>everyone.</p>
  
  <p>I want to know if there is a method to accurately get the rows occupied by a certain cell.</p>
  
  <p>Currently I'm doing this using the ff. function:</p>
  
  <pre><code>private int GetRowLines(string content, float maxFloatPerRow)
  {
      if (string.IsNullOrEmpty(content))
          content = string.Empty;
  
      float noteFwidth = BaseFont.GetWidthPoint(content, cellFont.Size);
  
      int nextRowLines = 0;
      var test = noteFwidth / maxFloatPerRow;
      nextRowLines = (int)Math.Ceiling(test);
  
      return nextRowLines == 0 ? 1 : nextRowLines;
  }
  </code></pre>
  
  <p>The only problem with this is that I need to supply the <code>maxFloatPerRow</code> which is done only by trial and error.</p>
  
  <blockquote>
    <ol>
    <li>I'll have a pdf generated with lots of <code>"i"</code> in the particular cell I want to test.</li>
    <li>Then I will copy all the content on that cell for 1 row (this will be the maximum characters in one row for that cell).</li>
    <li>Get the float width of that "max content per row" using the <code>BaseFont.GetWidthPoint</code> method.</li>
    </ol>
  </blockquote>
  
  <p>However, I want to create a utility method that will give me the number of rows a content will occupy, provided the Fwidth of the header, font of the content, and the content itself. More if needed so.</p>
  
  <p><strong>EDIT</strong> based on comment:</p>
  
  <p>I am using <code>itext v.3.1.7.0</code> and I am creating a pdf, not editing an existing one.</p>
  
  <p>I hope you guys have something to share. Thanks.</p>