use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawCircles.
private void drawCircles(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException {
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 20);
// strategy used by Adobe:
// 1) add small circle in white using /ca /CA 0.6 and width 1
// 2) fill
// 3) add small circle in one direction
// 4) add large circle in other direction
// 5) stroke + fill
// with square width 20 small r = 6.36, large r = 9.756
float smallR = 6.36f;
float largeR = 9.756f;
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
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);
drawCircle(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, smallR);
contentStream.fill();
contentStream.restoreGraphicsState();
// value from Adobe
contentStream.setLineWidth(0.59f);
drawCircle(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, smallR);
drawCircle2(contentStream, bbox.getWidth() / 2, bbox.getHeight() / 2, largeR);
contentStream.fillAndStroke();
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawRightPointer.
// TODO this is mostly identical to drawStar, except for scale, translation and symbol
private void drawRightPointer(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException {
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 17);
float min = Math.min(bbox.getWidth(), bbox.getHeight());
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
// value from Adobe
contentStream.setLineWidth(0.59f);
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f));
contentStream.transform(Matrix.getTranslateInstance(0, 50));
// we get the shape of a Zapf Dingbats right pointer (0x27A4) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
Path path = PDType1Font.ZAPF_DINGBATS.getPath("a174");
addPath(contentStream, path);
contentStream.fillAndStroke();
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawCrossHairs.
private void drawCrossHairs(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(0);
contentStream.setLineCapStyle(0);
// value from Adobe
contentStream.setLineWidth(0.61f);
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 1.5f, 0.001f * min / 1.5f));
contentStream.transform(Matrix.getTranslateInstance(0, 50));
// we get the shape of a Symbol crosshair (0x2295) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
Path path = PDType1Font.SYMBOL.getPath("circleplus");
addPath(contentStream, path);
contentStream.fillAndStroke();
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawCross.
private void drawCross(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException {
PDRectangle bbox = adjustRectAndBBox(annotation, 19, 19);
// should be a square, but who knows...
float min = Math.min(bbox.getWidth(), bbox.getHeight());
// small = offset nearest bbox edge
// large = offset second nearest bbox edge
float small = min / 10;
float large = min / 5;
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
// value from Adobe
contentStream.setLineWidth(0.59f);
contentStream.moveTo(small, large);
contentStream.lineTo(large, small);
contentStream.lineTo(min / 2, min / 2 - small);
contentStream.lineTo(min - large, small);
contentStream.lineTo(min - small, large);
contentStream.lineTo(min / 2 + small, min / 2);
contentStream.lineTo(min - small, min - large);
contentStream.lineTo(min - large, min - small);
contentStream.lineTo(min / 2, min / 2 + small);
contentStream.lineTo(large, min - small);
contentStream.lineTo(small, min - large);
contentStream.lineTo(min / 2 - small, min / 2);
contentStream.closeAndFillAndStroke();
// alternatively, this could also be drawn with Zapf Dingbats "a21"
// see DrawStar()
}
use of com.tom_roush.pdfbox.pdmodel.common.PDRectangle in project PdfBox-Android by TomRoush.
the class PDTextAppearanceHandler method drawCheck.
// TODO this is mostly identical to drawStar, except for scale, translation and symbol
// maybe use a table with all values and draw from there
// this could also optionally use outer circle
private void drawCheck(PDAnnotationText annotation, final PDAppearanceContentStream contentStream) throws IOException {
PDRectangle bbox = adjustRectAndBBox(annotation, 20, 19);
float min = Math.min(bbox.getWidth(), bbox.getHeight());
contentStream.setMiterLimit(4);
contentStream.setLineJoinStyle(1);
contentStream.setLineCapStyle(0);
// value from Adobe
contentStream.setLineWidth(0.59f);
contentStream.transform(Matrix.getScaleInstance(0.001f * min / 0.8f, 0.001f * min / 0.8f));
contentStream.transform(Matrix.getTranslateInstance(0, 50));
// we get the shape of a Zapf Dingbats check (0x2714) and use that one.
// Adobe uses a different font (which one?), or created the shape from scratch.
Path path = PDType1Font.ZAPF_DINGBATS.getPath("a20");
addPath(contentStream, path);
contentStream.fillAndStroke();
}
Aggregations