قم بإضافة PDF إشارات مرجعية ذات الوجهات المحددة
Contents
[
Hide
]
سيناريوهات الاستخدام الممكنة
الوجهات المسماة هي أنواع خاصة من الإشارات المرجعية أو الروابط الموجودة في PDF والتي لا تعتمد على PDF صفحة. هذا يعني أنه إذا تمت إضافة صفحات أو حذفها من PDF ، فقد تصبح الإشارات المرجعية غير صالحة ولكن ستظل الوجهات المسماة سليمة. لإنشاء وجهة محددة ، يرجى تعيينPdfBookmarkEntry.DestinationNameخاصية.
قم بإضافة PDF إشارات مرجعية ذات الوجهات المحددة
يرجى الاطلاع على نموذج التعليمات البرمجية التالي ، الخاص بهملف Excel المصدر و لهملف الإخراج PDF. تُظهر لقطة الشاشة الإشارات المرجعية والوجهات المسماة داخل الإخراج PDF. توضح لقطة الشاشة أيضًا كيفية عرض الوجهات المسماة وأنك بحاجة إلى إصدار احترافي من برنامج Acrobat Reader.
عينة من الرموز
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
//Load source Excel file | |
Workbook wb = new Workbook(sourceDir + "samplePdfBookmarkEntry_DestinationName.xlsx"); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Access cell C5 | |
Cell cell = ws.Cells["C5"]; | |
//Create Bookmark and Destination for this cell | |
PdfBookmarkEntry bookmarkEntry = new PdfBookmarkEntry(); | |
bookmarkEntry.Text = "Text"; | |
bookmarkEntry.Destination = cell; | |
bookmarkEntry.DestinationName = "AsposeCells--" + cell.Name; | |
//Access cell G56 | |
cell = ws.Cells["G56"]; | |
//Create Sub-Bookmark and Destination for this cell | |
PdfBookmarkEntry subbookmarkEntry1 = new PdfBookmarkEntry(); | |
subbookmarkEntry1.Text = "Text1"; | |
subbookmarkEntry1.Destination = cell; | |
subbookmarkEntry1.DestinationName = "AsposeCells--" + cell.Name; | |
//Access cell L4 | |
cell = ws.Cells["L4"]; | |
//Create Sub-Bookmark and Destination for this cell | |
PdfBookmarkEntry subbookmarkEntry2 = new PdfBookmarkEntry(); | |
subbookmarkEntry2.Text = "Text2"; | |
subbookmarkEntry2.Destination = cell; | |
subbookmarkEntry2.DestinationName = "AsposeCells--" + cell.Name; | |
//Add Sub-Bookmarks in list | |
ArrayList list = new ArrayList(); | |
list.Add(subbookmarkEntry1); | |
list.Add(subbookmarkEntry2); | |
//Assign Sub-Bookmarks list to Bookmark Sub-Entry | |
bookmarkEntry.SubEntry = list; | |
//Create PdfSaveOptions and assign Bookmark to it | |
PdfSaveOptions opts = new PdfSaveOptions(); | |
opts.Bookmark = bookmarkEntry; | |
//Save the workbook in Pdf format with given pdf save options | |
wb.Save(outputDir + "outputPdfBookmarkEntry_DestinationName.pdf", opts); |