面向ASP的Telerik UI。网络核心免费下载30天试用版

剃须刀页面

本文演示了如何为ASP配置Telerik UI PDFViewer。. NET Core在RazorPage场景中。

有关RazorPages示例的完整项目,请访问我们的GitHub库

PDFjs处理

下面的例子演示了如何在RazorPage项目中使用PDF.JS

@page @model Telerik.Examples.RazorPages.Pages.PDFViewer.PDFViewerIndexModel   @inject Microsoft.AspNetCore.Antiforgery.IAntiforgery Xsrf @ html . antiforgerytoken () 

PDFViewerPDFJSProcessing

@(Html.Kendo().PDFViewer() .Name("pdfviewer") .PdfjsProcessing(pdf => pdf. file (Url.Content("~/sample.pdf"))))) .Height(1200)))
  < / kendo-pdfviewer >
public class PDFViewerIndexModel: PageModel {public void OnGet() {}}

DPL处理

控件来初始化PDFViewer,下面的示例演示了如何使用远程文档处理库

@page @model telerik . example . razorpages . pages . pdfviewerdplmodel @inject microsoft.aspnetcore . antiforgery.iantiforforgery Xsrf @ html . antiforgerytoken () 

PDFViewerDPLProcessing

@(Html.Kendo().PDFViewer() .Name("pdfviewer") .DplProcessing(dpl => {dpl.Read(r=> r.l l("/ pdfviewer /PDFViewerDPL?handler=Read"));}))
 < pdl -processing>  
public类PDFViewerDPLModel: PageModel {private IHostingEnvironment _hostingEnvironment;public PDFViewerDPLModel(IHostingEnvironment) {_hostingEnvironment = environment;}公共无效OnGet(){}公共IActionResult OnGetRead(int?pageNumber){字符串filePath = Path.Combine(_hostingEnvironment.;)WebRootPath sample.pdf);FileStream stream = new FileStream(filePath, FileMode。开放、FileAccess.Read);JsonResult JsonResult;FixedDocument文档= FixedDocument. load(流);if (pageNumber == null) {jsonResult = new jsonResult (doc.ToJson());} else {jsonResult = new jsonResult (doc.GetPage((int)pageNumber));}返回jsonResult; } }

另请参阅

在本文中
Baidu
map