title: few barcodes are scanned but few are not using Zxing
body: <p>I am using zxing to scan barcode and split that in pdf.
  But most barcodes are scanned and few aren't. Although all barcodes are properly visible and i can scan them using barcode android app.
  my code is</p>
  
  <pre><code>    Boolean flag = Boolean.FALSE;
      PDDocument pdfDoc = null;
      Result prevResult = null;
      try{
          pdfDoc = PDDocument.load(new File(pathToReadPdf));
          log.debug("Total pdf pages : "+pdfDoc.getNumberOfPages());
  
          Reader reader = new MultiFormatReader();
          List&lt;PDPage&gt; pages = pdfDoc.getDocumentCatalog().getAllPages();
          for(PDPage page : pages) {
              PDResources resources = page.getResources();
              // Identify images from pdf
              Map images = resources.getImages();
              if( images != null ){
                  Iterator imageIter = images.keySet().iterator();
                  while( imageIter.hasNext()){
                      String key = (String)imageIter.next();
                      PDXObjectImage image = (PDXObjectImage)images.get( key );
                      if (image.getRGBImage()!=null){
                      Hashtable&lt;DecodeHintType, Object&gt; decodeHints = new Hashtable&lt;DecodeHintType, Object&gt;(3);
                      Vector&lt;BarcodeFormat&gt; barcodeFormats = new Vector&lt;BarcodeFormat&gt;();
                      barcodeFormats.add(BarcodeFormat.CODE_128);
                      decodeHints.put(DecodeHintType.POSSIBLE_FORMATS, barcodeFormats);
                      decodeHints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
                      decodeHints.put(DecodeHintType.PURE_BARCODE, true);
                      //decodeHints.put(DecodeHintType.CHARACTER_SET, "ISO-8859-1");
                      LuminanceSource source = new BufferedImageLuminanceSource(image.getRGBImage(), 0, 0, image.getWidth(), image.getHeight());
                      BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
                      Result result = null;
  
                      try{
                          result = reader.decode(bitmap, decodeHints);
                          splitPdf(page, result, loanApplicationId);
                          prevResult= result;
                          flag = Boolean.TRUE;
                      }catch(NotFoundException nfe){
                          if(prevResult!=null){
                              mergePDF(page, prevResult, loanApplicationId);
                          }
                          continue;
                      }
                      log.debug("Barcode text is " + result.getText());
                      }
                  }
              }
          }
      }catch(Exception e){
          e.printStackTrace();
          log.error("Error while splitting PDF : " + e.getMessage(), e);
      }
      finally {
          try{
              if(pdfDoc != null){
                  pdfDoc.close();
              }
          }catch (IOException ioe){
              ioe.printStackTrace();
              log.error("Error while closing PDF : " + ioe.getMessage(), ioe);
          }
      }
      return flag;` 
  </code></pre>
  
  <p>I think error might be in bitmap conversion.
  I am getting error at com.google.zxing.NotFoundException at <code>result = reader.decode(bitmap, decodeHints);</code></p>
  
  <p>barcode creation logic:</p>
  
  <pre><code> public byte[] createBarCode128(String fileName) {
  
      byte[] imageInByte = new byte[1024];
      try {
          Code128Bean bean = new Code128Bean();
          final int dpi = 300;
  
          //Configure the barcode generator
          bean.setModuleWidth(UnitConv.in2mm(6.0f / dpi));
          bean.doQuietZone(false);
  
          BitmapCanvasProvider canvas = new BitmapCanvasProvider(null, "image/x-png", dpi, BufferedImage.TYPE_BYTE_BINARY, false, 0);
  
          //Generate the barcode
          bean.generateBarcode(canvas, fileName);
  
          //Signal end of generation
          canvas.finish();
  
          BufferedImage originalImage = canvas.getBufferedImage();
          ByteArrayOutputStream baos = new ByteArrayOutputStream();
          ImageIO.write(originalImage, "jpg", baos);
          baos.flush();
          imageInByte = baos.toByteArray();
          log.debug(imageInByte.toString());
          baos.close();
          log.debug(" Bar Code is generated successfully ");
      }
      catch (IOException ex) {
          ex.printStackTrace();
          log.error(ex.getMessage(),ex);
      }
      return imageInByte;
  }
  </code></pre>
  
  <p>I am using below dependencies:</p>
  
  <pre><code> &lt;dependency&gt;
          &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;
          &lt;artifactId&gt;core&lt;/artifactId&gt;
          &lt;version&gt;2.3.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
          &lt;artifactId&gt;fontbox&lt;/artifactId&gt;
          &lt;version&gt;1.8.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;org.apache.pdfbox&lt;/groupId&gt;
          &lt;artifactId&gt;pdfbox&lt;/artifactId&gt;
          &lt;version&gt;1.8.0&lt;/version&gt;
      &lt;/dependency&gt;
      &lt;dependency&gt;
          &lt;groupId&gt;com.google.zxing&lt;/groupId&gt;
          &lt;artifactId&gt;javase&lt;/artifactId&gt;
          &lt;version&gt;2.2&lt;/version&gt;
      &lt;/dependency&gt;
  </code></pre>
  
  <p>my java version is 6 so zxing version 3 is not supported.</p>
  
  <p>Please suggest any solution.</p>