/** * This will tell if the next byte is whitespace or not. * * @return true if the next byte in the stream is a whitespace character. * * @throws IOException If there is an error reading from the stream. */ protected boolean isWhitespace() throws IOException { return isWhitespace(seqSource.peek()); }
private void initFromRandomAccessRead(RandomAccessRead rar) throws IOException { pdfSource = rar; PDFParser parser = new PDFParser(pdfSource); parser.parse(); visualSignature = parser.getDocument(); }
/** * Parses an appearance stream into tokens. */ private List<Object> tokenize(PDAppearanceStream appearanceStream) throws IOException { PDFStreamParser parser = new PDFStreamParser(appearanceStream.getContents()); parser.parse(); return parser.getTokens(); }
/** * Fills XRefTrailerResolver with data of given stream. * Stream must be of type XRef. * @param stream the stream to be read * @param objByteOffset the offset to start at * @param isStandalone should be set to true if the stream is not part of a hybrid xref table * @throws IOException if there is an error parsing the stream */ private void parseXrefStream(COSStream stream, long objByteOffset, boolean isStandalone) throws IOException { // the cross reference stream of a hybrid xref table will be added to the existing one // and we must not override the offset and the trailer if ( isStandalone ) { xrefTrailerResolver.nextXrefObj( objByteOffset, XRefType.STREAM ); xrefTrailerResolver.setTrailer( stream ); } PDFXrefStreamParser parser = new PDFXrefStreamParser( stream, document, xrefTrailerResolver ); parser.parse(); }
/** * Checks if the next char is a space or a return. * * @return true if the next char is a space or a return * @throws IOException if something went wrong */ private boolean hasNextSpaceOrReturn() throws IOException { return isSpaceOrReturn( seqSource.peek() ); } }
/** * Parse the header of a fdf. * * @return true if a FDF header was found * @throws IOException if something went wrong */ protected boolean parseFDFHeader() throws IOException { return parseHeader(FDF_HEADER, FDF_DEFAULT_VERSION); }
/** * Constructor. * * @param stream The content stream to parse. * @throws IOException If there is an error initializing the stream. */ public PDFStreamParser(InputStream stream) throws IOException { super(new InputStreamSource(stream)); }
/** * Adds all from newObjects to toBeParsedList if it is not an COSObject or * we didn't add this COSObject already (checked via addedObjects). */ private void addNewToList(final Queue<COSBase> toBeParsedList, final Collection<COSBase> newObjects, final Set<Long> addedObjects) { for (COSBase newObject : newObjects) { addNewToList(toBeParsedList, newObject, addedObjects); } }
private Map<COSObjectKey, Long> getBFCOSObjectOffsets() throws IOException { if (bfSearchCOSObjectKeyOffsets == null) { bfSearchForObjects(); } return bfSearchCOSObjectKeyOffsets; }
@Override public boolean isEOF() throws IOException { return peek() == -1; }
private static boolean isHexDigit(char ch) { return isDigit(ch) || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F'); }
/** * Default constructor. * * @param source input representing the pdf. */ public COSParser(RandomAccessRead source) { super(new RandomAccessSource(source)); this.source = source; }
/** * Read one String and throw an exception if it is not the expected value. * * @param expectedString the String value that is expected. * @throws IOException if the String char is not the expected value or if an * I/O error occurs. */ protected void readExpectedString(String expectedString) throws IOException { readExpectedString(expectedString.toCharArray(), false); }
/** * Parse the header of a pdf. * * @return true if a PDF header was found * @throws IOException if something went wrong */ protected boolean parsePDFHeader() throws IOException { return parseHeader(PDF_HEADER, PDF_DEFAULT_VERSION); }
/** * Constructor. * * @param bytes the bytes to parse. * @throws IOException If there is an error initializing the stream. */ public PDFStreamParser(byte[] bytes) throws IOException { super(new InputStreamSource(new ByteArrayInputStream(bytes))); }