Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.0.1-beta01</Version>
</PropertyGroup>

<PropertyGroup>
<PackageTags>Bootstrap Blazor WebAssembly wasm UI Components Pdf Reader</PackageTags>
<Description>Bootstrap UI components extensions of PdfReader</Description>
Expand All @@ -14,6 +18,7 @@

<ItemGroup>
<ProjectReference Include="..\..\..\..\BootstrapBlazor\src\BootstrapBlazor\BootstrapBlazor.csproj" />
<!--<PackageReference Include="BootstrapBlazor" Version="$(BBVersion)" />-->
Comment thread
ArgoZhang marked this conversation as resolved.
</ItemGroup>

<ItemGroup>
Expand Down
3 changes: 2 additions & 1 deletion src/components/BootstrapBlazor.PdfReader/PdfReader.razor
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<div class="bb-view-divider"></div>
<div class="bb-view-icon bb-view-fit-page" @onclick="FitToPage"><i class="fa-solid fa-arrows-left-right-to-line"></i></div>
<div class="bb-view-icon bb-view-fit-width" @onclick="FitToWidth"><i class="fa-solid fa-arrows-left-right"></i></div>
<div class="bb-view-icon bb-view-fit-rotate"><i class="fa-solid fa-rotate-left"></i></div>
<div class="bb-view-icon bb-view-fit-rotate" @onclick="RotateLeft"><i class="fa-solid fa-rotate-left"></i></div>
<div class="bb-view-icon bb-view-fit-rotate" @onclick="RotateRight"><i class="fa-solid fa-rotate-right"></i></div>
<div class="bb-view-divider"></div>
<div class="bb-view-icon bb-view-draw"><i class="fa-solid fa-pen-to-square"></i></div>
</div>
Expand Down
20 changes: 18 additions & 2 deletions src/components/BootstrapBlazor.PdfReader/PdfReader.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,31 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
/// <summary>
/// 适应页面宽度
/// </summary>
/// <returns></returns>
public void FitToPage() => IsFitToPage = true;

/// <summary>
/// 适应文档宽度
/// </summary>
/// <returns></returns>
public void FitToWidth() => IsFitToPage = false;

/// <summary>
/// 旋转页面方法
/// </summary>
Comment thread
ArgoZhang marked this conversation as resolved.
/// <returns></returns>
public async Task RotateLeft()
{
await InvokeVoidAsync("rotate", Id, -90);
}

/// <summary>
/// 旋转页面方法
/// </summary>
Comment thread
ArgoZhang marked this conversation as resolved.
/// <returns></returns>
public async Task RotateRight()
{
await InvokeVoidAsync("rotate", Id, 90);
}

private Task TriggerFit(string methodName) => InvokeVoidAsync(methodName, Id);

/// <summary>
Expand Down
23 changes: 16 additions & 7 deletions src/components/BootstrapBlazor.PdfReader/PdfReader.razor.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ export function fitToPage(id) {
}
}

export function rotate(id, step) {
const pdfViewer = Data.get(id);
if (pdfViewer) {
let rotate = pdfViewer.pagesRotation || 360;
Comment thread
ArgoZhang marked this conversation as resolved.
rotate += step;
pdfViewer.pagesRotation = rotate % 360;
}
}

export function dispose(id) {
Data.get(id);
}
Expand Down Expand Up @@ -252,16 +261,16 @@ export async function print(invoke, elementId, url) {
1000);
}

export function rotate(invoke, elementId, rotation) {
const pdf = getPdf(elementId);
//export function rotate(invoke, elementId, rotation) {
// const pdf = getPdf(elementId);

if (pdf == null || Number.isNaN(rotation) || rotation % 90 !== 0)
return;
// if (pdf == null || Number.isNaN(rotation) || rotation % 90 !== 0)
// return;

pdf.rotation = rotation;
// pdf.rotation = rotation;

queueRenderPage(pdf, pdf.pageNum);
}
// queueRenderPage(pdf, pdf.pageNum);
//}

export function zoomInOut(invoke, elementId, scale) {
const pdf = getPdf(elementId);
Expand Down