title: Dotted line in iText PDF cell
body: <p>I am trying to draw a dotted line in pdf line.</p>
  
  <p>Dotted line is drawing fine but its drawing with lots of space at top.</p>
  
  <p>I have tried to removed those spaces but unable to removed.</p>
  
  <p>I have used below code to draw a dotted line ::</p>
  
  <pre><code>class CustomDashedLineSeparator extends DottedLineSeparator {
      protected float dash = 5;
      protected float phase = 0.5f;
  
      public float getDash() {
          return dash;
      }
  
      public float getPhase() {
          return phase;
      }
  
      public void setDash(float dash) {
          this.dash = dash;
      }
  
      public void setPhase(float phase) {
          this.phase = phase;
      }
  
      @Override
      public void draw(PdfContentByte canvas, float llx, float lly, float urx, float ury, float y) {
          canvas.saveState();
          canvas.setLineWidth(lineWidth);
          canvas.setLineDash(dash, gap, phase);
          drawLine(canvas, llx, urx, y);
          canvas.restoreState();
      }
  }
  
      Chunk lineSeperatorChunk = getLineSeperatorCell();
      PdfPCell lineSeperatorCell = new PdfPCell();
      lineSeperatorCell.addElement(lineSeperatorChunk);
  
  private static Chunk getLineSeperatorCell() {
      CustomDashedLineSeparator separator = new CustomDashedLineSeparator();
      separator.setDash(2);
      separator.setGap(2);
      separator.setLineWidth((float) 0.1);
      return new Chunk(separator);
  }
  </code></pre>
  
  <p>I am getting output as below ::
  <a href="https://i.stack.imgur.com/ao3yA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ao3yA.png" alt="enter image description here"></a></p>