Bozza modifiche x ospitare PdfViewer

This commit is contained in:
Samuele Locatelli
2024-02-22 09:53:12 +01:00
parent f28a9efc48
commit bbf51a6270
4 changed files with 59 additions and 1 deletions
@@ -0,0 +1,5 @@
{
"version": 1,
"isRoot": true,
"tools": {}
}
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
@@ -11,6 +11,10 @@
<Content Remove="compilerconfig.json" />
</ItemGroup>
<ItemGroup>
<_WebToolingArtifacts Remove="Properties\PublishProfiles\IIS01.pubxml" />
</ItemGroup>
<ItemGroup>
<None Include="compilerconfig.json" />
</ItemGroup>
+12
View File
@@ -0,0 +1,12 @@
<div>
@if (isMobile)
{
<h3>Mobile</h3>
<iframe src="@PdfUrl" width="@Width" height="@Height" />
}
else
{
<h3>Desktop</h3>
<object type="application/pdf" data="@PdfUrl" width="@Width" height="@Height" />
}
</div>
+37
View File
@@ -0,0 +1,37 @@
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace EgwCoreLib.Razor
{
public partial class PdfViewer
{
/// <summary>
/// URL del documento da mostrare
/// </summary>
[Parameter]
public string PdfUrl { get; set; } = "";
/// <summary>
/// Larghezza desiderata
/// </summary>
public string Width { get; set; } = "100%";
/// <summary>
/// Altezza desiderata
/// </summary>
public string Height { get; set; } = "60%";
/// <summary>
/// Boolean Mobile vs Desktop
/// </summary>
private bool isMobile { get; set; }
[Inject]
protected IJSRuntime JSRuntime { get; set; } = null!;
protected override async Task OnAfterRenderAsync(bool firstRender)
{
isMobile = await JSRuntime.InvokeAsync<bool>("isDevice");
}
}
}