Agregar PDF Marcadores con destinos con nombre

Posibles escenarios de uso

Los destinos con nombre son tipos especiales de marcadores o enlaces en PDF que no dependen de las páginas PDF. Significa que, si se agregan o eliminan páginas de PDF, los marcadores pueden dejar de ser válidos, pero los destinos designados permanecerán intactos. Para crear un destino con nombre, configure elPdfBookmarkEntry.DestinationNamepropiedad.

Agregar PDF Marcadores con destinos con nombre

Consulte el siguiente código de ejemplo, suarchivo fuente de Excel , y esarchivo de salida PDF. La captura de pantalla muestra los marcadores y los destinos con nombre dentro de la salida PDF. La captura de pantalla también describe cómo ver los destinos con nombre y que necesita la versión profesional de Acrobat Reader.

todo:imagen_alternativa_texto

Código de muestra

// 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);