title: 2D barcode generation issue in Java
body: <p>I am generating barcodes using iText API, everything looks good when it is linear barcodes when it is 2D barcodes then barcodes are placed into pdf document as images, hence reducing the quality of the barcode on low resolution printers and unable to scan the barcode. Below is the code</p>
  
  <pre><code>BarcodePDF417 pdf417 = new BarcodePDF417();
      String text = "BarcodePDF417 barcode";
      pdf417.setText(text);
      Image img = pdf417.getImage();        
      document.add(img);
  </code></pre>
  
  <p>Now i am look for an alternative to draw barcode and i found palceBarcode method which might favor to the requirement.</p>
  
  <p>I have seen the below code in BarcodePDF417 class in itext source and could not able to find out the way how to use it</p>
  
  <pre><code>public void placeBarcode(PdfContentByte cb, BaseColor foreground, float moduleHeight, float moduleWidth) {
      paintCode();
      int stride = (bitColumns + 7) / 8;
      cb.setColorFill(foreground);
      for (int k = 0; k &lt; codeRows; ++k) {
          int p = k * stride;
          for (int j = 0; j &lt; bitColumns; ++j) {
              int b = outBits[p + j / 8] &amp; 0xff;
              b &lt;&lt;= j % 8;
              if ((b &amp; 0x80) != 0) {
                  cb.rectangle(j * moduleWidth, (codeRows - k - 1) * moduleHeight, moduleWidth, moduleHeight);
              }
          }
      }
      cb.fill();
  }
  </code></pre>
  
  <p>Can anyone suggest the way to use the above method?</p>
  
  <p>I have written code like below but getting dark page as a whole.</p>
  
  <pre><code>Rectangle pageSize = new Rectangle(w * 72, h * 72);
      Document doc = new Document(pageSize, 1f, 1f, 1f, 1f);
      PdfWriter writer = PdfWriter.getInstance(doc, getOutputStream());
      doc.open();
      PdfContentByte cb = writer.getDirectContent();
      BarcodePDF417 pf = new BarcodePDF417();
      pf.setText("BarcodePDF417 barcode");
      pf.getImage();
      Rectangle rc = pf.getBarcodeSize();
      pf.placeBarcode(cb, BaseColor.BLACK, rc.getHeight(), rc.getWidth());
      doc.close();
  </code></pre>