# How to Organize your PDFs in C#
IronPDF 提供了一套全面的工具,除了 PDF 生成功能外,其中一些工具可用于组织您的 PDF 文档结构。 从未有过如此简单的方法来编辑您的 PDF 结构。 操作您的 PDF 结构、添加书签和附件,并用一个库创建理想的 PDF 布局。 有了 IronPDF,您再也不用为 PDF 的组织而苦恼了。
在本综合教程中,我们将探讨如何使用 IronPDF 更好地组织 PDF 文档。 为此,我们将通过一些基本示例,引导您了解这些组织功能是如何工作的,并检查代码示例及其相应的解释。 本文结束后,您就可以直接使用 IronPDF 满足您的 PDF 组织需求了。
*as-heading:2(快速入门:使用IronPDF轻松合并 PDF )*
只需几行代码即可开始使用 IronPDF 组织您的 PDF。 此示例演示了如何使用 IronPDF 库轻松将多个 PDF 文档合并为一个。 这种方法非常适合希望快速而简单解决方案的开发人员,可以轻松集成到您的 C# 项目中,提高您的文档管理效率。
```cs
:title=Organize PDFs Instantly
IronPdf.PdfDocument.Merge(
IronPdf.PdfDocument.FromFile("file1.pdf"),
IronPdf.PdfDocument.FromFile("file2.pdf"))
.SaveAs("merged.pdf");
```
## 目录
- **组织您的 PDF 结构**
- [添加、复制和删除 PDF 页面](#anchor-manage-your-pdf-pages)
- [添加页面](#anchor-add-pages)
- [复制页面](#anchor-copy-pages)
- [删除页面](#anchor-delete-pages)
- [合并或拆分 PDF](#anchor-merge-pdfs)
- [拆分多页 PDF](#anchor-split-multipage-pdf)
- **补充组织**
- [添加和移除附件](#anchor-add-remove-attachments)
- [添加附件](#anchor-add-attachments)
- [移除附件](#anchor-remove-attachments)
- [大纲和书签](#anchor-outlines-bookmarks)
- [添加书签](#anchor-add-bookmarks)
- [检索书签](#anchor-retrieve-bookmarks)
## 组织您的 PDF 结构
让我们先来看看 IronPDF 提供的一些功能,帮助您控制 PDF 文件的结构。 使用这些工具,您可以轻松操控 PDF 文档内的页面及其定位。
### 管理您的 PDF 页面
通过添加新页面、从文件中删除不必要的页面甚至复制特定页面以创建重复项,为您的 PDF 文档添加新的内容。 通过操作 PDF 文档中的页面,您可以轻松调整 PDF 结构,以满足您的需求。
#### 添加页面
只需几行代码即可为您的 PDF 添加新页面。 使用 IronPDF,为您的 PDF 文件添加新内容轻而易举。
```cs
using IronPdf;
// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");
// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");
// Merge the two documents
PdfDocument finalPdf = PdfDocument.Merge(coverPage, contentPage);
finalPdf.SaveAs("pdfWithCover.pdf");
```
此方法简化了添加新页面的过程。 要在多页PDF文档中特定索引位置添加新页,可以使用`InsertPdf`方法轻松实现:
```cs
using IronPdf;
// Import cover page
PdfDocument coverPage = PdfDocument.FromFile("coverPage.pdf");
// Import content document
PdfDocument contentPage = PdfDocument.FromFile("contentPage.pdf");
// Insert PDF
contentPage.InsertPdf(coverPage, 0);
```
#### 复制页面
通过复制 PDF 文档中的页面,您可以轻松保持一致的风格并在多个 PDF 文件之间转移信息。 IronPDF的`CopyPages`方法提供了一种简单的方法,通过几行代码复制PDF中的特定页面。
```cs
using IronPdf;
using System.Collections.Generic;
// Copy a single page into a new PDF object
PdfDocument myReport = PdfDocument.FromFile("report_final.pdf");
PdfDocument copyOfPageOne = myReport.CopyPage(0);
// Copy multiple pages into a new PDF object
PdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
```
#### 删除页面
要从PDF中删除特定页面,您可以使用`RemovePages`方法,允许您以编程方式从文档中移除不需要的页面。
```cs
using IronPdf;
using System.Collections.Generic;
PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");
// Remove a single page
pdf.RemovePage(0);
// Remove multiple pages
pdf.RemovePages(new List<int> { 2, 3 });
```
有关上述代码片段的更详细说明以及探索其附加功能,请参阅我们的全面[指南](http://test.ironpdf.local/how-to/add-copy-delete-pages-pdf/)。
### 合并或拆分 PDF
#### 合并 PDF
using IronPDF 的合并工具将多个 PDF 文档合并为一个易于共享的 PDF。 这种功能特别有用,当您想要将相似文件分组以便于分发时,可以将单独的页面合并到一个新的 PDF 或执行各种其他 PDF 合并任务。 使用IronPDF的合并工具,您可以借利用`Merge`方法轻松自动化这一过程。
```cs
using IronPdf;
// Two paged PDF
const string html_a =
@"<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_A] 2nd Page</p>";
// Two paged PDF
const string html_b =
@"<p> [PDF_B] </p>
<p> [PDF_B] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_B] 2nd Page</p>";
var renderer = new ChromePdfRenderer();
var pdfdoc_a = renderer.RenderHtmlAsPdf(html_a);
var pdfdoc_b = renderer.RenderHtmlAsPdf(html_b);
// Four paged PDF
var merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b);
merged.SaveAs("Merged.pdf");
```
#### 拆分 PDF
就像您可能想将多个 PDF 合并为一个便于分享的 PDF 文档一样,有时您也可能想将多页 PDF 文件拆分为独立的文档。
```cs
using IronPdf;
// We will use the 4-page PDF from the Merge example above:
var pdf = PdfDocument.FromFile("Merged.pdf");
// Takes only the first page into a new PDF
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Page1Only.pdf");
// Take the pages 2 & 3 (Note: index starts at 0)
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Pages2to3.pdf");
```
有关上述代码片段的更详细说明以及探索其附加功能,请参阅我们的全面[指南](https://ironpdf.com/how-to/merge-or-split-pdfs/)。
### 拆分多页 PDF
要拆分多页 PDF,我们将采取类似于拆分单页 PDF 的方法。 在这种情况下,我们将使用 for 循环来完成任务。
```cs
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");
for (int idx = 0; idx < pdf.PageCount; idx++)
{
// Create new document for each page
PdfDocument outputDocument = pdf.CopyPage(idx);
string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf";
// Export to new file
outputDocument.SaveAs(fileName);
}
```
有关上述代码片段的更详细说明以及探索其附加功能,请参阅我们的全面[指南](https://ironpdf.com/how-to/split-multipage-pdf/)。
## 组织工具
在本节中,我们将仔细研究 IronPDF 提供的一些工具,以改善您的 PDF 文档的组织。 通过利用这些工具,您可以增强 PDF 文档,使其更易于读者浏览多页内容。
### 添加和移除附件
通过附件链接到支持文件、相关内容等,提高您的 PDF 文件质量。 通过添加附加材料、数据和图像到特定页面上,您可以避免文件中增加多余页面而造成的混乱,使其更易于浏览。 使用 IronPDF,您可以轻松添加或移除附件,确保您的 PDF 保持相关性和简洁性。
#### 添加附件
```cs
using IronPdf;
using System.IO;
// Import attachment file
byte[] fileData = File.ReadAllBytes(@"path/to/file");
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData);
pdf.SaveAs("addAttachment.pdf");
```
#### 移除附件
```cs
using IronPdf;
using System.Linq;
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");
// Add attachment to the PDF
PdfAttachmentCollection retrieveAttachments = pdf.Attachments;
// Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First());
pdf.SaveAs("removeAttachment.pdf");
```
有关上述代码片段的更详细说明以及探索其附加功能,请参阅我们的全面[指南](https://ironpdf.com/how-to/add-remove-attachments/)。
### 大纲和书签
在多页 PDF 文档中使用大纲,可以大大提高文档的可用性,使读者更容易浏览到其中的特定页面。 使用 IronPDF,您可以为您的 PDF 创建一个自定义大纲,并带有书签,为读者提供无缝的导航体验。 同样,您可以检索 PDF 中当前书签的列表,让您快速查看您的大纲的当前结构。
#### 添加书签
IronPDF 支持单层和多层书签,完全控制您的 PDF 文档大纲中细节的层次,根据您的特定需求和 PDF 文件的长度量身定制。
```cs
using IronPdf;
// Create a new PDF or edit an existing document.
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");
// Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);
// Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);
pdf.SaveAs("singleLayerBookmarks.pdf");
```
#### 检索书签
要检查PDF文档中的现有书签,`GetAllBookmarks`工具提供了一种简单的方法来获取任何给定PDF文件中所有书签的完整列表。
```cs
using IronPdf;
// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");
// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();
```
有关上述代码片段的更详细说明以及探索其附加功能,请参阅我们的全面[指南](https://ironpdf.com/how-to/bookmarks/)。
## 结论
using IronPDF 管理您的 PDF 可以很简单。 此工具提供了一整套功能,使您能够管理页面、合并或拆分文档、创建大纲以及处理附件——这一切都使用简洁明了的 C# 代码。 无论您是创建新文档还是重组现有文档,IronPDF 都能让您轻松制作出精美、专业、易于浏览和共享的 PDF 文档。
如果您对 IronPDF 有任何疑问或想要请求功能,请联系我们的[支持团队](/troubleshooting/engineering-request-pdf/)。 我们很乐意为您提供帮助。
Imports IronPdf
' Import cover page
Private coverPage As PdfDocument = PdfDocument.FromFile("coverPage.pdf")
' Import content document
Private contentPage As PdfDocument = PdfDocument.FromFile("contentPage.pdf")
' Insert PDF
contentPage.InsertPdf(coverPage, 0)
复制页面
通过复制 PDF 文档中的页面,您可以轻松保持一致的风格并在多个 PDF 文件之间转移信息。 IronPDF的CopyPages方法提供了一种简单的方法,通过几行代码复制PDF中的特定页面。
using IronPdf;using System.Collections.Generic;// Copy a single page into a new PDF objectPdfDocument myReport = PdfDocument.FromFile("report_final.pdf");PdfDocument copyOfPageOne = myReport.CopyPage(0);// Copy multiple pages into a new PDF objectPdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
using IronPdf;
using System.Collections.Generic;
// Copy a single page into a new PDF object
PdfDocument myReport = PdfDocument.FromFile("report_final.pdf");
PdfDocument copyOfPageOne = myReport.CopyPage(0);
// Copy multiple pages into a new PDF object
PdfDocument copyOfFirstThreePages = myReport.CopyPages(new List<int> { 0, 1, 2 });
ImportsIronPdfImportsSystem.Collections.Generic' Copy a single page into a new PDF objectPrivate myReport AsPdfDocument = PdfDocument.FromFile("report_final.pdf")Private copyOfPageOne AsPdfDocument = myReport.CopyPage(0)' Copy multiple pages into a new PDF objectPrivate copyOfFirstThreePages AsPdfDocument = myReport.CopyPages(New List(OfInteger) From {0, 1, 2})
Imports IronPdf
Imports System.Collections.Generic
' Copy a single page into a new PDF object
Private myReport As PdfDocument = PdfDocument.FromFile("report_final.pdf")
Private copyOfPageOne As PdfDocument = myReport.CopyPage(0)
' Copy multiple pages into a new PDF object
Private copyOfFirstThreePages As PdfDocument = myReport.CopyPages(New List(Of Integer) From {0, 1, 2})
using IronPdf;using System.Collections.Generic;PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");// Remove a single pagepdf.RemovePage(0);// Remove multiple pagespdf.RemovePages(new List<int> { 2, 3 });
using IronPdf;
using System.Collections.Generic;
PdfDocument pdf = PdfDocument.FromFile("full_report.pdf");
// Remove a single page
pdf.RemovePage(0);
// Remove multiple pages
pdf.RemovePages(new List<int> { 2, 3 });
ImportsIronPdfImportsSystem.Collections.GenericPrivate pdf AsPdfDocument = PdfDocument.FromFile("full_report.pdf")' Remove a single pagepdf.RemovePage(0)' Remove multiple pagespdf.RemovePages(New List(OfInteger) From {2, 3})
Imports IronPdf
Imports System.Collections.Generic
Private pdf As PdfDocument = PdfDocument.FromFile("full_report.pdf")
' Remove a single page
pdf.RemovePage(0)
' Remove multiple pages
pdf.RemovePages(New List(Of Integer) From {2, 3})
Imports IronPdf
' Two paged PDF
Private Const html_a As String = "<p> [PDF_A] </p>
<p> [PDF_A] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_A] 2nd Page</p>"
' Two paged PDF
Private Const html_b As String = "<p> [PDF_B] </p>
<p> [PDF_B] 1st Page </p>
<div style = 'page-break-after: always;' ></div>
<p> [PDF_B] 2nd Page</p>"
Private renderer = New ChromePdfRenderer()
Private pdfdoc_a = renderer.RenderHtmlAsPdf(html_a)
Private pdfdoc_b = renderer.RenderHtmlAsPdf(html_b)
' Four paged PDF
Private merged = PdfDocument.Merge(pdfdoc_a, pdfdoc_b)
merged.SaveAs("Merged.pdf")
拆分 PDF
就像您可能想将多个 PDF 合并为一个便于分享的 PDF 文档一样,有时您也可能想将多页 PDF 文件拆分为独立的文档。
using IronPdf;// We will use the 4-page PDF from the Merge example above:var pdf = PdfDocument.FromFile("Merged.pdf");// Takes only the first page into a new PDFvar page1doc = pdf.CopyPage(0);page1doc.SaveAs("Page1Only.pdf");// Take the pages 2 & 3 (Note: index starts at 0)var page23doc = pdf.CopyPages(1, 2);page23doc.SaveAs("Pages2to3.pdf");
using IronPdf;
// We will use the 4-page PDF from the Merge example above:
var pdf = PdfDocument.FromFile("Merged.pdf");
// Takes only the first page into a new PDF
var page1doc = pdf.CopyPage(0);
page1doc.SaveAs("Page1Only.pdf");
// Take the pages 2 & 3 (Note: index starts at 0)
var page23doc = pdf.CopyPages(1, 2);
page23doc.SaveAs("Pages2to3.pdf");
ImportsIronPdf' We will use the 4-page PDF from the Merge example above:Private pdf = PdfDocument.FromFile("Merged.pdf")' Takes only the first page into a new PDFPrivate page1doc = pdf.CopyPage(0)page1doc.SaveAs("Page1Only.pdf")' Take the pages 2 & 3 (Note: index starts at 0)Dim page23doc = pdf.CopyPages(1, 2)page23doc.SaveAs("Pages2to3.pdf")
Imports IronPdf
' We will use the 4-page PDF from the Merge example above:
Private pdf = PdfDocument.FromFile("Merged.pdf")
' Takes only the first page into a new PDF
Private page1doc = pdf.CopyPage(0)
page1doc.SaveAs("Page1Only.pdf")
' Take the pages 2 & 3 (Note: index starts at 0)
Dim page23doc = pdf.CopyPages(1, 2)
page23doc.SaveAs("Pages2to3.pdf")
要拆分多页 PDF,我们将采取类似于拆分单页 PDF 的方法。 在这种情况下,我们将使用 for 循环来完成任务。
using IronPdf;PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");for (int idx = 0; idx < pdf.PageCount; idx++){ // Create new document for each page PdfDocument outputDocument = pdf.CopyPage(idx); string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf"; // Export to new file outputDocument.SaveAs(fileName);}
using IronPdf;
PdfDocument pdf = PdfDocument.FromFile("multiPage.pdf");
for (int idx = 0; idx < pdf.PageCount; idx++)
{
// Create new document for each page
PdfDocument outputDocument = pdf.CopyPage(idx);
string fileName = @$"multiPage - Page {idx + 1}_tempfile.pdf";
// Export to new file
outputDocument.SaveAs(fileName);
}
ImportsIronPdfPrivate pdf AsPdfDocument = PdfDocument.FromFile("multiPage.pdf")For idx AsInteger = 0 To pdf.PageCount - 1 ' Create new document for each page Dim outputDocument AsPdfDocument = pdf.CopyPage(idx) Dim fileName AsString = $"multiPage - Page {idx + 1}_tempfile.pdf" ' Export to new file outputDocument.SaveAs(fileName)Next idx
Imports IronPdf
Private pdf As PdfDocument = PdfDocument.FromFile("multiPage.pdf")
For idx As Integer = 0 To pdf.PageCount - 1
' Create new document for each page
Dim outputDocument As PdfDocument = pdf.CopyPage(idx)
Dim fileName As String = $"multiPage - Page {idx + 1}_tempfile.pdf"
' Export to new file
outputDocument.SaveAs(fileName)
Next idx
在本节中,我们将仔细研究 IronPDF 提供的一些工具,以改善您的 PDF 文档的组织。 通过利用这些工具,您可以增强 PDF 文档,使其更易于读者浏览多页内容。
添加和移除附件
通过附件链接到支持文件、相关内容等,提高您的 PDF 文件质量。 通过添加附加材料、数据和图像到特定页面上,您可以避免文件中增加多余页面而造成的混乱,使其更易于浏览。 使用 IronPDF,您可以轻松添加或移除附件,确保您的 PDF 保持相关性和简洁性。
添加附件
using IronPdf;using System.IO;// Import attachment filebyte[] fileData = File.ReadAllBytes(@"path/to/file");// Open existing PDFPdfDocument pdf = PdfDocument.FromFile("sample.pdf");// Add attachment to the PDFpdf.Attachments.AddAttachment("Example", fileData);pdf.SaveAs("addAttachment.pdf");
using IronPdf;
using System.IO;
// Import attachment file
byte[] fileData = File.ReadAllBytes(@"path/to/file");
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("sample.pdf");
// Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData);
pdf.SaveAs("addAttachment.pdf");
ImportsIronPdfImportsSystem.IO' Import attachment filePrivate fileData() AsByte = File.ReadAllBytes("path/to/file")' Open existing PDFPrivate pdf AsPdfDocument = PdfDocument.FromFile("sample.pdf")' Add attachment to the PDFpdf.Attachments.AddAttachment("Example", fileData)pdf.SaveAs("addAttachment.pdf")
Imports IronPdf
Imports System.IO
' Import attachment file
Private fileData() As Byte = File.ReadAllBytes("path/to/file")
' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("sample.pdf")
' Add attachment to the PDF
pdf.Attachments.AddAttachment("Example", fileData)
pdf.SaveAs("addAttachment.pdf")
移除附件
using IronPdf;using System.Linq;// Open existing PDFPdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");// Add attachment to the PDFPdfAttachmentCollection retrieveAttachments = pdf.Attachments;// Remove attachment from PDFpdf.Attachments.RemoveAttachment(retrieveAttachments.First());pdf.SaveAs("removeAttachment.pdf");
using IronPdf;
using System.Linq;
// Open existing PDF
PdfDocument pdf = PdfDocument.FromFile("addAttachment.pdf");
// Add attachment to the PDF
PdfAttachmentCollection retrieveAttachments = pdf.Attachments;
// Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First());
pdf.SaveAs("removeAttachment.pdf");
ImportsIronPdfImportsSystem.Linq' Open existing PDFPrivate pdf AsPdfDocument = PdfDocument.FromFile("addAttachment.pdf")' Add attachment to the PDFPrivate retrieveAttachments AsPdfAttachmentCollection = pdf.Attachments' Remove attachment from PDFpdf.Attachments.RemoveAttachment(retrieveAttachments.First())pdf.SaveAs("removeAttachment.pdf")
Imports IronPdf
Imports System.Linq
' Open existing PDF
Private pdf As PdfDocument = PdfDocument.FromFile("addAttachment.pdf")
' Add attachment to the PDF
Private retrieveAttachments As PdfAttachmentCollection = pdf.Attachments
' Remove attachment from PDF
pdf.Attachments.RemoveAttachment(retrieveAttachments.First())
pdf.SaveAs("removeAttachment.pdf")
在多页 PDF 文档中使用大纲,可以大大提高文档的可用性,使读者更容易浏览到其中的特定页面。 使用 IronPDF,您可以为您的 PDF 创建一个自定义大纲,并带有书签,为读者提供无缝的导航体验。 同样,您可以检索 PDF 中当前书签的列表,让您快速查看您的大纲的当前结构。
添加书签
IronPDF 支持单层和多层书签,完全控制您的 PDF 文档大纲中细节的层次,根据您的特定需求和 PDF 文件的长度量身定制。
using IronPdf;// Create a new PDF or edit an existing document.PdfDocument pdf = PdfDocument.FromFile("existing.pdf");// Add a bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);// Add a sub-bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);pdf.SaveAs("singleLayerBookmarks.pdf");
using IronPdf;
// Create a new PDF or edit an existing document.
PdfDocument pdf = PdfDocument.FromFile("existing.pdf");
// Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0);
// Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1);
pdf.SaveAs("singleLayerBookmarks.pdf");
ImportsIronPdf' Create a new PDF or edit an existing document.Private pdf AsPdfDocument = PdfDocument.FromFile("existing.pdf")' Add a bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0)' Add a sub-bookmarkpdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1)pdf.SaveAs("singleLayerBookmarks.pdf")
Imports IronPdf
' Create a new PDF or edit an existing document.
Private pdf As PdfDocument = PdfDocument.FromFile("existing.pdf")
' Add a bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfBookmark", 0)
' Add a sub-bookmark
pdf.Bookmarks.AddBookMarkAtEnd("NameOfSubBookmark", 1)
pdf.SaveAs("singleLayerBookmarks.pdf")
using IronPdf;// Load existing PDF documentPdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");// Retrieve bookmarks listvar mainBookmark = pdf.Bookmarks.GetAllBookmarks();
using IronPdf;
// Load existing PDF document
PdfDocument pdf = PdfDocument.FromFile("multiLayerBookmarks.pdf");
// Retrieve bookmarks list
var mainBookmark = pdf.Bookmarks.GetAllBookmarks();
ImportsIronPdf' Load existing PDF documentPrivate pdf AsPdfDocument = PdfDocument.FromFile("multiLayerBookmarks.pdf")' Retrieve bookmarks listPrivate mainBookmark = pdf.Bookmarks.GetAllBookmarks()
Imports IronPdf
' Load existing PDF document
Private pdf As PdfDocument = PdfDocument.FromFile("multiLayerBookmarks.pdf")
' Retrieve bookmarks list
Private mainBookmark = pdf.Bookmarks.GetAllBookmarks()