程序员开发实例大全宝库

网站首页 > 编程文章 正文

Blazor组件自做十二 : Blazor Pdf Reader PDF阅读器 组件

zazugpt 2024-11-08 14:58:55 编程文章 15 ℃ 0 评论

Blazor Pdf Reader PDF阅读器 组件

应小伙伴要求撸了一个简单的PDF阅读器组件

示例:

https://blazor.app1.es/pdfReaders

Tips:

Blazor 部署 pdf.js 不能正确显示中文资源解决办法

使用方法:

1.nuget包

BootstrapBlazor.PdfReader

2._Imports.razor 文件 或者页面添加 添加组件库引用

@using BootstrapBlazor.Components

3.razor页面

<PdfReader PdfFile="https://densen.es/test/webdev/pdf/sample.pdf" />
           
<PdfReader UrlBase="https://blazor.app1.es/"
           PdfFile="_content/DemoShared/sample.pdf" />

<PdfReader UrlBase="https://blazor.app1.es/"
           PdfFile="_content/DemoShared/sample.pdf" 
           EnableStreamingMode="true"/>

<pre>跨域最佳体验</pre>

<PdfReader UrlBase="https://blazor.app1.es/"
           PdfFile="_content/DemoShared/sample.pdf" 
           EnableStreamingMode="true"
           ForcePDFJS="true" />

4.参数说明

参数

说明

默认值

PdfStream

用于渲染的文件流,为空则用URL参数读取文件


PdfFile

PDF文件路径, https://xx.com/sample.pdf

null

Func<string, Task>? OnInfo

信息回调


Func<string, Task>? OnError

错误回调


EnableStreamingMode

使用流化模式,可跨域读取文件

false

UrlBase

PDF文件基础路径, (使用流化模式才需要设置), https://xx.com


Height

700

Page

指定页码,如果浏览器支持,将加载PDF并自动滚动到第n页

1

ForceIframe

强制使用 Iframe

false

ForcePDFJS

强制使用 PDF.js

false

PDFJS_URL

PDF.js 浏览器页面路径

内置

Search

*查询字符串


View

*视图模式

FitV

Pagemode

*页面模式

thumbs

*表示PDF.js 专有

优先嵌入模式,不支持则回落倒pdf.js模式

跨域最佳体验: EnableStreamingMode=true , ForcePDFJS=true

项目源码

Github:

densen2014/BootstrapBlazor.PdfReader


本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表