Skip to content

Commit 156aed8

Browse files
Merge pull request #1485 from syncfusion-content/984373-pv-navigation
984373: Changes for the restructure for the navigation section for the blazor pdfviewer
2 parents ac2be78 + 1aa7701 commit 156aed8

File tree

11 files changed

+540
-471
lines changed

11 files changed

+540
-471
lines changed

Document-Processing-toc.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,16 @@
509509
</li>
510510
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/toolbar-customization">Toolbar Customization</a></li>
511511
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/command-manager">Command Manager</a></li>
512-
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/navigation">Navigation</a></li>
512+
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation">Interactive PDF Navigation</a>
513+
<ul>
514+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/page-navigation">Page Navigation</a>
515+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/bookmark-navigation">Bookmark Navigation</a>
516+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/page-thumbnail-navigation">Page Thumbnail Navigation</a>
517+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/hyperlink-navigation">Hyperlink Navigation</a>
518+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/table-of-content-navigation">Table of Content Navigation</a>
519+
<a href="/document-processing/pdf/pdf-viewer/blazor/interactive-pdf-navigation/modern-navigation-panel">Modern Navigation Panel</a>
520+
</ul>
521+
</li>
513522
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/magnification">Magnification</a></li>
514523
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/text-search">Text Search</a></li>
515524
<li> <a href="/document-processing/pdf/pdf-viewer/blazor/interaction">Interaction Mode</a></li>

Document-Processing/PDF/PDF-Viewer/blazor/interaction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,4 @@ The following code illustrates how to disable the annotation interaction.
9999

100100
## See also
101101

102-
* [Navigation in Blazor SfPdfViewer Component](./navigation)
102+
* [Navigation in Blazor SfPdfViewer Component](./interactive-pdf-navigation)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
layout: post
3+
title: Navigation in Blazor SfPdfViewer Component | Syncfusion
4+
description: Learn all about page navigation, bookmarks, thumbnails, hyperlinks, and the modern navigation panel in the Blazor SfPdfViewer component.
5+
platform: document-processing
6+
control: SfPdfViewer
7+
documentation: ug
8+
---
9+
10+
# Navigation in Blazor SfPdfViewer Component
11+
12+
Page navigation in the Syncfusion<sup style="font-size:70%">&reg;</sup> SfPdfViewer component can be performed using the following methods:
13+
14+
* Scroll through the pages.
15+
* Use the Go to page option in the built-in toolbar.
16+
* Select a bookmark in the bookmark panel.
17+
* Select a page in the thumbnail panel.
18+
* Click hyperlinks or entries in the table of contents.
19+
* Modern navigation panel.
20+
21+
## See also
22+
23+
* [Magnification in Blazor SfPdfViewer Component](./magnification)
24+
* [Getting Started with SmartPdfViewer in Blazor Web App](../../Smart-PDF-Viewer/blazor/getting-started/web-app)
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
layout: post
3+
title: Bookmark navigation in Blazor SfPdfViewer | Syncfusion
4+
description: Learn how to use the bookmark panel in the Blazor PDF Viewer to navigate to labeled destinations, including visibility options and behavior.
5+
platform: document-processing
6+
control: SfPdfViewer
7+
documentation: ug
8+
---
9+
10+
# Bookmark navigation in SfPdfViewer
11+
12+
Use the bookmark panel to jump directly to labeled destinations in a PDF.
13+
14+
Bookmarks defined in the PDF document are automatically loaded and listed in the bookmark panel. Selecting a bookmark navigates to its target. Nested bookmarks are supported; if the document has no bookmarks, the panel appears empty.
15+
16+
![Bookmark panel in Blazor PDF Viewer showing document bookmarks](../../blazor-classic/images/blazor-pdfviewer-bookmark-navigation.png)
17+
18+
Enable or disable the bookmark panel by setting the [EnableBookmarkPanel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableBookmarkPanel) property. This property only controls the panel’s visibility; bookmarks are read from the PDF.
19+
20+
```cshtml
21+
22+
@using Syncfusion.Blazor.SfPdfViewer
23+
24+
<SfPdfViewer2 Height="100%" Width="100%" DocumentPath="@DocumentPath" EnableBookmarkPanel="true" />
25+
26+
@code{
27+
public string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf";
28+
}
29+
30+
```
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
---
2+
layout: post
3+
title: Hyperlink navigation in Blazor SfPdfViewer | Syncfusion
4+
description: Learn how the Blazor PDF Viewer handles hyperlinks, including external URLs and in-document links, click behavior, and common link types.
5+
platform: document-processing
6+
control: SfPdfViewer
7+
documentation: ug
8+
---
9+
10+
# Hyperlink navigation in SfPdfViewer
11+
12+
Use hyperlinks in a PDF to navigate either to external URLs or to destinations within the same document. Hyperlinks are detected from the PDF content and work by default.
13+
14+
- External links (HTTP/HTTPS, etc.) open in the browser according to browser security and settings (for example, a new tab or window).
15+
- In-document links navigate directly to the referenced page or location in the viewer.
16+
17+
If a document does not contain hyperlinks, no link-specific highlighting appears.
18+
19+
![Hyperlink navigation in Blazor PDF Viewer](../../blazor-classic/images/blazor-pdfviewer-hyperlink-navigation.png)
Lines changed: 245 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,245 @@
1+
---
2+
layout: post
3+
title: Modern navigation panel in Blazor SfPdfViewer | Syncfusion
4+
description: Learn how the modern navigation panel in the Blazor PDF Viewer with custom panels with flexible layouts.
5+
platform: document-processing
6+
control: SfPdfViewer
7+
documentation: ug
8+
---
9+
10+
# Modern navigation panel in SfPdfViewer
11+
12+
The modern navigation panel consolidates thumbnails, bookmarks, comments, and custom panels in a single, flexible side panel for a streamlined navigation experience.
13+
14+
Enable the modern navigation panel using the [EnableNavigationPanel](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_EnableNavigationPanel) property. Visibility can be toggled from the UI or programmatically.
15+
16+
The following example enables the modern navigation panel:
17+
18+
```cshtml
19+
20+
@using Syncfusion.Blazor.SfPdfViewer;
21+
22+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
23+
Height="100%"
24+
Width="100%"
25+
EnableNavigationPanel="true">
26+
</SfPdfViewer2>
27+
28+
```
29+
30+
![Enable the modern navigation panel in Blazor PDF Viewer](../../blazor-classic/images/enable_modern_navigation_panel.png)
31+
32+
## Default items in the navigation panel
33+
34+
The modern navigation panel contains the following built-in items:
35+
36+
- Comment panel
37+
- Thumbnail panel
38+
- Bookmark panel
39+
40+
## Rearrange default items in the navigation panel
41+
42+
Use the `BuiltInItems` property, which accepts a list of [NavigationToolbarItem](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.NavigationToolbarItem.html) enums. The viewer renders the navigation icons in the exact sequence provided.
43+
44+
The following example displays Thumbnails first, followed by Bookmarks and the Comment panel.
45+
46+
```cshtml
47+
48+
@using Syncfusion.Blazor.SfPdfViewer;
49+
50+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
51+
Height="100%"
52+
Width="100%"
53+
EnableNavigationPanel="true">
54+
<NavigationToolbarSettings BuiltInItems="navigationToolbarItems"></NavigationToolbarSettings>
55+
</SfPdfViewer2>
56+
57+
@code {
58+
// Defines the list of built-in navigation items in the desired order.
59+
List<NavigationToolbarItem> navigationToolbarItems = new List<NavigationToolbarItem>()
60+
{
61+
NavigationToolbarItem.Thumbnails,
62+
NavigationToolbarItem.Bookmarks,
63+
NavigationToolbarItem.CommentPanel,
64+
};
65+
}
66+
67+
```
68+
69+
![Rearrange default items in the modern navigation panel](../../blazor-classic/images/rearrange_navigation_panel_items.png)
70+
71+
## Open or close the navigation panel programmatically
72+
73+
Open or close a navigation panel programmatically by calling the [ToggleItemByIndex](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.PdfViewerBase.html#Syncfusion_Blazor_SfPdfViewer_PdfViewerBase_ToggleItemByIndex_System_Int32_) method. Indices are zero-based and apply to the combined sequence of built-in and custom items.
74+
75+
The following example toggles the visibility of the second item in the navigation panel (index 1).
76+
77+
```cshtml
78+
79+
@using Syncfusion.Blazor.SfPdfViewer;
80+
81+
<button id="toggle-custom-panel-visibility-api-btn" @onclick="OpenCustomPanel">OpenCustomPanel</button>
82+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
83+
@ref="pdfViewer"
84+
Height="100%"
85+
Width="100%"
86+
EnableNavigationPanel="true">
87+
</SfPdfViewer2>
88+
89+
@code {
90+
private SfPdfViewer2? pdfViewer;
91+
private async Task OpenCustomPanel()
92+
{
93+
// Toggles the visibility of the navigation panel item at the specified index (1 in this case).
94+
await pdfViewer.ToggleItemByIndex(1);
95+
}
96+
}
97+
98+
```
99+
100+
![Toggle a navigation panel item by index](../../blazor-classic/images/navigation_panel_toggleitembyindex.png)
101+
102+
### Add custom items to the navigation panel
103+
104+
You can add custom items to the SfPdfViewer navigation toolbar. Create a list of [CustomNavigationToolbarItem](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.CustomNavigationToolbarItem.html) objects and assign it to the `CustomItems` property.
105+
106+
Each CustomNavigationToolbarItem object includes:
107+
- Index: Position of the item in the toolbar.
108+
- Name: Display name of the item.
109+
- TooltipText: Text shown on hover.
110+
- HeaderText: Header displayed at the top of the custom panel.
111+
- IconCss: CSS class for the item's icon.
112+
- Template: Custom template for panel content.
113+
- ItemType: Item type, such as [NavigationToolbarItemType.Button](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.NavigationToolbarItemType.html#Syncfusion_Blazor_SfPdfViewer_NavigationToolbarItemType_Button) or [NavigationToolbarItemType.Separator](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.NavigationToolbarItemType.html#Syncfusion_Blazor_SfPdfViewer_NavigationToolbarItemType_Separator).
114+
115+
### Add a custom template for the navigation panel
116+
117+
Define a custom UI for a navigation panel by assigning a RenderFragment to the `Template` property of a [CustomNavigationToolbarItem](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.SfPdfViewer.CustomNavigationToolbarItem.html).
118+
119+
The following example adds a default toolbar with a custom item containing a small, interactive panel with a customized UI.
120+
121+
```cshtml
122+
123+
@using Syncfusion.Blazor.SfPdfViewer
124+
125+
<SfPdfViewer2 @ref="pdfViewer"
126+
DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
127+
Height="100%"
128+
Width="100%" EnableNavigationPanel="true">
129+
<PdfViewerToolbarSettings ToolbarItems="ToolbarItems"></PdfViewerToolbarSettings>
130+
<NavigationToolbarSettings BuiltInItems="navigationToolbarItems" CustomItems="customNavigationToolbarItems"></NavigationToolbarSettings>
131+
</SfPdfViewer2>
132+
133+
@code {
134+
SfPdfViewer2 pdfViewer;
135+
// List of standard toolbar items.
136+
List<ToolbarItem> ToolbarItems = new List<ToolbarItem>()
137+
{
138+
ToolbarItem.OpenOption,
139+
ToolbarItem.PageNavigationTool,
140+
ToolbarItem.MagnificationTool,
141+
ToolbarItem.CommentTool,
142+
ToolbarItem.SelectionTool,
143+
ToolbarItem.PanTool,
144+
ToolbarItem.UndoRedoTool,
145+
ToolbarItem.SubmitForm,
146+
ToolbarItem.SearchOption,
147+
ToolbarItem.PrintOption,
148+
ToolbarItem.DownloadOption
149+
};
150+
// List of built-in navigation panel items.
151+
List<NavigationToolbarItem> navigationToolbarItems = new List<NavigationToolbarItem>()
152+
{
153+
NavigationToolbarItem.Thumbnails,
154+
NavigationToolbarItem.Bookmarks,
155+
NavigationToolbarItem.CommentPanel,
156+
};
157+
// List to hold the custom navigation toolbar items.
158+
List<CustomNavigationToolbarItem> customNavigationToolbarItems;
159+
160+
// Initializes the component and sets up the custom navigation items.
161+
protected override void OnInitialized()
162+
{
163+
customNavigationToolbarItems = new List<CustomNavigationToolbarItem>()
164+
{
165+
new CustomNavigationToolbarItem()
166+
{
167+
Name = "Edit Annotation",
168+
HeaderText = "Edit Annotation",
169+
IconCss = "e-pv-annotation-icon e-pv-icon",
170+
Index = 4,
171+
TooltipText = "Edit Annotation",
172+
ItemType = NavigationToolbarItemType.Button,
173+
Template = EditAnnotationTemplate()
174+
}
175+
};
176+
}
177+
178+
// Defines the RenderFragment for the custom panel's content.
179+
private RenderFragment EditAnnotationTemplate()
180+
{
181+
return @<div style="padding: 16px 24px; background-color: #f9fafb; border-top: 1px solid #e5e7eb; display: flex; flex-direction: column; align-items: center; gap: 12px; border-bottom-left-radius: 12px; border-bottom-right-radius: 12px;">
182+
<button style="background: #ffffff; color: #374151; border: 1px solid #d1d5db; padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer;" @onclick="AddRectangle">
183+
Add Rectangle
184+
</button>
185+
<button style="background: #ffffff; color: #374151; border: 1px solid #d1d5db; padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer;" @onclick="AddRadius">
186+
Add Radius
187+
</button>
188+
<button style="background: #ffffff; color: #374151; border: 1px solid #d1d5db; padding: 10px 18px; border-radius: 6px; font-size: 14px; font-weight: 500; cursor: pointer;" @onclick="AddFreeText">
189+
Add Free text
190+
</button>
191+
</div>;
192+
}
193+
194+
// Sets the annotation mode to Rectangle.
195+
private async Task AddRectangle()
196+
{
197+
await pdfViewer.SetAnnotationModeAsync(AnnotationType.Rectangle);
198+
}
199+
200+
// Sets the annotation mode to Radius.
201+
private async Task AddRadius()
202+
{
203+
await pdfViewer.SetAnnotationModeAsync(AnnotationType.Radius);
204+
}
205+
206+
// Sets the annotation mode to FreeText.
207+
private async Task AddFreeText()
208+
{
209+
await pdfViewer.SetAnnotationModeAsync(AnnotationType.FreeText);
210+
}
211+
}
212+
213+
```
214+
215+
![Custom template in the modern navigation panel](../../blazor-classic/images/custom_navigation_panel_template.png)
216+
217+
### Demand rendering for the navigation panel
218+
219+
SfPdfViewer supports different loading strategies for navigation panel content to optimize performance. The available options are:
220+
221+
* **Dynamic** : The content for a panel is only loaded into the DOM when that panel is selected. When you switch to a different panel, the previous content is removed and replaced.
222+
* **Init** : The content for all navigation panels is rendered during the initial load and is always present in the DOM.
223+
* **Demand** : The content for a panel is loaded into the DOM the first time it is selected. The content is then kept in the DOM, even if you navigate to other panels.
224+
225+
The following example sets the loading strategy to Demand.
226+
227+
```cshtml
228+
229+
@using Syncfusion.Blazor.SfPdfViewer;
230+
@using Syncfusion.Blazor.Navigations;
231+
232+
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"
233+
Height="100%"
234+
Width="100%"
235+
EnableNavigationPanel="true">
236+
<NavigationToolbarSettings LoadOn="ContentLoad.Demand"></NavigationToolbarSettings>
237+
</SfPdfViewer2>
238+
239+
```
240+
241+
### Modern navigation panel in mobile view
242+
243+
On mobile devices, the navigation toolbar collapses into a toggle menu to save space. Any custom items appear at the beginning of this menu.
244+
245+
![Modern navigation panel in mobile view](../../blazor-classic/images/navigation_panel_mobile.png)

0 commit comments

Comments
 (0)