lib/raw.js
function (pdf_file, cb) {
            var quality = 300;
            if (options.hasOwnProperty('quality') && options.quality) {
              quality = options.quality;
            }
            convert(pdf_file.file_path, quality, function (err, tif_path) {
              var zeroBasedNumPages = num_pages-1;
              self.emit('log', 'converted page to intermediate tiff file, page '+ index+ ' (0-based indexing) of '+ zeroBasedNumPages);
              if (err) { return cb(err); }
              var ocr_flags = [
                '-psm 6'
              ];
              if (options.ocr_flags) {
                ocr_flags = options.ocr_flags;
              }
              ocr(tif_path, ocr_flags, function (err, extract) {
                fs.unlink(tif_path, function (tif_cleanup_err, reply) {
                  if (tif_cleanup_err) {
                    err += ', error removing temporary tif file: "'+tif_cleanup_err+'"';
                  }
                  if (err) { return cb(err); }
                  var page_number = index+1
                  self.emit('log', 'raw ocr: page ' + index + ' (0-based indexing) of ' +zeroBasedNumPages + ' complete');
                  single_page_pdf_file_paths.push(pdf_file.file_path);
                  self.emit('page', { hash: hash, text: extract, index: index, num_pages: num_pages, pdf_path: pdf_path, single_page_pdf_path: pdf_file.file_path});
                  text_pages.push(extract);
                  index++;
                  cb();
                });
              });
            });
          }
function (pdf_file, cb) {
            var quality = 300;
            if (options.hasOwnProperty('quality') && options.quality) {
              quality = options.quality;
            }
            convert(pdf_file.file_path, quality, function (err, tif_path) {
              var zeroBasedNumPages = num_pages-1;
              self.emit('log', 'converted page to intermediate tiff file, page '+ index+ ' (0-based indexing) of '+ zeroBasedNumPages);
              if (err) { return cb(err); }
              var ocr_flags = [
                '-psm 6'
              ];
              if (options.ocr_flags) {
                ocr_flags = options.ocr_flags;
              }
              ocr(tif_path, ocr_flags, function (err, extract) {
                fs.unlink(tif_path, function (tif_cleanup_err, reply) {
                  if (tif_cleanup_err) {
                    err += ', error removing temporary tif file: "'+tif_cleanup_err+'"';
                  }
                  if (err) { return cb(err); }
                  var page_number = index+1
                  self.emit('log', 'raw ocr: page ' + index + ' (0-based indexing) of ' +zeroBasedNumPages + ' complete');
                  single_page_pdf_file_paths.push(pdf_file.file_path);
                  self.emit('page', { hash: hash, text: extract, index: index, num_pages: num_pages, pdf_path: pdf_path, single_page_pdf_path: pdf_file.file_path});
                  text_pages.push(extract);
                  index++;
                  cb();
                });
              });
            });
          }
function ( pdf_file , cb ) { var quality = 300 ; if ( options . hasOwnProperty ( 'quality' ) && options . quality ) { quality = options . quality ; } convert ( pdf_file . file_path , quality , function ( err , tif_path ) { var zeroBasedNumPages = num_pages - 1 ; self . emit ( 'log' , 'converted page to intermediate tiff file, page ' + index + ' (0-based indexing) of ' + zeroBasedNumPages ) ; if ( err ) { return cb ( err ) ; } var ocr_flags = [ '-psm 6' ] ; if ( options . ocr_flags ) { ocr_flags = options . ocr_flags ; } ocr ( tif_path , ocr_flags , function ( err , extract ) { fs . unlink ( tif_path , function ( tif_cleanup_err , reply ) { if ( tif_cleanup_err ) { err += ', error removing temporary tif file: "' + tif_cleanup_err + '"' ; } if ( err ) { return cb ( err ) ; } var page_number = index + 1 self . emit ( 'log' , 'raw ocr: page ' + index + ' (0-based indexing) of ' + zeroBasedNumPages + ' complete' ) ; single_page_pdf_file_paths . push ( pdf_file . file_path ) ; self . emit ( 'page' , { hash : hash , text : extract , index : index , num_pages : num_pages , pdf_path : pdf_path , single_page_pdf_path : pdf_file . file_path } ) ; text_pages . push ( extract ) ; index ++ ; cb ( ) ; } ) ; } ) ; } ) ; }
extract the text for each page via ocr
extract the text for each page via ocr