title: Detect and remove blank pages in PDF file with perl
body: <p>Is there a reliable way to detect blank pages with a perl script? I tried to do it with to following script by using the getPageText method. If I do it like that, pages which only contain graphics without text are also recognized as blank pages. </p>
  
  <pre><code>#!/usr/bin/perl -w
  
  use CAM::PDF;
  my $filename=$ARGV[0];
  my $doc = CAM::PDF-&gt;new($filename) || die "$CAM::PDF::errstr\n";
  my $pages = $doc-&gt;numPages();
  print $pages;
  
  $content=$doc-&gt;getPageText(1);
  print "length".length($content);
  if(length($content)==0)
  {
    print "File is empty";
  }
  
  foreach my $p ( 1 .. $doc-&gt;numPages() ) {
      my $str = $doc-&gt;getPageText($p);
      $str =~ m/[[:alnum:]]+/ms );  # actually returned text
      print "Result text:".qq($str);
   }
  </code></pre>
  
  <p>Is there another approach to find blank pages?</p>