Files
egwcorelib/EgwCoreLib.Razor/PdfViewer.razor.cs
T
Samuele Locatelli d38d9687d5 Test display pdf
2024-02-22 11:38:51 +01:00

54 lines
1.4 KiB
C#

using Microsoft.AspNetCore.Components;
using Microsoft.Extensions.Options;
using Microsoft.JSInterop;
using System.Diagnostics.CodeAnalysis;
using System.Xml.Linq;
using ZXingBlazor.Components;
namespace EgwCoreLib.Razor
{
public partial class PdfViewer
{
/// <summary>
/// URL del documento da mostrare
/// </summary>
[Parameter]
public string PdfUrl { get; set; } = "";
/// <summary>
/// Larghezza desiderata
/// </summary>
[Parameter]
public string Width { get; set; } = "100%";
/// <summary>
/// Altezza desiderata
/// </summary>
[Parameter]
public string Height { get; set; } = "80%";
/// <summary>
/// Boolean Mobile vs Desktop
/// </summary>
private bool isMobile { get; set; }
[Inject]
[NotNull]
private IJSRuntime? JS { get; set; }
private IJSObjectReference? module;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
try
{
if (!firstRender) return;
module = await JS.InvokeAsync<IJSObjectReference>("import", "./_content/EgwCoreLib.Razor/PdfViewer.razor.js");
isMobile = await JS.InvokeAsync<bool>("isDevice");
}
catch
{ }
}
}
}