private static void extractRefFromEnd(byte[] raw,final PdfObject pdfObject,PdfFileReader objectReader){
  String objectRef;
  int ptr=0;
  final int len=raw.length;
  for (int jj=0; jj < len; jj++) {
    if (raw[jj] >= '0' && raw[jj] <= '9') {
      ptr=jj;
      jj=len;
    }
  }
  int end=ptr;
  while ((raw[end] >= '0' && raw[end] <= '9') || raw[end] == ' ' || raw[end] == 10 || raw[end] == 13 || raw[end] == 9) {
    end++;
  }
  if (raw[end] == 'o' && raw[end + 1] == 'b' && raw[end + 2] == 'j') {
    objectRef=new String(raw,0,end) + 'R';
    int newArrayLen=raw.length - end - 4;
    byte[] newArray=new byte[newArrayLen];
    System.arraycopy(raw,end + 4,newArray,0,newArrayLen);
    raw=newArray;
    pdfObject.setRef(objectRef);
    Dictionary.readDictionaryFromRefOrDirect(pdfObject,objectRef,0,raw,-1,objectReader);
  }
}

private static void extractRefFromEnd ( byte [ ] raw , final PdfObject pdfObject , PdfFileReader objectReader ) { String objectRef ; int ptr = 0 ; final int len = raw . length ; for ( int jj = 0 ; jj < len ; jj ++ ) { if ( raw [ jj ] >= '0' && raw [ jj ] <= '9' ) { ptr = jj ; jj = len ; } } int end = ptr ; while ( ( raw [ end ] >= '0' && raw [ end ] <= '9' ) || raw [ end ] == ' ' || raw [ end ] == 10 || raw [ end ] == 13 || raw [ end ] == 9 ) { end ++ ; } if ( raw [ end ] == 'o' && raw [ end + 1 ] == 'b' && raw [ end + 2 ] == 'j' ) { objectRef = new String ( raw , 0 , end ) + 'R' ; int newArrayLen = raw . length - end - 4 ; byte [ ] newArray = new byte [ newArrayLen ] ; System . arraycopy ( raw , end + 4 , newArray , 0 , newArrayLen ) ; raw = newArray ; pdfObject . setRef ( objectRef ) ; Dictionary . readDictionaryFromRefOrDirect ( pdfObject , objectRef , 0 , raw , - 1 , objectReader ) ; } }
see case 23155 ( encrypted annot needs obj ref appended so we can decrypt string later )
