How to add a map with a pointer in the PDF file?

Question. I am using Java and iText to create a PDF file. Is it possible to add a map with a pointer to let the user know where is the original point?
March 23rd 20 at 18:51
1 answer
March 23rd 20 at 18:53
What do you mean by "a map with a pointer to let the user know where is the original point"? If the PDF file has a map you can add annotation arrows. This is what you need?
Here are two examples.
Example 1: adding a custom form as additional content on top of maps
This option is illustrated in example AddPointer:
PdfCanvas canvas = new PdfCanvas(pdfDoc.getFirstPage());
 .moveTo(220, 330)
 .lineTo(240, 370)
 .arc(200, 350, 240, 390, 0, (float) 180)
 .lineTo(220, 330)
 .circle(220, 370, 10)

If you know the coordinates, you can draw lines and curves, the red indicator like the picture below (the red indicator near Cambridge Innovation Center):
Map with pointer

Example 2: add string annotations over the map
This option is illustrated in example AddPointerAnnotation:
Rectangle rect = new Rectangle(220, 350, 255, 245);
PdfLineAnnotation lineAnnotation = new PdfLineAnnotation(rect, new float[]{225, 355, 470, 590});
lineAnnotation.setTitle(new PdfString("You are here:"));
lineAnnotation.setContents("Cambridge Innovation Center");

BorderStyle PdfDictionary = new PdfDictionary();
borderStyle.put(PdfName.S, PdfName.S);
borderStyle.put(PdfName.W, new PdfNumber(5));

Le PdfArray = new PdfArray();
le.add(new PdfName("OpenArrow"));
le.add(new PdfName("None"));
lineAnnotation.put(new PdfName("LE"), le);
lineAnnotation.put(new PdfName("IT"), new PdfName("LineArrow"));


The result is abstract (it is part of the not real content, but the interactive layer is superimposed on top of the real content):
Map annotation

Layer is interactive: when the user clicks on the annotation an additional information:
Map is an open annotation

Find more questions by tags iTextPDF.NETJava