彩票走势图

Aspose.Cells电子表格组件使用技巧(十):添加PDF书签

原创|其它|编辑:郝浩|2012-06-28 21:10:47.000|阅读 467 次

概述:本文旨在提供开发人员了解如何在电子表格转换成PDF文件时插入PDF书签。Aspose.Cells允许您在运行时添加你所需要的标签。PDF书签可以大大地改善长PDF文档的适航性。当添加书签链接到PDF文档的其他部分时,你可以准确地控制你所需要的视觉。你不只是链接到页面等。本文我们将通过Aspose.Cells API来添加PDF书签。

# 慧都年终大促·界面/图表报表/文档/IDE等千款热门软控件火热促销中 >>

本文旨在提供开发人员了解如何在电子表格转换成PDF文件时插入PDF书签。Aspose.Cells允许您在运行时添加你所需要的标签。PDF书签可以大大地改善长PDF文档的适航性。当添加书签链接到PDF文档的其他部分时,你可以准确地控制你所需要的视觉。你不只是链接到页面等。本文我们将通过Aspose.Cells API来添加PDF书签。

[Java]

//Instantiate a new wor30pxkbook.
Workbook workbook = new Workbook();
//Get the worksheets in the workbook.
WorksheetCollection worksheets = workbook.getWorksheets();
//Add a sheet to the workbook.
worksheets.add("1");
//Add 2nd sheet to the workbook.
worksheets.add("2");
//Add the third sheet.
worksheets.add("3");
//Get cells in different worksheets.
Cell cellInPage1 = worksheets.get(0).getCells().get("A1");
Cell cellInPage2 = worksheets.get(1).getCells().get("A1");
Cell cellInPage3 = worksheets.get(2).getCells().get("A1");

//Add a value to the A1 cell in the first sheet.
cellInPage1.setValue("a");
//Add a value to the A1 cell in the second sheet.
cellInPage2.setValue("b");
//Add a value to the A1 cell in the third sheet.
cellInPage3.setValue("c");

//Create the PdfBookmark entry object.
PdfBookmarkEntry pbeRoot = new PdfBookmarkEntry();
//Set its text.
pbeRoot.setText("root");
//Set its destination source page.
pbeRoot.setDestination(cellInPage1);
//Set the bookmark collapsed.
pbeRoot.setOpen(false);
//Add a new PdfBookmark entry object.
PdfBookmarkEntry subPbe1 = new PdfBookmarkEntry();
//Set its text.
subPbe1.setText("1");
//Set its destination source page.
subPbe1.setDestination(cellInPage2);

//Add another PdfBookmark entry object.
PdfBookmarkEntry subPbe2 = new PdfBookmarkEntry();
//Set its text.
subPbe2.setText("2");
//Set its destination source page.
subPbe2.setDestination(cellInPage3);
//Create an array list.
ArrayList subEntryList = new ArrayList();
//Add the entry objects to it.
subEntryList.add(subPbe1);
subEntryList.add(subPbe2);
pbeRoot.setSubEntry(subEntryList);

//Set the pdf bookmarks, you need to specify the root object here.
workbook.getSaveOptions().setPdfBookmark(pbeRoot);

//Save the pdf file.
workbook.save("d:\\files\\PdfBookmarks_test.pdf", FileFormatType.PDF);

查看Aspose.Cells FAQ ://pclwef.cn/zh-CN/EVQuestions


(慧都控件网版权所有,转载请注明出处,否则追究法律责任)
标签:

本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@pclwef.cn

文章转载自:慧都控件网

为你推荐

  • 推荐视频
  • 推荐活动
  • 推荐产品
  • 推荐文章
  • 慧都慧问
扫码咨询


添加微信 立即咨询

电话咨询

客服热线
023-68661681

TOP