【发布时间】:2015-04-20 10:00:14
【问题描述】:
我需要使用ice pdf 查看器获取注释的直角坐标。有没有办法做到这一点?
【问题讨论】:
我需要使用ice pdf 查看器获取注释的直角坐标。有没有办法做到这一点?
【问题讨论】:
您需要进入 Viewer RI 源代码进行一些更改,然后重建 icepdf-viewer.jar。
org.icepdf.ri.common.tools.SquareAnnotationHandler 类处理所有鼠标事件和绘图以创建方形注释。这是开始扩展或将其用作参考的好地方。
在 mouseReleased 下添加消息对话框
JOptionPane.showMessageDialog(null, "Rectangle coordinates x ---> "+rectToDraw.x+" y --> "+ rectToDraw.y+" Width --> "+ rectToDraw.width+" height --> "+ rectToDraw.height);
【讨论】:
如果有人还在寻找答案。
Icepdf 的 Annotation 类保存这些坐标。可以像这样检索它们:
Rectangle2D.Float box = annotation.getUserSpaceRectangle();
Map<String, Double> bounds = new HashMap<String, Double>();
bounds.put("height", box.getHeight());
bounds.put("width", box.getWidth());
bounds.put("x", box.getX());
bounds.put("y", box.getY());
【讨论】: