Aspose十分高兴的宣布Aspose.PDF for Java新版本的发布。按照每月定期发布的流程,Aspose.PDF for Java 18.2已经发布并可以在我们的Maven知识库上下载。Aspose.PDF for Java 18.2是一个平衡版本,我们已经从Aspose.PDF for .NET 18.2 API移植了一些功能,以便为.NET和Java平台提供相同的功能。为了了解此版本API的新特性,我们建议您访问Aspose.PDF for Java 18.2发行说明页面。此外,以下是我们想强调的一些功能。
在现有的PDF文档中创建命名目标
使用Aspose.PDF for Java 18.2,您现在可以在Java应用程序中以编程方式创建命名目标。我们为com.aspose.pdf.Document类实现了getNamedDestinations()方法,该方法允许您在现有PDF文档中操作命名目标。NamedDestinationCollection具有如下属性:
- public IAppointment get_Item(String name); // Gets destination by its name
- public void set_Item(String name, IAppointment value); // Sets destination by its name
- public int getCount(); // Returns count of the destinations.
- public void remove(String name); // Removes destination by its name.
- public void add(String name, IAppointment appointment); // Adds new named destination.
以下代码片段演示了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,
new com.aspose.pdf.XYZExplicitDestination(i, 0, 600, 0.5)); } for (int i = 1; i <= 100; i++) {
// Create outlines (two outlines for every page) com.aspose.pdf.OutlineItemCollection item1 = new
com.aspose.pdf.OutlineItemCollection(pdf.getOutlines()); item1.setDestination (new
com.aspose.pdf.NamedDestination(pdf, "Page" + i)); item1.setTitle ("Page " + i + "(1)"); pdf.getOutlines().add(item1); com.aspose.pdf.OutlineItemCollection item2 =
new com.aspose.pdf.OutlineItemCollection(pdf.getOutlines()); item2.setDestination (new
com.aspose.pdf.NamedDestination(pdf, "Page" + i)); item2.setTitle ("Page " + i + "(2)"); pdf.getOutlines().add(item2); } // Update on of the named destinations pdf.getNamedDestinations().set_Item("Page50",
new com.aspose.pdf.XYZExplicitDestination(50, 0, 100, 2)); pdf.save(myDir+"result.pdf");
其他修复
我们始终建议用户使用我们API的最新版本,因为它们包括与早期发布版本中报告的问题相关的最新功能/改进和修复。 因此,请下载最新版本的Aspose.PDF for Java 18.2。
- Aspose.PDF for Java产品主页
- 下载Aspose.PDF for Java
- Aspose.PDF系列产品论坛– 发布您的技术问题和疑问,或者您在运行Aspose.PDF API时遇到的任何其他问题。
- Aspose.PDF for Java在线文档– 帮助文档和API参考文档。
- 启动博客订阅– 不要限制自己,您可以通过订阅Aspose.PDF博客,随时关注有关Aspose.PDF API,新功能,修复和其他API相关主题的最新消息。