Skip to content

Commit b1b7c0d

Browse files
authored
doc(EmbedPDF): add EmbedPDF documentation (#7508)
* doc: 更新示例 * doc: 增加 EmbedPdfs 组件
1 parent e1858d6 commit b1b7c0d

7 files changed

Lines changed: 67 additions & 1 deletion

File tree

exclusion.dic

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,4 @@ vditor
124124
alertdialog
125125
blazorbootstrap
126126
llms
127+
ebook

src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<PackageReference Include="BootstrapBlazor.Dom2Image" Version="10.0.1" />
3939
<PackageReference Include="BootstrapBlazor.DriverJs" Version="10.0.1" />
4040
<PackageReference Include="BootstrapBlazor.ElementIcon" Version="10.0.0" />
41+
<PackageReference Include="BootstrapBlazor.EmbedPDF" Version="10.0.0-beta01" />
4142
<PackageReference Include="BootstrapBlazor.FileViewer" Version="10.0.0" />
4243
<PackageReference Include="BootstrapBlazor.FluentSystemIcon" Version="10.0.0" />
4344
<PackageReference Include="BootstrapBlazor.FontAwesome" Version="10.0.0" />
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@page "/embed-pdf"
2+
@inject IStringLocalizer<EmbedPdfs> Localizer
3+
4+
@* <h3>@Localizer["PdfTitle"]</h3>
5+
<h3>@Localizer["PdfDescription"]</h3>
6+
7+
<PackageTips Name="BootstrapBlazor.EmbedPDF" />
8+
*@
9+
<DemoBlock Title="@Localizer["PdfReaderNormalText"]" Introduction="@Localizer["PdfReaderNormalIntro"]" Name="Normal">
10+
<div class="" style="border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); overflow: hidden;">
11+
<EmbedPDF></EmbedPDF>
12+
</div>
13+
</DemoBlock>
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the Apache 2.0 License
3+
// See the LICENSE file in the project root for more information.
4+
// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
5+
6+
namespace BootstrapBlazor.Server.Components.Samples;
7+
8+
/// <summary>
9+
/// PdfReaders
10+
/// </summary>
11+
public partial class EmbedPdfs
12+
{
13+
[Inject, NotNull]
14+
private IWebHostEnvironment? WebHostEnvironment { get; set; }
15+
16+
[Inject, NotNull]
17+
private DownloadService? DownloadService { get; set; }
18+
19+
private bool _showTwoPagesOneView = true;
20+
private bool _showPrint = true;
21+
private bool _enableThumbnails = true;
22+
private bool _showDownload = true;
23+
private bool _showToolbar = true;
24+
private bool _showFileName = true;
25+
private string _url = "./samples/sample.pdf";
26+
private string _streamFileName = "";
27+
28+
private async Task<Stream> OnGetStreamAsync()
29+
{
30+
await Task.Yield();
31+
if (string.IsNullOrEmpty(_streamFileName))
32+
{
33+
return Stream.Null;
34+
}
35+
36+
var stream = File.OpenRead(Path.Combine(WebHostEnvironment.WebRootPath, "samples", _streamFileName));
37+
return stream;
38+
}
39+
40+
private void GetTestStream()
41+
{
42+
_url = "";
43+
_streamFileName = "ebook.pdf";
44+
}
45+
46+
private void GetSampleStream()
47+
{
48+
_url = "";
49+
_streamFileName = "sample.pdf";
50+
}
51+
}

src/BootstrapBlazor.Server/Components/Samples/PdfReaders.razor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private async Task<Stream> OnGetStreamAsync()
4040
private void GetTestStream()
4141
{
4242
_url = "";
43-
_streamFileName = "sample2.pdf";
43+
_streamFileName = "ebook.pdf";
4444
}
4545

4646
private void GetSampleStream()
180 KB
Binary file not shown.
-630 KB
Binary file not shown.

0 commit comments

Comments
 (0)