public static final boolean isPDFLinearized(final String pdfUrl){
  if (pdfUrl.startsWith("jar")) {
    return false;
  }
  boolean isLinear=false;
  final URL url;
  final InputStream is;
  try {
    url=new URL(pdfUrl);
    is=url.openStream();
    final byte[] buffer=new byte[128];
    is.read(buffer);
    is.close();
    final int len=buffer.length;
    for (int i=0; i < len; i++) {
      if (buffer[i] == '/' && buffer[i + 1] == 'L' && buffer[i + 2] == 'i' && buffer[i + 3] == 'n' && buffer[i + 4] == 'e' && buffer[i + 5] == 'a' && buffer[i + 6] == 'r') {
        isLinear=true;
        i=len;
      }
    }
  }
 catch (  final IOException e) {
    LogWriter.writeLog("[PDF] Exception " + e + " scanning URL "+ pdfUrl);
  }
  return isLinear;
}

public static final boolean isPDFLinearized ( final String pdfUrl ) { if ( pdfUrl . startsWith ( "jar" ) ) { return false ; } boolean isLinear = false ; final URL url ; final InputStream is ; try { url = new URL ( pdfUrl ) ; is = url . openStream ( ) ; final byte [ ] buffer = new byte [ 128 ] ; is . read ( buffer ) ; is . close ( ) ; final int len = buffer . length ; for ( int i = 0 ; i < len ; i ++ ) { if ( buffer [ i ] == '/' && buffer [ i + 1 ] == 'L' && buffer [ i + 2 ] == 'i' && buffer [ i + 3 ] == 'n' && buffer [ i + 4 ] == 'e' && buffer [ i + 5 ] == 'a' && buffer [ i + 6 ] == 'r' ) { isLinear = true ; i = len ; } } } catch ( final IOException e ) { LogWriter . writeLog ( "[PDF] Exception " + e + " scanning URL " + pdfUrl ) ; } return isLinear ; }
examine first few bytes to see if linearized and return true linearized file
