PDF预览 (PdfView)

基于pdfobject.js实现。

概述

  • 基于pdfobject.js实现

代码演示

1.默认示例

using WebSite.Data;

namespace WebSite.Docus.View.PdfViews;

class PdfView1 : BaseComponent
{
    protected override void BuildRenderTree(RenderTreeBuilder builder)
    {
        var stream = FileService.GetPdfStream();
        builder.Component<PdfView>("pdfView")
               .Set(c => c.Style, "demo-pdf")
               .Set(c => c.Stream, stream)
               .Build();
    }
}

2.弹窗示例

using WebSite.Data;

namespace WebSite.Docus.View.PdfViews;

class PdfView2 : BaseComponent
{
    protected override void BuildRenderTree(RenderTreeBuilder builder)
    {
        builder.Button("显示PDF", Callback(OnShowPDF), StyleType.Primary);
    }

    private void OnShowPDF()
    {
        var stream = FileService.GetPdfStream();
        UI.ShowPdf("查看PDF", 600, 400, stream);
    }
}