private long XrefPosition(Tokenizer tokenizer) { tokenizer.MoveToEnd(); tokenizer.MoveToPrevious('s'); Token token = tokenizer.Token(); if (!TokenValidator.Validate(token, CharacterSetType.Regular, "startxref")) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "Expected startxref"); } token = tokenizer.Token(); if (!TokenValidator.IsWhiteSpace(token)) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "Expected a whitespace between starxref and position"); } token = tokenizer.Token(); if (!TokenValidator.IsRegularNumber(token)) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "startxref position expected"); } long xrefPosition = token.ToLong(); token = tokenizer.Token(); if (!TokenValidator.IsDelimiter(token)) { token = tokenizer.Token(); } if (!TokenValidator.IsDelimiter(token, "%")) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "Expected %%EOF at end of the file"); } token = tokenizer.Token(); if (!TokenValidator.IsDelimiter(token, "%")) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "Expected %%EOF at end of the file"); } token = tokenizer.Token(); if (!TokenValidator.Validate(token, CharacterSetType.Regular, "EOF")) { throw new PdfException(PdfExceptionCodes.INVALID_EOF, "Expected %%EOF at end of the file"); } return(xrefPosition); }