可以使用OutlineItemCollection在PDF文档中添加书签。 首先,你需要使用文档对象打开PDF文档。在那之后,你可以在文档对象的Outlines集合中添加OutlineItemCollection。然而,在将OutlineItemCollection添加到Outlines集合之前,你需要定义书签的属性。
下面是在PDF文件中添加书签的代码片段
C#
//open document
Document pdfDocument = new Document("input.pdf");
//create a bookmark object
OutlineItemCollection pdfOutline = new OutlineItemCollection(pdfDocument.Outlines);
pdfOutline.Title = "Test Outline";
pdfOutline.Italic = true;
pdfOutline.Bold = true;
//set the destination page number
pdfOutline.Action = new Aspose.Pdf.InteractiveFeatures.GoToAction(doc.Pages[1]);
//add bookmark in the document's outline collection.
pdfDocument.Outlines.Add(pdfOutline);
//save output
pdfDocument.Save("output.pdf");
VB.NET
'open document
Dim pdfDocument As New Document("input.pdf")
'create a bookmark object
Dim pdfOutline As New OutlineItemCollection(pdfDocument.Outlines)
pdfOutline.Title = "Test Outline"
pdfOutline.Italic = True
pdfOutline.Bold = True
'set the destination page number
pdfOutline.Action = New Aspose.Pdf.InteractiveFeatures.GoToAction(doc.Pages(1))
'add bookmark in the document's outline collection.
pdfDocument.Outlines.Add(pdfOutline)
'save output
pdfDocument.Save("output.pdf")
本文暂时没有评论,来添加一个吧(●'◡'●)