protected void skipSpaces() throws IOException {
        int c = source.read();
        // 37 is the % character, a comment
        while (isWhitespace(c) || c == 37) {
            if (c == 37) {
                // skip past the comment section
                c = source.read();
                while (!isEOL(c) && c != -1) {
                    c = source.read();
                }
            } else {
                c = source.read();
            }
        }
        if (c != -1) {
            source.rewind(1);
        }
    }
This will skip all spaces and comments that are present.

@throws IOException If there is an error reading from the stream.
tika-parsers/tika-parsers-standard/tika-parsers-standard-modules/tika-parser-pdf-module/src/main/java/org/apache/tika/parser/pdf/updates/StartXRefScanner.java