在iText Java中添加地图 [英] Adding maps at iText Java
问题描述
我正在使用java和iText创建pdf.是否可以添加带有指针的地图,以便用户知道起点在哪里?
I am using java and iText to create a pdf. Is it possible to add a map with a pointer on it so the user will know where the starting point is?
说明(来自OP同时删除的答案,应该是对问题的修改)
Clarification (from a meanwhile deleted answer by the OP which should have been an edit of the question)
我的问题是我可以从Web而不是图像上添加到iText谷歌地图
my problem is can i add at iText google map from web and not as an image
推荐答案
由于您没有回答我在评论中添加的反对问题,因此我为您提供了两个示例.如果这些不是您想要的,那么您真的应该澄清您的问题.
Since you didn't answer my counter-question added in comment, I'm providing you two examples. If these are not what you're looking for, you really should clarify your question.
示例1:在地图顶部添加自定义形状作为额外内容
在 AddPointer 示例中对此进行了演示:
This is demonstrated in the AddPointer example:
PdfContentByte canvas = writer.getDirectContent();
canvas.setColorStroke(BaseColor.RED);
canvas.setLineWidth(3);
canvas.moveTo(220, 330);
canvas.lineTo(240, 370);
canvas.arc(200, 350, 240, 390, 0, (float) 180);
canvas.lineTo(220, 330);
canvas.closePathStroke();
canvas.setColorFill(BaseColor.RED);
canvas.circle(220, 370, 10);
canvas.fill();
如果我们知道指针的坐标,则可以绘制直线和曲线,从而显示红色指针(请参见剑桥创新中心附近的红色针脚):
If we know the coordinates of the pointer, we can draw lines and curves that result in a the red pointer shown here (see the red pin near the Cambridge Innovation Center):
示例2:在地图顶部添加线条注释
在 AddPointerAnnotation 示例中进行了演示:
Rectangle rect = new Rectangle(220, 350, 475, 595);
PdfAnnotation annotation = PdfAnnotation.createLine(writer, rect, "Cambridge Innovation Center", 225, 355, 470, 590);
PdfArray le = new PdfArray();
le.add(new PdfName("OpenArrow"));
le.add(new PdfName("None"));
annotation.setTitle("You are here:");
annotation.setColor(BaseColor.RED);
annotation.setFlags(PdfAnnotation.FLAGS_PRINT);
annotation.setBorderStyle(
new PdfBorderDictionary(5, PdfBorderDictionary.STYLE_SOLID));
annotation.put(new PdfName("LE"), le);
annotation.put(new PdfName("IT"), new PdfName("LineArrow"));
writer.addAnnotation(annotation);
结果是一个注释(它不是真实内容的一部分,而是真实内容之上的交互式层的一部分):
The result is an annotation (which isn't part of the real content, but part of an interactive layer on top of the real content):
这是交互式的,即当用户单击注释时会显示更多信息:
It is interactive in the sense that extra info is shown when the user clicks the annotation:
还有许多其他选择,但再次重申:您的问题并不十分清楚.
Many other options are possible, but once again: your question wasn't entirely clear.
这篇关于在iText Java中添加地图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!