title: How do i change the color of a line in itext?
body: <p>I have drawn a rectangle in a pdf . Inside it i have drawn multiple lines . i want lines to appear in different colors as . for that i have written  following lines of code, but its not working.</p>
  
  <p>All lines appear in black including recatngle drawn on pdf</p>
  
  <pre><code> PdfContentByte cb = writer.getDirectContent();
      try {
  
          cb.setFontAndSize(BaseFont.createFont(BaseFont.HELVETICA, BaseFont.WINANSI, true), 24);
          cb.rectangle(0f,0f,842f,595f);
          cb.saveState();
  
      //  Rectangle rect=new Rectangle(56.69f,56.69f,737f,510.23f);
          final float bx=0f;
          float bX=842f;
          float by=0f;
          float bY=595f;
         float  x=14.17f;
          int count=0;
  
        float bXX=14.17f+bx;
  
  
           for(float k=0;k&lt;842;k=k+x)
           {
               cb.moveTo(k+bx,by);
                  cb.lineTo(k+bx,bY+bx); 
  
                  cb.setLineWidth(7);
                  cb.setColorStroke(new BaseColor(Color.BLUE));
  
           }
  
  
  
          for(float i=0;i&lt;595;i=i+x)
          {
              cb.moveTo(bx,by+i);
              cb.lineTo(bx+bX,i+by); 
              cb.setColorStroke(new BaseColor(Color.RED));
          }
  
  
  
      //  ColumnText.showTextAligned(cb, Element.ALIGN_LEFT,new Phrase("LEAD I"), 0,(12*graphHeight), 0);
          cb.restoreState();
          cb.stroke();
  
  
      } catch (DocumentException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
      }
  
  }
  </code></pre>