Get Hyperlinks from Images in PDF using Java

A new release version Aspose.PDF for Java 17.7 has been added to the portfolio of Aspose.PDF product family. This release offers a feature to Get hyperlink associated with the image file, perform PDF file creation and manipulation with great stability. In this release, we have also improved the PDF form manipulation and the Flatten form fields feature is specifically improved. Furthermore, as a regular monthly release process, this version also includes fixes for issues reported in earlier release versions.

Get Hyperlink Associated with Image in PDF

Aspose.PDF for Java supports the feature to Add Image in existing PDF document and also the feature to Add Hyperlink to PDF document. However, there can be a scenario where an image already presents inside PDF document points to a web URL and you may have a requirement to get hyperlink associated with the image. Please note that links are represented as annotations in a PDF file and they can be added, updated, or deleted. Furthermore, Aspose.PDF for Java also supports getting the destination (URL) of the hyperlink in a PDF file so in order to accomplish above-mentioned requirement, we need to first search the images inside PDF document using following code snippet and then use the extracted rectangular coordinates to get the URL of LinkAnnotation from a specific region.

// Open document
 Document doc = new Document("D:\\Tests\\input.pdf");
 // Create ImagePlacementAbsorber object to perform image placement search
 ImagePlacementAbsorber abs = new ImagePlacementAbsorber();
 // Accept the absorber for first page
 doc.getPages().get_Item(1).accept(abs);
 // Display image placement properties for all placements
 for (ImagePlacement imagePlacement : (Iterable)abs.getImagePlacements())
 {     
     System.out.println("image width:" + imagePlacement.getRectangle().getWidth());
     System.out.println("image height:" + imagePlacement.getRectangle().getHeight());
     System.out.println("image LLX:" + imagePlacement.getRectangle().getLLX());
     System.out.println("image LLY:" + imagePlacement.getRectangle().getLLY());
     System.out.println("image horizontal resolution:" + imagePlacement.getResolution().getX());
     System.out.println("image vertical resolution:" + imagePlacement.getResolution().getY());
 }

Stable Inter-File Format Conversion

In this release, we have specifically improved the interfile format conversion features, so PDF to DOC, PDF to PPTX, PDF to HTML and PDF to PDF/A have become more stable and robust as compared to earlier release versions. Some customers also reported incorrect rendering of Chinese text/content when the PDF file is converted to HTML format. In some scenarios, the colors of images are also lost during PDF to HTML conversion and these scenarios are also fixed.

Miscellaneous fixes

As mentioned above, the tabular text alignment in resultant PPTX, missing notes in rendered PPTX, overlapping of text on table border during PDF to HTML conversion, splitting of text to multiple lines during PDF to PPTX conversion are also resolved. As it is always recommended to use the latest release of our API’s, so we suggest you please download the latest release of Aspose.PDF for Java 17.7 and check Release Notes section regarding the list of issues fixed in Aspose.PDF for Java 17.7