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); }
private void AnalyzeHeader(Tokenizer tokenizer) { Token token = tokenizer.Token(); if (!TokenValidator.IsDelimiter(token, "%")) { throw new PdfException(PdfExceptionCodes.HEADER_NOT_FOUND, "Header not found"); } token = tokenizer.Token(); if (!TokenValidator.Validate(token, CharacterSetType.Regular, "PDF-1.1", "PDF-1.2", "PDF-1.3", "PDF-1.4", "PDF-1.5", "PDF-1.6", "PDF-1.7")) { throw new PdfException(PdfExceptionCodes.HEADER_NOT_FOUND, "Header not found"); } }