Am 16.05.2019 um 11:40 schrieb Евгений Король:
Hello. I try to get information from Link Annotation of pdf file. How
do I know which page link links to? I tried get getCOSObject from
annotation and parse it for Dest to get page. Perhaps this can be done
easier?
This code segment from PDFDebugger may help:
private void collectLinkLocations() throws IOException
{
for (PDAnnotation annotation : page.getAnnotations())
{
if (annotation instanceof PDAnnotationLink)
{
PDAnnotationLink linkAnnotation = (PDAnnotationLink)
annotation;
PDAction action = linkAnnotation.getAction();
if (action instanceof PDActionURI)
{
PDActionURI uriAction = (PDActionURI) action;
rectMap.put(annotation.getRectangle(), "URI: " +
uriAction.getURI());
continue;
}
PDDestination destination;
if (action instanceof PDActionGoTo)
{
PDActionGoTo goToAction = (PDActionGoTo) action;
destination = goToAction.getDestination();
}
else
{
destination = linkAnnotation.getDestination();
}
if (destination instanceof PDNamedDestination)
{
destination = document.getDocumentCatalog().
findNamedDestinationPage((PDNamedDestination) destination);
}
if (destination instanceof PDPageDestination)
{
PDPageDestination pageDestination =
(PDPageDestination) destination;
int pageNum = pageDestination.retrievePageNumber();
if (pageNum != -1)
{
rectMap.put(annotation.getRectangle(), "Page
destination: " + (pageNum + 1));
}
}
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]