Пример #1
0
 public void nextValidToken() throws IOException {
   int level = 0;
   String n1 = null;
   String n2 = null;
   int ptr = 0;
   while (nextToken()) {
     if (type == TK_COMMENT) continue;
     switch (level) {
       case 0:
         {
           if (type != TK_NUMBER) return;
           ptr = file.getFilePointer();
           n1 = stringValue;
           ++level;
           break;
         }
       case 1:
         {
           if (type != TK_NUMBER) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           n2 = stringValue;
           ++level;
           break;
         }
       default:
         {
           if (type != TK_OTHER || !stringValue.equals("R")) {
             file.seek(ptr);
             type = TK_NUMBER;
             stringValue = n1;
             return;
           }
           type = TK_REF;
           reference = Integer.valueOf(n1).intValue();
           generation = Integer.valueOf(n2).intValue();
           return;
         }
     }
   }
   throwError("Unexpected end of file");
 }
Пример #2
0
 public int getStartxref() throws IOException {
   int size = Math.min(1024, file.length());
   int pos = file.length() - size;
   file.seek(pos);
   String str = readString(1024);
   int idx = str.lastIndexOf("startxref");
   if (idx < 0) throw new IOException("PDF startxref not found.");
   return pos + idx;
 }
Пример #3
0
 public void seek(int pos) throws IOException {
   file.seek(pos);
 }