Test display pdf...

This commit is contained in:
Samuele Locatelli
2024-02-22 18:48:53 +01:00
parent 472fe4e0f2
commit 4e533bff80
4 changed files with 75 additions and 36 deletions
@@ -16,32 +16,12 @@
<option value="File04.pdf">File 04</option>
<option value="File05.pdf">File 05</option>
</select>
<span class="input-group-text">Height</span>
<select class="form-select" @bind="@HeightSel">
<option value="200px">200</option>
<option value="400px">400</option>
<option value="600px">600</option>
<option value="800px">800</option>
<option value="1000px">1000</option>
</select>
@* <span class="input-group-text">Compo</span>
<select class="form-select" @bind="@CompoSel">
<option value="1">PdfDisplay</option>
<option value="2">PdfViewer</option>
</select> *@
</div>
</div>
</div>
</div>
<div class="card-body">
<PdfDisplay Width="100%" Height="@HeightSel" PdfUrl="@($"test/{FileSel}")"></PdfDisplay>
@* @if (CompoSel == 1)
{
}
else
{
<PdfDisplay Width="100%" Height="@HeightSel" PdfUrl="@($"test/{FileSel}")"></PdfDisplay>
} *@
<div class="card-body py-1">
<PdfDisplay Width="100%" PdfUrl="@($"test/{FileSel}")" HeightList="@heightList"></PdfDisplay>
<p class="card-text">Selezione: <b>@FileSel</b></p>
</div>
</div>
@@ -74,6 +74,8 @@ namespace EgwCoreLib.BlazorTest.Pages
private string baseUri = "";
private string fileUrl = "";
private Dictionary<string, string> heightList { get; set; } = new Dictionary<string, string>() { { "200", "200px" }, { "400", "400px" }, { "600", "600px" }, { "800", "800px" }, { "1000", "1000px" } };
#endregion Private Properties
#region Private Methods
+19 -3
View File
@@ -1,10 +1,26 @@
@if (isMobile)
<div class="d-flex justify-content-between mb-1">
<div class="px-0">
<div class="input-group input-group-sm w-100">
<span class="input-group-text"><b>@(isMobile ? "Mobile" : "Desktop")</b></span>
</div>
</div>
<div class="px-0">
<div class="input-group input-group-sm w-100">
<span class="input-group-text">H</span>
<select class="form-select" @bind="@Height">
@foreach (var item in HeightList)
{
<option value="@item.Value">@item.Key</option>
}
</select>
</div>
</div>
</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" />
}
+52 -11
View File
@@ -9,6 +9,8 @@ namespace EgwCoreLib.Razor
{
public partial class PdfDisplay
{
#region Public Properties
/// <summary>
/// URL del documento da mostrare
/// </summary>
@@ -20,22 +22,39 @@ namespace EgwCoreLib.Razor
/// </summary>
[Parameter]
public string Width { get; set; } = "100%";
/// <summary>
/// Altezza desiderata
/// Elenco altezze ammesse
/// </summary>
[Parameter]
public string Height { get; set; } = "80%";
public Dictionary<string, string> HeightList
{
get => hList;
set
{
if (hList != value && value.Count > 0)
{
hList = value;
}
}
}
/// <summary>
/// Boolean Mobile vs Desktop
/// </summary>
private bool isMobile { get; set; }
[Inject]
[NotNull]
private IJSRuntime? JS { get; set; }
private Dictionary<string, string> hList { get; set; } = new Dictionary<string, string>() { { "200", "200px" }, { "400", "400px" }, { "600", "600px" } };
private IJSObjectReference? module;
protected override void OnInitialized()
{
// in base a quanti ne ho preso ultima o in mezzo...
int numSkip = HeightList.Count() > 3 ? 2 : 0;
Height = HeightList.Skip(numSkip).FirstOrDefault().Value;
}
#endregion Public Properties
#region Protected Methods
protected override async Task OnAfterRenderAsync(bool firstRender)
{
@@ -48,7 +67,29 @@ namespace EgwCoreLib.Razor
}
catch
{ }
}
#endregion Protected Methods
#region Private Fields
private IJSObjectReference? module;
#endregion Private Fields
#region Private Properties
private string Height { get; set; } = "600px";
/// <summary>
/// Boolean Mobile vs Desktop
/// </summary>
private bool isMobile { get; set; }
[Inject]
[NotNull]
private IJSRuntime? JS { get; set; }
#endregion Private Properties
}
}