use of com.tom_roush.pdfbox.pdmodel.graphics.state.PDExtendedGraphicsState in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawRightArrow.
private void drawRightArrow(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException {
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 20);
float min = Math.min(bbox.getWidth(), bbox.getHeight());
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
// value from Adobe
contentStream.setLineWidth(0.59f);
// Adobe first fills a white circle with CA ca 0.6, so do we
contentStream.saveGraphicsState();
contentStream.setLineWidth(1);
PDExtendedGraphicsState gs = new PDExtendedGraphicsState();
gs.setAlphaSourceFlag(false);
gs.setStrokingAlphaConstant(0.6f);
gs.setNonStrokingAlphaConstant(0.6f);
gs.setBlendMode(BlendMode.NORMAL);
contentStream.setGraphicsStateParameters(gs);
contentStream.setNonStrokingColor(1f);
drawCircle2(contentStream, min / 2, min / 2, min / 2 - 1);
contentStream.fill();
contentStream.restoreGraphicsState();
contentStream.saveGraphicsState();
// rescale so that the glyph fits into circle and move it to circle center
// values gathered by trial and error
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 1.3f, 0.001f * min / 1.3f));
contentStream.transform(Matrix.getTranslateInstance(200, 300));
// we get the shape of a Zapf Dingbats right arrow (0x2794) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
Path path = PDType1Font.ZAPF_DINGBATS.getPath("a160");
addPath(contentStream, path);
contentStream.restoreGraphicsState();
// surprisingly, this one not counterclockwise.
drawCircle(contentStream, min / 2, min / 2, min / 2 - 1);
contentStream.fillAndStroke();
}
Aggregations