use of org.apache.pdfbox.pdmodel.interactive.annotation.PDAnnotationInk in project pdfbox by apache.
the class PDInkAppearanceHandler method generateNormalAppearance.
@Override
public void generateNormalAppearance() {
PDAnnotationInk ink = (PDAnnotationInk) getAnnotation();
// PDF spec does not mention /Border for ink annotations, but it is used if /BS is not available
AnnotationBorder ab = AnnotationBorder.getAnnotationBorder(ink, ink.getBorderStyle());
PDColor color = ink.getColor();
if (color == null || color.getComponents().length == 0 || Float.compare(ab.width, 0) == 0) {
return;
}
try {
try (PDAppearanceContentStream cs = getNormalAppearanceAsContentStream()) {
handleOpacity(ink.getConstantOpacity());
cs.setStrokingColor(color);
if (ab.dashArray != null) {
cs.setLineDashPattern(ab.dashArray, 0);
}
cs.setLineWidth(ab.width);
for (float[] pathArray : ink.getInkList()) {
int nPoints = pathArray.length / 2;
// in an implementation-dependent way" - we do lines.
for (int i = 0; i < nPoints; ++i) {
float x = pathArray[i * 2];
float y = pathArray[i * 2 + 1];
if (i == 0) {
cs.moveTo(x, y);
} else {
cs.lineTo(x, y);
}
}
cs.stroke();
}
}
} catch (IOException ex) {
LOG.error(ex);
}
}
Aggregations