int nextByte = seqSource.peek(); char c = (char)nextByte; switch(c) int leftBracket = seqSource.read(); c = (char) seqSource.peek(); seqSource.unread(leftBracket); if(c == '<') String trueString = new String( seqSource.readFully(4), ISO_8859_1 ); if( trueString.equals( TRUE ) ) "' at offset " + seqSource.getPosition()); String falseString = new String( seqSource.readFully(5), ISO_8859_1 ); if( falseString.equals( FALSE ) ) "' at offset " + seqSource.getPosition()); seqSource.read(); retval = new COSObject(null); break; int ic = seqSource.read(); c = (char)ic; while( Character.isDigit( c )|| ic = seqSource.read();
/** * Read one char and throw an exception if it is not the expected value. * * @param ec the char value that is expected. * @throws IOException if the read char is not the expected value or if an * I/O error occurs. */ protected void readExpectedChar(char ec) throws IOException { char c = (char) seqSource.read(); if (c != ec) { throw new IOException("expected='" + ec + "' actual='" + c + "' at offset " + seqSource.getPosition()); } }
protected void skipWhiteSpaces() throws IOException { //PDF Ref 3.2.7 A stream must be followed by either //a CRLF or LF but nothing else. int whitespace = seqSource.read(); //see brother_scan_cover.pdf, it adds whitespaces //after the stream but before the start of the //data, so just read those first while (ASCII_SPACE == whitespace) { whitespace = seqSource.read(); } if (ASCII_CR == whitespace) { whitespace = seqSource.read(); if (ASCII_LF != whitespace) { seqSource.unread(whitespace); //The spec says this is invalid but it happens in the real //world so we must support it. } } else if (ASCII_LF != whitespace) { //we are in an error. //but again we will do a lenient parsing and just assume that everything //is fine seqSource.unread(whitespace); } }
char c = (char) seqSource.peek(); if( c == 't' ) String trueString = new String( seqSource.readFully( 4 ), ISO_8859_1 ); if( !trueString.equals( TRUE ) ) + "' at offset " + seqSource.getPosition()); String falseString = new String( seqSource.readFully( 5 ), ISO_8859_1 ); if( !falseString.equals( FALSE ) ) + "' at offset " + seqSource.getPosition()); + "' at offset " + seqSource.getPosition());
while( (lastByte = seqSource.read() ) != ASCII_SPACE && lastByte != ASCII_LF && lastByte != ASCII_CR && "' is getting too long, stop reading at offset " + seqSource.getPosition()); seqSource.unread(lastByte);
/** * This will read an long from the stream. * * @return The long that was read from the stream. * * @throws IOException If there is an error reading from the stream. */ protected long readLong() throws IOException { skipSpaces(); long retval = 0; StringBuilder longBuffer = readStringNumber(); try { retval = Long.parseLong( longBuffer.toString() ); } catch( NumberFormatException e ) { seqSource.unread(longBuffer.toString().getBytes(ISO_8859_1)); throw new IOException( "Error: Expected a long type at offset " + seqSource.getPosition() + ", instead got '" + longBuffer + "'", e); } return retval; }
private void parseCOSDictionaryNameValuePair(COSDictionary obj) throws IOException { COSName key = parseCOSName(); COSBase value = parseCOSDictionaryValue(); skipSpaces(); if (((char) seqSource.peek()) == 'd') { // if the next string is 'def' then we are parsing a cmap stream // and want to ignore it, otherwise throw an exception. String potentialDEF = readString(); if (!potentialDEF.equals(DEF)) { seqSource.unread(potentialDEF.getBytes(ISO_8859_1)); } else { skipSpaces(); } } if (value == null) { LOG.warn("Bad dictionary declaration at offset " + seqSource.getPosition()); } else { // label this item as direct, to avoid signature problems. value.setDirect(true); obj.setItem(key, value); } }
/** * This will tell if the next byte to be read is an end of line byte. * * @return true if the next byte is 0x0A or 0x0D. * * @throws IOException If there is an error reading from the stream. */ protected boolean isEOL() throws IOException { return isEOL(seqSource.peek()); }
char c = (char) seqSource.peek(); if (c == '>') LOG.warn("Invalid dictionary, found: '" + c + "' but expected: '/' at offset " + seqSource.getPosition()); if (readUntilEndOfCOSDictionary())
private void parseCOSDictionaryNameValuePair(COSDictionary obj) throws IOException { COSName key = parseCOSName(); COSBase value = parseCOSDictionaryValue(); skipSpaces(); if (((char) seqSource.peek()) == 'd') { // if the next string is 'def' then we are parsing a cmap stream // and want to ignore it, otherwise throw an exception. String potentialDEF = readString(); if (!potentialDEF.equals(DEF)) { seqSource.unread(potentialDEF.getBytes(ISO_8859_1)); } else { skipSpaces(); } } if (value == null) { LOG.warn("Bad Dictionary Declaration " + seqSource); } else { // label this item as direct, to avoid signature problems. value.setDirect(true); obj.setItem(key, value); } }
private COSBase getObjectFromPool(COSObjectKey key) throws IOException { if (document == null) { throw new IOException("object reference " + key + " at offset " + seqSource.getPosition() + " in content stream"); } return document.getObjectFromPool(key); }
final int readBytes = pdfSource.read(binCharTestArr, 0, MAX_BIN_CHAR_TEST_LENGTH); boolean noBinData = true; int startOpIdx = -1; pdfSource.unread(binCharTestArr, 0, readBytes); pdfSource.getPosition());
char c = (char) seqSource.peek(); if( c == 't' ) String trueString = new String( seqSource.readFully( 4 ), ISO_8859_1 ); if( !trueString.equals( TRUE ) ) + "' at offset " + seqSource.getPosition()); String falseString = new String( seqSource.readFully( 5 ), ISO_8859_1 ); if( !falseString.equals( FALSE ) ) + "' at offset " + seqSource.getPosition()); + "' at offset " + seqSource.getPosition());