use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDType3Font method generateBoundingBox.
private BoundingBox generateBoundingBox() {
PDRectangle rect = getFontBBox();
if (rect.getLowerLeftX() == 0 && rect.getLowerLeftY() == 0 && rect.getUpperRightX() == 0 && rect.getUpperRightY() == 0) {
// Plan B: get the max bounding box of the glyphs
COSDictionary cp = getCharProcs();
for (COSName name : cp.keySet()) {
COSBase base = cp.getDictionaryObject(name);
if (base instanceof COSStream) {
PDType3CharProc charProc = new PDType3CharProc(this, (COSStream) base);
try {
PDRectangle glyphBBox = charProc.getGlyphBBox();
if (glyphBBox == null) {
continue;
}
rect.setLowerLeftX(Math.min(rect.getLowerLeftX(), glyphBBox.getLowerLeftX()));
rect.setLowerLeftY(Math.min(rect.getLowerLeftY(), glyphBBox.getLowerLeftY()));
rect.setUpperRightX(Math.max(rect.getUpperRightX(), glyphBBox.getUpperRightX()));
rect.setUpperRightY(Math.max(rect.getUpperRightY(), glyphBBox.getUpperRightY()));
} catch (IOException ex) {
// ignore
}
}
}
}
return new BoundingBox(rect.getLowerLeftX(), rect.getLowerLeftY(), rect.getUpperRightX(), rect.getUpperRightY());
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDFontDescriptor method getFontBoundingBox.
/**
* This will get the fonts bounding box.
*
* @return The fonts bounding box.
*/
public PDRectangle getFontBoundingBox() {
COSArray rect = (COSArray) dic.getDictionaryObject(COSName.FONT_BBOX);
PDRectangle retval = null;
if (rect != null) {
retval = new PDRectangle(rect);
}
return retval;
}
Aggregations