/** * Get the width from a type3 charproc stream. * * @return the glyph width. * @throws IOException if the stream could not be read, or did not have d0 or d1 as first * operator, or if their first argument was not a number. */ public float getWidth() throws IOException { List<COSBase> arguments = new ArrayList<>(); PDFStreamParser parser = new PDFStreamParser(getContents()); Object token = parser.parseNextToken(); while (token != null) { if (token instanceof COSObject) { arguments.add(((COSObject) token).getObject()); } else if (token instanceof Operator) { return parseWidth((Operator) token, arguments); } else { arguments.add((COSBase) token); } token = parser.parseNextToken(); } throw new IOException("Unexpected end of stream"); }
PDFStreamParser parser = new PDFStreamParser(getContents()); Object token = parser.parseNextToken(); while (token != null)