PDF
查看组件使用js
创建,配置参考pdfobject.js
@inherits BaseComponent
<KPdfView @ref="pdf" Id="pdfView1" />
@code {
private KPdfView pdf;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
await base.OnAfterRenderAsync(firstRender);
if (firstRender)
{
//使用流
var bytes = await File.ReadAllBytesAsync(@"D:\test.pdf");
var stream = new MemoryStream(bytes);
await pdf?.ShowAsync(stream);
//使用文件路径
await pdf?.ShowAsync(@"D:\test.pdf");
//使用URL
await pdf?.ShowAsync("/files/test.pdf");
}
}
}