-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #58 from SyncfusionExamples/871336_SfPdfViewer
871336 sf pdf viewer
- Loading branch information
Showing
149 changed files
with
6,029 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
...stom Toolbar/Primary Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change.sln
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.9.34526.213 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Icon-Style-Change", "Icon-Style-Change\Icon-Style-Change.csproj", "{E0450A89-6646-4BE9-B216-16CDD6E19123}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{E0450A89-6646-4BE9-B216-16CDD6E19123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{E0450A89-6646-4BE9-B216-16CDD6E19123}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{E0450A89-6646-4BE9-B216-16CDD6E19123}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{E0450A89-6646-4BE9-B216-16CDD6E19123}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {8D287B08-68EB-402E-A95E-AB59527F1EF9} | ||
EndGlobalSection | ||
EndGlobal |
12 changes: 12 additions & 0 deletions
12
...oolbar/Primary Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/App.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Router AppAssembly="@typeof(App).Assembly"> | ||
<Found Context="routeData"> | ||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> | ||
<FocusOnNavigate RouteData="@routeData" Selector="h1" /> | ||
</Found> | ||
<NotFound> | ||
<PageTitle>Not found</PageTitle> | ||
<LayoutView Layout="@typeof(MainLayout)"> | ||
<p role="alert">Sorry, there's nothing at this address.</p> | ||
</LayoutView> | ||
</NotFound> | ||
</Router> |
13 changes: 13 additions & 0 deletions
13
... Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Data/WeatherForecast.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
namespace Icon_Style_Change.Data | ||
{ | ||
public class WeatherForecast | ||
{ | ||
public DateOnly Date { get; set; } | ||
|
||
public int TemperatureC { get; set; } | ||
|
||
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); | ||
|
||
public string? Summary { get; set; } | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
... Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Data/WeatherForecastService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Icon_Style_Change.Data | ||
{ | ||
public class WeatherForecastService | ||
{ | ||
private static readonly string[] Summaries = new[] | ||
{ | ||
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" | ||
}; | ||
|
||
public Task<WeatherForecast[]> GetForecastAsync(DateOnly startDate) | ||
{ | ||
return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast | ||
{ | ||
Date = startDate.AddDays(index), | ||
TemperatureC = Random.Shared.Next(-20, 55), | ||
Summary = Summaries[Random.Shared.Next(Summaries.Length)] | ||
}).ToArray()); | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
...Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Icon-Style-Change.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Syncfusion.Blazor.SfPdfViewer" Version="*" /> | ||
<PackageReference Include="Syncfusion.Blazor.Themes" Version="*" /> | ||
</ItemGroup> | ||
</Project> |
6 changes: 6 additions & 0 deletions
6
...m Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Icon-Style-Change.csproj.user
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<PropertyGroup> | ||
<ActiveDebugProfile>https</ActiveDebugProfile> | ||
</PropertyGroup> | ||
</Project> |
18 changes: 18 additions & 0 deletions
18
...mary Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Pages/Counter.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
@page "/counter" | ||
|
||
<PageTitle>Counter</PageTitle> | ||
|
||
<h1>Counter</h1> | ||
|
||
<p role="status">Current count: @currentCount</p> | ||
|
||
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button> | ||
|
||
@code { | ||
private int currentCount = 0; | ||
|
||
private void IncrementCount() | ||
{ | ||
currentCount++; | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...imary Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Pages/Error.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
@page | ||
@model Icon_Style_Change.Pages.ErrorModel | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" /> | ||
<title>Error</title> | ||
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" /> | ||
<link href="~/css/site.css" rel="stylesheet" asp-append-version="true" /> | ||
</head> | ||
|
||
<body> | ||
<div class="main"> | ||
<div class="content px-4"> | ||
<h1 class="text-danger">Error.</h1> | ||
<h2 class="text-danger">An error occurred while processing your request.</h2> | ||
|
||
@if (Model.ShowRequestId) | ||
{ | ||
<p> | ||
<strong>Request ID:</strong> <code>@Model.RequestId</code> | ||
</p> | ||
} | ||
|
||
<h3>Development Mode</h3> | ||
<p> | ||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred. | ||
</p> | ||
<p> | ||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong> | ||
It can result in displaying sensitive information from exceptions to end users. | ||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong> | ||
and restarting the app. | ||
</p> | ||
</div> | ||
</div> | ||
</body> | ||
|
||
</html> |
27 changes: 27 additions & 0 deletions
27
...ry Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Pages/Error.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using Microsoft.AspNetCore.Mvc.RazorPages; | ||
using System.Diagnostics; | ||
|
||
namespace Icon_Style_Change.Pages | ||
{ | ||
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)] | ||
[IgnoreAntiforgeryToken] | ||
public class ErrorModel : PageModel | ||
{ | ||
public string? RequestId { get; set; } | ||
|
||
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId); | ||
|
||
private readonly ILogger<ErrorModel> _logger; | ||
|
||
public ErrorModel(ILogger<ErrorModel> logger) | ||
{ | ||
_logger = logger; | ||
} | ||
|
||
public void OnGet() | ||
{ | ||
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; | ||
} | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
...ry Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Pages/FetchData.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
@page "/fetchdata" | ||
@using Icon_Style_Change.Data | ||
@inject WeatherForecastService ForecastService | ||
|
||
<PageTitle>Weather forecast</PageTitle> | ||
|
||
<h1>Weather forecast</h1> | ||
|
||
<p>This component demonstrates fetching data from a service.</p> | ||
|
||
@if (forecasts == null) | ||
{ | ||
<p><em>Loading...</em></p> | ||
} | ||
else | ||
{ | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>Date</th> | ||
<th>Temp. (C)</th> | ||
<th>Temp. (F)</th> | ||
<th>Summary</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
@foreach (var forecast in forecasts) | ||
{ | ||
<tr> | ||
<td>@forecast.Date.ToShortDateString()</td> | ||
<td>@forecast.TemperatureC</td> | ||
<td>@forecast.TemperatureF</td> | ||
<td>@forecast.Summary</td> | ||
</tr> | ||
} | ||
</tbody> | ||
</table> | ||
} | ||
|
||
@code { | ||
private WeatherForecast[]? forecasts; | ||
|
||
protected override async Task OnInitializedAsync() | ||
{ | ||
forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); | ||
} | ||
} |
117 changes: 117 additions & 0 deletions
117
...rimary Custom Toolbar - SfPdfViewer/Icon-Style-Change/Icon-Style-Change/Pages/Index.razor
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
@page "/" | ||
|
||
@using Syncfusion.Blazor.SfPdfViewer; | ||
@using Syncfusion.Blazor.Navigations; | ||
|
||
<SfPdfViewer2 @ref="@Viewer" DocumentPath="@DocumentPath" Height="100%" Width="100%"> | ||
<PdfViewerToolbarSettings CustomToolbarItems="@CustomToolbarItems" ToolbarItems="@ToolbarItems" /> | ||
<PdfViewerEvents ToolbarClicked="ClickAction"></PdfViewerEvents> | ||
</SfPdfViewer2> | ||
|
||
@code{ | ||
private string DocumentPath { get; set; } = "wwwroot/Data/PDF_Succinctly.pdf"; | ||
SfPdfViewer2 Viewer; | ||
MemoryStream stream; | ||
|
||
// List provide the position and element for the custom toolbar items | ||
public List<PdfToolbarItem> CustomToolbarItems = new List<PdfToolbarItem>() | ||
{ | ||
new PdfToolbarItem (){ Index = 1, Template = @GetTemplate("PreviousPage")}, | ||
new PdfToolbarItem (){ Index = 2, Template = @GetTemplate("NextPage")}, | ||
new PdfToolbarItem (){ Index = 4, Template = @GetTemplate("Save")}, | ||
new PdfToolbarItem (){ Index = 7, Template = @GetTemplate("Download")} | ||
}; | ||
|
||
// Get the renderfragment element for the custom toolbaritems in the primary toolbar | ||
private static RenderFragment GetTemplate(string name) | ||
{ | ||
return __builder => | ||
{ | ||
if (name == "PreviousPage") | ||
{ | ||
<ToolbarItem PrefixIcon="e-icons e-chevron-up" | ||
Text="Previous Page" | ||
TooltipText="Previous Page" | ||
Id="previousPage" | ||
Align="ItemAlign.Left"> | ||
</ToolbarItem> | ||
} | ||
else if(name == "NextPage") | ||
{ | ||
<ToolbarItem PrefixIcon="e-icons e-chevron-down" | ||
Text="Next Page" | ||
TooltipText="Next Page" | ||
Id="nextPage" | ||
Align="ItemAlign.Left"> | ||
</ToolbarItem> | ||
} | ||
else if(name == "Save") | ||
{ | ||
<ToolbarItem PrefixIcon="e-icons e-save" | ||
Text="Save" | ||
TooltipText="Save Document" | ||
Id="save" | ||
Align="ItemAlign.Right"> | ||
</ToolbarItem> | ||
} | ||
else if(name == "Download") | ||
{ | ||
<ToolbarItem PrefixIcon="e-icons e-download" | ||
Text="Download" | ||
TooltipText="Download" | ||
Id="download" | ||
Align="ItemAlign.Right"> | ||
</ToolbarItem> | ||
} | ||
}; | ||
} | ||
|
||
// Click for the custom toolbaritems in the primary toolbar | ||
public async void ClickAction(ClickEventArgs Item) | ||
{ | ||
if (Item.Item.Id == "previousPage") | ||
{ | ||
await Viewer.GoToPreviousPageAsync(); | ||
} | ||
else if (Item.Item.Id == "nextPage") | ||
{ | ||
await Viewer.GoToNextPageAsync(); | ||
} | ||
else if(Item.Item.Id == "save") | ||
{ | ||
byte[] data = await Viewer.GetDocumentAsync(); | ||
stream = new MemoryStream(data); | ||
await Viewer.LoadAsync(stream); | ||
} | ||
else if (Item.Item.Id == "download") | ||
{ | ||
await Viewer.DownloadAsync(); | ||
} | ||
} | ||
|
||
// Default toolbar items list provided for the toolbaritems | ||
public List<Syncfusion.Blazor.SfPdfViewer.ToolbarItem> ToolbarItems = new List<Syncfusion.Blazor.SfPdfViewer.ToolbarItem>() | ||
{ | ||
Syncfusion.Blazor.SfPdfViewer.ToolbarItem.OpenOption, | ||
Syncfusion.Blazor.SfPdfViewer.ToolbarItem.SelectionTool, | ||
Syncfusion.Blazor.SfPdfViewer.ToolbarItem.SearchOption, | ||
Syncfusion.Blazor.SfPdfViewer.ToolbarItem.PrintOption | ||
}; | ||
} | ||
<style> | ||
.e-icons.e-chevron-up::before { | ||
content: '\e87a'; | ||
} | ||
.e-icons.e-chevron-down::before { | ||
content: '\e70d'; | ||
} | ||
.e-icons.e-download::before { | ||
content: '\e7a0'; | ||
} | ||
.e-icons.e-save::before { | ||
content: '\e7a8' | ||
} | ||
</style> |
Oops, something went wrong.