if (base instanceof COSStream) PDType3CharProc charProc = new PDType3CharProc(this, (COSStream) base); try PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox == null)
@Override public float getWidthFromFont(int code) throws IOException { PDType3CharProc charProc = getCharProc(code); if (charProc == null || charProc.getContentStream() == null || charProc.getContentStream().getLength() == 0) { return 0; } return charProc.getWidth(); }
/** * 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"); }
private void calcBBox(PDType3Font font) throws IOException { double minX = 0; double maxX = 0; double minY = 0; double maxY = 0; for (int index = 0; index <= 255; ++index) { PDType3CharProc charProc = font.getCharProc(index); if (charProc == null) { continue; } PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox == null) { continue; } minX = Math.min(minX, glyphBBox.getLowerLeftX()); maxX = Math.max(maxX, glyphBBox.getUpperRightX()); minY = Math.min(minY, glyphBBox.getLowerLeftY()); maxY = Math.max(maxY, glyphBBox.getUpperRightY()); } fontBBox = new PDRectangle((float) minX, (float) minY, (float) (maxX - minX), (float) (maxY - minY)); }
/** * Returns the stream of the glyph for the given character code * * @param code character code * @return the stream to be used to render the glyph */ public PDType3CharProc getCharProc(int code) { String name = getEncoding().getName(code); COSBase base = getCharProcs().getDictionaryObject(COSName.getPDFName(name)); if (base instanceof COSStream) { return new PDType3CharProc(this, (COSStream) base); } return null; } }
getGraphicsState().getCurrentTransformationMatrix().concatenate(charProc.getMatrix());
/** * 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<COSBase>(); PDFStreamParser parser = new PDFStreamParser(this); 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"); }
@Override public float getWidthFromFont(int code) throws IOException { PDType3CharProc charProc = getCharProc(code); if (charProc == null) { return 0; } return charProc.getWidth(); }
PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox != null)
/** * Returns the stream of the glyph for the given character code * * @param code character code * @return the stream to be used to render the glyph */ public PDType3CharProc getCharProc(int code) { String name = getEncoding().getName(code); if (!".notdef".equals(name)) { COSStream stream; stream = (COSStream)getCharProcs().getDictionaryObject(COSName.getPDFName(name)); if (stream == null) { return null; } return new PDType3CharProc(this, stream); } return null; } }
getGraphicsState().getCurrentTransformationMatrix().concatenate(charProc.getMatrix());
/** * 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(this); 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"); }
if (base instanceof COSStream) PDType3CharProc charProc = new PDType3CharProc(this, (COSStream) base); try PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox == null)
if (charProc != null) { BoundingBox fontBBox = t3Font.getBoundingBox(); PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox != null) {
@Override public float getWidthFromFont(int code) throws IOException { PDType3CharProc charProc = getCharProc(code); if (charProc == null || charProc.getContentStream() == null || charProc.getContentStream().getLength() == 0) { return 0; } return charProc.getWidth(); }
/** * Returns the stream of the glyph for the given character code * * @param code character code * @return the stream to be used to render the glyph */ public PDType3CharProc getCharProc(int code) { String name = getEncoding().getName(code); COSBase base = getCharProcs().getDictionaryObject(COSName.getPDFName(name)); if (base instanceof COSStream) { return new PDType3CharProc(this, (COSStream) base); } return null; } }
getGraphicsState().getCurrentTransformationMatrix().concatenate(charProc.getMatrix());
if (base instanceof COSStream) PDType3CharProc charProc = new PDType3CharProc(this, (COSStream) base); try PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox == null)
PDRectangle glyphBBox = charProc.getGlyphBBox(); if (glyphBBox != null)