
We at Aspose are pleased to announce a new version of Aspose.PDF for Java. As part of our regular monthly release process, Aspose.PDF for Java 18.2 is now available for download from our Maven repository. This release aligns the Java API with features from Aspose.PDF for .NET 18.2, providing a consistent experience across .NET and Java platforms. For detailed information, see the release notes page for Aspose.PDF for Java 18.2. Below are some highlighted features.
Create Named Destination in Existing PDF Documents using Java
With Aspose.PDF for Java 18.2, you can programmatically create named destinations in your Java application. The new getNamedDestinations() method in the com.aspose.pdf.Document class lets you manage named destinations in existing PDFs. The NamedDestinationCollection provides these members:
- public IAppointment get_Item(String name); // Retrieves a destination by name
- public void set_Item(String name, IAppointment value); // Sets a destination by name
- public int getCount(); // Returns the number of destinations
- public void remove(String name); // Removes a destination by name
- public void add(String name, IAppointment appointment); // Adds a new named destination
The following snippet shows how to use getNamedDestinations():
Document pdf = new Document();
// Create document with 100 pages
for (int i = 1; i <= 100; i++)
{
Page page = pdf.getPages().add();
page.addStamp(new com.aspose.pdf.TextStamp("Page " + i));
// Named Destinations for every page
pdf.getNamedDestinations().add("Page" + i, <br>new com.aspose.pdf.XYZExplicitDestination(i, 0, 600, 0.5));
}
for (int i = 1; i <= 100; i++)
{<br> // Create outlines (two outlines for every page)
com.aspose.pdf.OutlineItemCollection item1 = new <br>com.aspose.pdf.OutlineItemCollection(pdf.getOutlines());
item1.setDestination (new <br>com.aspose.pdf.NamedDestination(pdf, "Page" + i));
item1.setTitle ("Page " + i + "(1)");
pdf.getOutlines().add(item1);
com.aspose.pdf.OutlineItemCollection item2 = <br>new com.aspose.pdf.OutlineItemCollection(pdf.getOutlines());
item2.setDestination (new <br>com.aspose.pdf.NamedDestination(pdf, "Page" + i));
item2.setTitle ("Page " + i + "(2)");
pdf.getOutlines().add(item2);
}
// Update one of the named destinations
pdf.getNamedDestinations().set_Item("Page50", <br>new com.aspose.pdf.XYZExplicitDestination(50, 0, 100, 2));
pdf.save(myDir+"result.pdf");
Miscellaneous Fixes
We always recommend using the latest API release to benefit from new features, improvements, and bug fixes. Download the latest version of Aspose.PDF for Java 18.2.
- Home page for Aspose.PDF for Java
- Download Aspose.PDF for Java
- Aspose.PDF product family forum – Post technical questions, share issues, and get support.
- Aspose.PDF for Java online documentation – Access help documentation and API references.
- Enable Blog Subscription – Stay updated on new features, fixes, and news for Aspose.PDF APIs.