原創(chuàng)|其它|編輯:郝浩|2012-06-28 21:10:47.000|閱讀 489 次
概述:本文旨在提供開發(fā)人員了解如何在電子表格轉(zhuǎn)換成PDF文件時插入PDF書簽。Aspose.Cells允許您在運行時添加你所需要的標簽。PDF書簽可以大大地改善長PDF文檔的適航性。當添加書簽鏈接到PDF文檔的其他部分時,你可以準確地控制你所需要的視覺。你不只是鏈接到頁面等。本文我們將通過Aspose.Cells API來添加PDF書簽。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
本文旨在提供開發(fā)人員了解如何在電子表格轉(zhuǎn)換成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 ://fc6vip.cn/zh-CN/EVQuestions
本站文章除注明轉(zhuǎn)載外,均為本站原創(chuàng)或翻譯。歡迎任何形式的轉(zhuǎn)載,但請務(wù)必注明出處、不得修改原文相關(guān)鏈接,如果存在內(nèi)容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉(zhuǎn)載自:慧都控件網(wǎng)