Skip to content

Commit

Permalink
Update WebConverter
Browse files Browse the repository at this point in the history
  • Loading branch information
sungaila committed Feb 27, 2024
1 parent a48b5c6 commit 8c8b742
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/PDFtoImage/PDFtoImage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
<!-- Blazor WebAssembly stuff -->
<ItemGroup Condition="'$(TargetFramework)'=='net7.0' or '$(TargetFramework)'=='net8.0'">
<PackageReference Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.7" PrivateAssets="analyzers" />
<PackageReference Include="Sungaila.PDFium.BlazorWebAssembly" Version="123.0.6295" PrivateAssets="analyzers" />
<PackageReference Include="Sungaila.PDFium.BlazorWebAssembly" Version="124.0.6322" PrivateAssets="analyzers" />
</ItemGroup>

<Import Project="PDFtoImage.PropertiesSigning.targets" />
Expand Down
4 changes: 2 additions & 2 deletions src/WebConverter/Models/RenderRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public class RenderRequest : IDisposable

[Required]
[Range(float.MinValue, float.MaxValue)]
public float BoundsWidth { get; set; } = 100f;
public float BoundsWidth { get; set; } = 1000f;

[Required]
[Range(float.MinValue, float.MaxValue)]
public float BoundsHeight { get; set; } = 100f;
public float BoundsHeight { get; set; } = 1000f;

public static string GetRotationLocalized(PdfRotation rotation) => rotation switch
{
Expand Down
8 changes: 4 additions & 4 deletions src/WebConverter/Pages/Index.razor
Original file line number Diff line number Diff line change
Expand Up @@ -192,24 +192,24 @@
<div class="form-group row mb-1">
<label for="boundsX" class="col-sm-3 col-form-label label-nowrap">X</label>
<div class="col-sm">
<InputNumber @bind-Value="Model.BoundsX" id="boundsX" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="1" disabled="@(!Model.UseBounds)" />
<InputNumber @bind-Value="Model.BoundsX" id="boundsX" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="0.000001" disabled="@(!Model.UseBounds)" />
</div>

<label for="boundsY" class="col-sm-3 col-form-label label-nowrap">Y</label>
<div class="col-sm">
<InputNumber @bind-Value="Model.BoundsY" id="boundsY" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="1" disabled="@(!Model.UseBounds)" />
<InputNumber @bind-Value="Model.BoundsY" id="boundsY" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="0.000001" disabled="@(!Model.UseBounds)" />
</div>
</div>

<div class="form-group row">
<label for="boundsWidth" class="col-sm-3 col-form-label label-nowrap">Width</label>
<div class="col-sm">
<InputNumber @bind-Value="Model.BoundsWidth" id="boundsWidth" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="1" disabled="@(!Model.UseBounds)" />
<InputNumber @bind-Value="Model.BoundsWidth" id="boundsWidth" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="0.000001" disabled="@(!Model.UseBounds)" />
</div>

<label for="boundsHeight" class="col-sm-3 col-form-label label-nowrap">Height</label>
<div class="col-sm">
<InputNumber @bind-Value="Model.BoundsHeight" id="boundsHeight" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="1" disabled="@(!Model.UseBounds)" />
<InputNumber @bind-Value="Model.BoundsHeight" id="boundsHeight" class="form-control form-control-sm" min="@float.MinValue" max="@float.MaxValue" step="0.000001" disabled="@(!Model.UseBounds)" />
</div>
</div>
</div>
Expand Down
7 changes: 7 additions & 0 deletions src/WebConverter/Pages/Index.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ private async Task Submit()

await Task.Factory.StartNew(() =>
{
if (!Model.UseBounds)
{
var pageSize = PDFtoImage.Conversion.GetPageSize(Model.Input, true, Model.Page, !string.IsNullOrEmpty(Model.Password) ? Model.Password : null);
Model.BoundsWidth = pageSize.Width;
Model.BoundsHeight = pageSize.Height;
}
bitmap = PDFtoImage.Conversion.ToImage(
Model.Input,
leaveOpen: true,
Expand Down

0 comments on commit 8c8b742

Please sign in to comment.