Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/BootstrapBlazor.Server/BootstrapBlazor.Server.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<PackageReference Include="BootstrapBlazor.OctIcon" Version="9.0.4" />
<PackageReference Include="BootstrapBlazor.OnScreenKeyboard" Version="9.0.1" />
<PackageReference Include="BootstrapBlazor.PdfReader" Version="9.0.1" />
<PackageReference Include="BootstrapBlazor.PdfViewer" Version="9.0.0-beta01" />
<PackageReference Include="BootstrapBlazor.Player" Version="9.0.1" />
<PackageReference Include="BootstrapBlazor.RDKit" Version="9.0.2" />
<PackageReference Include="BootstrapBlazor.SignaturePad" Version="9.0.1" />
Expand Down
12 changes: 12 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/PdfViewers.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@page "/pdf-viewer"
@inject IStringLocalizer<PdfViewers> Localizer

<h3>@Localizer["PdfViewerTitle"]</h3>

<h4>@Localizer["PdfViewerDescription"]</h4>

<PackageTips Name="BootstrapBlazor.PdfViewer" />

<DemoBlock Title="@Localizer["PdfViewerNormalTitle"]" Introduction="@Localizer["PdfViewerNormalIntro"]" Name="Normal">
<PdfViewer Url="./samples/pdf-viewer.pdf" Height="620px"></PdfViewer>
</DemoBlock>
268 changes: 268 additions & 0 deletions src/BootstrapBlazor.Server/Components/Samples/PdfViewers.razor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,268 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License
// See the LICENSE file in the project root for more information.
// Maintainer: Argo Zhang([email protected]) Website: https://www.blazor.zone

using System.ComponentModel;

namespace BootstrapBlazor.Server.Components.Samples;

/// <summary>
/// PdfViewers
/// </summary>
public partial class PdfViewers
{
[NotNull]
PdfReader? AdvancedPdfReader { get; set; }

[DisplayName("流模式")]
private bool StreamMode { get; set; }

[DisplayName("禁用复制/打印/下载")]
private bool ReadOnly { get; set; }

[DisplayName("水印内容")]
private string Watermark { get; set; } = "www.blazor.zone";

private EnumZoomMode Zoom { get; set; } = EnumZoomMode.PageHeight;

private EnumPageMode PageMode { get; set; } = EnumPageMode.None;

[DisplayName("搜索")]
private string? Search { get; set; } = "Performance";

private int Page { get; set; } = 3;

private async Task ApplyZoom()
{
Zoom = Zoom switch
{
EnumZoomMode.Auto => EnumZoomMode.PageActual,
EnumZoomMode.PageActual => EnumZoomMode.PageFit,
EnumZoomMode.PageFit => EnumZoomMode.PageWidth,
EnumZoomMode.PageWidth => EnumZoomMode.PageHeight,
EnumZoomMode.PageHeight => EnumZoomMode.Zoom75,
EnumZoomMode.Zoom75 => EnumZoomMode.Zoom50,
EnumZoomMode.Zoom50 => EnumZoomMode.Zoom25,
EnumZoomMode.Zoom25 => EnumZoomMode.Zoom200,
_ => EnumZoomMode.Auto
};
await Refresh();
}

private async Task ApplyPageMode()
{
PageMode = PageMode switch
{
EnumPageMode.Thumbs => EnumPageMode.Outline,
EnumPageMode.Outline => EnumPageMode.Attachments,
EnumPageMode.Attachments => EnumPageMode.Layers,
EnumPageMode.Layers => EnumPageMode.None,
_ => EnumPageMode.Thumbs
};
await Refresh();
}

async Task Refresh()
{
if (AdvancedPdfReader != null)
await AdvancedPdfReader.Refresh(Search, Page, PageMode, Zoom, ReadOnly, Watermark);
}

private async Task ApplyPage()
{
Search = null;
await Refresh();
}

private async Task ApplyPagePrevious()
{
Page--;
Search = null;
await Refresh();
}

private async Task ApplyPageNext()
{
Page++;
Search = null;
await Refresh();
}

private Task ApplySearch() => Refresh();

private Task Clear()
{
Search = string.Empty;
StateHasChanged();
return Task.CompletedTask;
}

/// <summary>
/// GetAttributes
/// </summary>
/// <returns></returns>
protected AttributeItem[] GetAttributes() =>
[
new()
{
Name = "Filename",
Description = Localizer["AttributesPdfReaderFilename"],
Type = "string?",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "StreamMode",
Description = Localizer["AttributesPdfReaderStreamMode"],
Type = "bool",
ValueList = "-",
DefaultValue = "false"
},
new()
{
Name = "Width",
Description = Localizer["AttributesPdfReaderWidth"],
Type = "string",
ValueList = "-",
DefaultValue = "100%"
},
new()
{
Name = "Height",
Description = Localizer["AttributesPdfReaderHeight"],
Type = "string",
ValueList = "-",
DefaultValue = "700px"
},
new()
{
Name = "StyleString",
Description = Localizer["AttributesPdfReaderStyleString"],
Type = "string",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "Page",
Description = Localizer["AttributesPdfReaderPage"],
Type = "int",
ValueList = "-",
DefaultValue = "1"
},
new()
{
Name = "PageMode",
Description = Localizer["AttributesPdfReaderPageMode"],
Type = "EnumPageMode",
ValueList = "-",
DefaultValue = "Thumbs"
},
new()
{
Name = "Zoom",
Description = Localizer["AttributesPdfReaderZoom"],
Type = "EnumZoomMode",
ValueList = "-",
DefaultValue = "Auto"
},
new()
{
Name = "Search",
Description = Localizer["AttributesPdfReaderSearch"],
Type = "string?",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "Refresh()",
Description = Localizer["AttributesPdfReaderRefresh"],
Type = "Task",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "NavigateToPage(int page)",
Description = Localizer["AttributesPdfReaderNavigateToPage"],
Type = "Task",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "Refresh(int page)",
Description = Localizer["AttributesPdfReaderRefreshPage"],
Type = "Task",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "Refresh(string? search, int? page, EnumPageMode? pageMode, EnumZoomMode? zoom)",
Description = Localizer["AttributesPdfReaderRefreshComponent"],
Type = "Task",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "Stream",
Description = Localizer["AttributesPdfReaderStream"],
Type = "Stream?",
ValueList = "-",
DefaultValue = "-"
},
new()
{
Name = "ViewerBase",
Description = Localizer["AttributesPdfReaderViewerBase"],
Type = "string",
ValueList = "-",
DefaultValue = Localizer["AttributesPdfReaderViewerBaseDefaultValue"],
},
new()
{
Name = "NavPanels",
Description = Localizer["AttributesPdfReaderNavPanels"],
Type = "bool",
ValueList = "-",
DefaultValue = "true"
},
new()
{
Name = "Toolbar",
Description = Localizer["AttributesPdfReaderToolbar"],
Type = "bool",
ValueList = "-",
DefaultValue = "true"
},
new()
{
Name = "StatusBar",
Description = Localizer["AttributesPdfReaderStatusBar"],
Type = "bool",
ValueList = "-",
DefaultValue = "true"
},
new()
{
Name = "Debug",
Description = Localizer["AttributesPdfReaderDebug"],
Type = "bool",
ValueList = "-",
DefaultValue = "false"
},
new()
{
Name = nameof(PdfReader.LocalFileName),
Description = Localizer[nameof(PdfReader.LocalFileName)],
Type = "string",
ValueList = " — ",
DefaultValue = " — "
}
];
}
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,12 @@ void AddData(DemoMenuItem item)
Url = "pdf-reader"
},
new()
{
IsNew = true,
Text = Localizer["PdfViewer"],
Url = "pdf-viewer"
},
new()
{
Text = Localizer["Player"],
Url = "player"
Expand Down
7 changes: 7 additions & 0 deletions src/BootstrapBlazor.Server/Locales/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -4856,6 +4856,7 @@
"PulseButton": "PulseButton",
"Bluetooth": "IBluetooth",
"PdfReader": "PDF Reader",
"PdfViewer": "PDF Viewer",
"VideoPlayer": "VideoPlayer",
"FileViewer": "FileViewer",
"FlipClock": "FlipClock",
Expand Down Expand Up @@ -6156,6 +6157,12 @@
"PdfReaderCompatibilityModeTips": "- Chrome < 97 automatically uses version 2.4.456<br/>- Chrome < 109 automatically uses version 2.6.347<br/>- Note: ReadOnly and Watermark cannot be used in these two compatibility modes",
"LocalFileName": "local PDF file path"
},
"BootstrapBlazor.Server.Components.Samples.PdfViewers": {
"PdfViewerTitle": "PDFViewer",
"PdfViewerDescription": "Open the PDF file in the component to read its contents",
"PdfViewerNormalTitle": "Basic usage",
"PdfViewerNormalIntro": "Load a PDF file by setting the <code>Url</code> parameter"
},
"BootstrapBlazor.Server.Components.Samples.VideoPlayers": {
"VideoPlayersTitle": "VideoPlayer",
"VideoPlayersNormalTitle": "Basic usage",
Expand Down
7 changes: 7 additions & 0 deletions src/BootstrapBlazor.Server/Locales/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -4856,6 +4856,7 @@
"PulseButton": "心跳按钮 PulseButton",
"Bluetooth": "蓝牙服务 IBluetoothService",
"PdfReader": "PDF阅读器 PDF Reader",
"PdfViewer": "PDF阅读器 PDF Viewer",
"VideoPlayer": "视频播放器 VideoPlayer",
"FileViewer": "文件预览器 FileViewer",
"FlipClock": "卡片翻转时钟 FlipClock",
Expand Down Expand Up @@ -6156,6 +6157,12 @@
"PdfReaderCompatibilityModeTips": "- Chrome < 97 自动使用 2.4.456 版本<br/>- Chrome < 109 自动使用 2.6.347 版本<br/>- 注:ReadOnly 和 Watermark 在这两种兼容模式下不能使用",
"LocalFileName": "PDF本地文件路径"
},
"BootstrapBlazor.Server.Components.Samples.PdfViewers": {
"PdfViewerTitle": "PDFViewer PDF 阅读器",
"PdfViewerDescription": "在组件中打开 Pdf 文件阅读其内容",
"PdfViewerNormalTitle": "基础用法",
"PdfViewerNormalIntro": "通过设置 <code>Url</code> 参数加载 Pdf 文件"
},
"BootstrapBlazor.Server.Components.Samples.VideoPlayers": {
"VideoPlayersTitle": "VideoPlayer 视频播放器",
"VideoPlayersNormalTitle": "基础用法",
Expand Down
1 change: 1 addition & 0 deletions src/BootstrapBlazor.Server/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@
"onscreen-keyboard": "OnScreenKeyboards",
"pagination": "Paginations",
"pdf-reader": "PdfReaders",
"pdf-viewer": "PdfViewers",
"pop-confirm": "PopoverConfirms",
"popover": "Popovers",
"progress": "Progress",
Expand Down
Binary file not shown.