Bozza modifiche x ospitare PdfViewer
This commit is contained in:
@@ -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>
|
||||
|
||||
@@ -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>
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user