Skip to content

Commit 8d9fbf4

Browse files
committed
PdfViewer failed when the pdf has password #1184 - Intital commot
1 parent d3babfe commit 8d9fbf4

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

BlazorBootstrap.Demo.RCL/Components/Pages/PdfViewer/PdfViewerDocumentation.razor

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@
3535
<Image Src="https://github.com/user-attachments/assets/2a2afd0d-9065-456c-9866-db10f81b7780" Alt="Blazor Bootstrap: Blazor PDF Viewer Component - RTL doc"/>
3636
</Section>
3737

38+
<Section Size="HeadingSize.H2" Name="Password protected" PageUrl="@pageUrl" Link="password-protected">
39+
<Demo Type="typeof(PdfViewer_Demo_05_Password_Protected_A)" Tabs="true" />
40+
</Section>
41+
42+
<Section Size="HeadingSize.H2" Name="Prompt for password" PageUrl="@pageUrl" Link="prompt-for-password">
43+
<Demo Type="typeof(PdfViewer_Demo_05_Password_Protected_B_Prompt_For_Password)" Tabs="true" />
44+
</Section>
45+
3846
@code {
3947
private const string pageUrl = RouteConstants.Demos_PDFViewer_Documentation;
4048
private const string pageTitle = "Blazor PDF Viewer";
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<p>@eventLog</p>
2+
3+
<PdfViewer Class="mb-3"
4+
Url="@($"{StringConstants.DocsBasePath}/pdf_password_protected.pdf")"
5+
Password="12345"
6+
OnDocumentLoaded="OnDocumentLoaded"
7+
OnPageChanged="OnPageChanged" />
8+
9+
@code {
10+
private string documentUrl = $"{StringConstants.DocsBasePath}/pdf_password_protected.pdf";
11+
private string eventLog { get; set; } = $"Last event: ..., CurrentPage: 0, TotalPages: 0";
12+
13+
private void OnDocumentLoaded(PdfViewerEventArgs args)
14+
=> eventLog = $"Last event: OnDocumentLoaded, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";
15+
16+
private void OnPageChanged(PdfViewerEventArgs args)
17+
=> eventLog = $"Last event: OnPageChanged, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";
18+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<p>@eventLog</p>
2+
3+
<PdfViewer Class="mb-3"
4+
Url="@($"{StringConstants.DocsBasePath}/pdf_password_protected.pdf")"
5+
OnDocumentLoaded="OnDocumentLoaded"
6+
OnPageChanged="OnPageChanged" />
7+
8+
@code {
9+
private string documentUrl = $"{StringConstants.DocsBasePath}/pdf_password_protected.pdf";
10+
private string eventLog { get; set; } = $"Last event: ..., CurrentPage: 0, TotalPages: 0";
11+
12+
private void OnDocumentLoaded(PdfViewerEventArgs args)
13+
=> eventLog = $"Last event: OnDocumentLoaded, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";
14+
15+
private void OnPageChanged(PdfViewerEventArgs args)
16+
=> eventLog = $"Last event: OnPageChanged, CurrentPage: {args.CurrentPage}, TotalPages: {args.TotalPages}";
17+
}

0 commit comments

Comments
 (0)