From 2bb7dda0587868fb30af9ccd16b71023718b47c2 Mon Sep 17 00:00:00 2001 From: SaravanaPriya31 Date: Tue, 9 Jan 2024 17:49:55 +0530 Subject: [PATCH 1/3] 865193-blazor --- .../PDFViewerSample.sln | 25 ++++++ .../PDFViewerSample/App.razor | 12 +++ .../PDFViewerSample/Data/WeatherForecast.cs | 13 +++ .../Data/WeatherForecastService.cs | 20 +++++ .../PDFViewerSample/PDFViewerSample.csproj | 15 ++++ .../PDFViewerSample/Pages/Counter.razor | 18 ++++ .../PDFViewerSample/Pages/Error.cshtml | 42 +++++++++ .../PDFViewerSample/Pages/Error.cshtml.cs | 27 ++++++ .../PDFViewerSample/Pages/FetchData.razor | 47 ++++++++++ .../PDFViewerSample/Pages/Index.razor | 81 ++++++++++++++++++ .../PDFViewerSample/Pages/_Host.cshtml | 38 ++++++++ .../PDFViewerSample/Program.cs | 36 ++++++++ .../Properties/launchSettings.json | 37 ++++++++ .../PDFViewerSample/Shared/MainLayout.razor | 19 ++++ .../Shared/MainLayout.razor.css | 70 +++++++++++++++ .../PDFViewerSample/Shared/NavMenu.razor | 39 +++++++++ .../PDFViewerSample/Shared/NavMenu.razor.css | 68 +++++++++++++++ .../PDFViewerSample/Shared/SurveyPrompt.razor | 16 ++++ .../PDFViewerSample/_Imports.razor | 12 +++ .../appsettings.Development.json | 9 ++ .../PDFViewerSample/appsettings.json | 9 ++ .../PDFViewerSample/wwwroot/favicon.png | Bin 0 -> 1148 bytes 22 files changed, 653 insertions(+) create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample.sln create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/App.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecast.cs create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecastService.cs create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/PDFViewerSample.csproj create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Counter.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml.cs create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/FetchData.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Index.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/_Host.cshtml create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Program.cs create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Properties/launchSettings.json create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor.css create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor.css create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/SurveyPrompt.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/_Imports.razor create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.Development.json create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.json create mode 100644 Open and Save for Blazor PDF Viewer/PDFViewerSample/wwwroot/favicon.png diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample.sln b/Open and Save for Blazor PDF Viewer/PDFViewerSample.sln new file mode 100644 index 0000000..0233f20 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34219.65 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFViewerSample", "PDFViewerSample\PDFViewerSample.csproj", "{BB29B753-23A1-4745-88AE-AC504A24E031}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {BB29B753-23A1-4745-88AE-AC504A24E031}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {BB29B753-23A1-4745-88AE-AC504A24E031}.Debug|Any CPU.Build.0 = Debug|Any CPU + {BB29B753-23A1-4745-88AE-AC504A24E031}.Release|Any CPU.ActiveCfg = Release|Any CPU + {BB29B753-23A1-4745-88AE-AC504A24E031}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {ABAD2D2C-DCA0-4842-A7B4-8AD6EDD097B6} + EndGlobalSection +EndGlobal diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/App.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/App.razor new file mode 100644 index 0000000..6fd3ed1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/App.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecast.cs b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecast.cs new file mode 100644 index 0000000..e676c4d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PDFViewerSample.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; } + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecastService.cs b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecastService.cs new file mode 100644 index 0000000..41a1070 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Data/WeatherForecastService.cs @@ -0,0 +1,20 @@ +namespace PDFViewerSample.Data +{ + public class WeatherForecastService + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + public Task 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()); + } + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/PDFViewerSample.csproj b/Open and Save for Blazor PDF Viewer/PDFViewerSample/PDFViewerSample.csproj new file mode 100644 index 0000000..87c3da9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/PDFViewerSample.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Counter.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Counter.razor new file mode 100644 index 0000000..ef23cb3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +

Counter

+ +

Current count: @currentCount

+ + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml new file mode 100644 index 0000000..39e9928 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model PDFViewerSample.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+
+
+ + + diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml.cs b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml.cs new file mode 100644 index 0000000..9b888f9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace PDFViewerSample.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 _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/FetchData.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/FetchData.razor new file mode 100644 index 0000000..f47eac3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/FetchData.razor @@ -0,0 +1,47 @@ +@page "/fetchdata" +@using PDFViewerSample.Data +@inject WeatherForecastService ForecastService + +Weather forecast + +

Weather forecast

+ +

This component demonstrates fetching data from a service.

+ +@if (forecasts == null) +{ +

Loading...

+} +else +{ + + + + + + + + + + + @foreach (var forecast in forecasts) + { + + + + + + + } + +
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
+} + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Index.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Index.razor new file mode 100644 index 0000000..bcbc392 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/Index.razor @@ -0,0 +1,81 @@ +@using Box.V2; +@using Box.V2.Auth; +@using Box.V2.Config; +@using Box.V2.Models; +@using Syncfusion.Blazor.PdfViewerServer; +@using Syncfusion.Blazor.Buttons + +@page "/" +Save file to google drive + + +@code { + + private SfPdfViewerServer viewer; + private string DocumentPath { get; set; } + + private readonly string accessToken = "Your Box Storage Access Token"; + private readonly string folderID = "Your Folder ID"; + private readonly string clientID = "Your Box Storage ClientID"; + private readonly string clientSecret = "Your Box Storage ClientSecret"; + private readonly string fileName = "File Name to be loaded into Syncfusion PDF Viewer"; + + protected override async Task OnInitializedAsync() + { + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + // Download the file from Box storage + var items = await client.FoldersManager.GetFolderItemsAsync(folderID, 1000, autoPaginate: true); + var files = items.Entries.Where(i => i.Type == "file"); + + // Filter the files based on the objectName + var matchingFile = files.FirstOrDefault(file => file.Name == fileName); + + if (matchingFile != null) + { + // Fetch the file from Box storage by its ID + using (var fileStream = await client.FilesManager.DownloadAsync(matchingFile.Id).ConfigureAwait(false)) + { + using (MemoryStream stream = new MemoryStream()) + { + await fileStream.CopyToAsync(stream).ConfigureAwait(false); + + // Reset the position to the beginning of the stream + stream.Position = 0; + DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(stream.ToArray()); + } + } + } + else + { + // Handle case where the file is not found + Console.WriteLine("File not found in the specified folder."); + } + } + + public async void OnClick(MouseEventArgs args) + { + byte[] data = await viewer.GetDocument(); + string result = Path.GetFileNameWithoutExtension(fileName); + string FileName = result + "_downloaded.pdf"; + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + var fileRequest = new BoxFileRequest + { + Name = FileName, + Parent = new BoxFolderRequest { Id = folderID }, + }; + + using (var stream = new MemoryStream(data)) + { + var boxFile = await client.FilesManager.UploadAsync(fileRequest, stream); + } + + } +} \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/_Host.cshtml b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/_Host.cshtml new file mode 100644 index 0000000..0be3440 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Pages/_Host.cshtml @@ -0,0 +1,38 @@ +@page "/" +@using Microsoft.AspNetCore.Components.Web +@namespace PDFViewerSample.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + + + + + + + + + + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Program.cs b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Program.cs new file mode 100644 index 0000000..4cb4434 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Program.cs @@ -0,0 +1,36 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; +using PDFViewerSample.Data; +using Syncfusion.Blazor; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; }); +// Add Syncfusion Blazor service to the container. +builder.Services.AddSyncfusionBlazor(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + + + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Properties/launchSettings.json b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Properties/launchSettings.json new file mode 100644 index 0000000..c9647fa --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:6297", + "sslPort": 44319 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5069", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7180;http://localhost:5069", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor new file mode 100644 index 0000000..5eda93d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor @@ -0,0 +1,19 @@ +@inherits LayoutComponentBase + +PDFViewerSample + +
+ + +
+
+ About +
+ +
+ @Body +
+
+
diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor.css b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor.css new file mode 100644 index 0000000..551e4b2 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/MainLayout.razor.css @@ -0,0 +1,70 @@ +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.top-row { + background-color: #f7f7f7; + border-bottom: 1px solid #d6d5d5; + justify-content: flex-end; + height: 3.5rem; + display: flex; + align-items: center; +} + + .top-row ::deep a, .top-row .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + } + + .top-row a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + +@media (max-width: 640.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row a, .top-row .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .top-row, article { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor new file mode 100644 index 0000000..7b06af0 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor @@ -0,0 +1,39 @@ + + + + +@code { + private bool collapseNavMenu = true; + + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor.css b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor.css new file mode 100644 index 0000000..604b7a1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/NavMenu.razor.css @@ -0,0 +1,68 @@ +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.nav-item { + font-size: 0.9rem; + padding-bottom: 0.5rem; +} + + .nav-item:first-of-type { + padding-top: 1rem; + } + + .nav-item:last-of-type { + padding-bottom: 1rem; + } + + .nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; + } + +.nav-item ::deep a.active { + background-color: rgba(255,255,255,0.25); + color: white; +} + +.nav-item ::deep a:hover { + background-color: rgba(255,255,255,0.1); + color: white; +} + +@media (min-width: 641px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } + + .nav-scrollable { + /* Allow sidebar to scroll for tall menus */ + height: calc(100vh - 3.5rem); + overflow-y: auto; + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/SurveyPrompt.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/SurveyPrompt.razor new file mode 100644 index 0000000..ec64baa --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/Shared/SurveyPrompt.razor @@ -0,0 +1,16 @@ +
+ + @Title + + + Please take our + brief survey + + and tell us what you think. +
+ +@code { + // Demonstrates how a parent component can supply parameters + [Parameter] + public string? Title { get; set; } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/_Imports.razor b/Open and Save for Blazor PDF Viewer/PDFViewerSample/_Imports.razor new file mode 100644 index 0000000..57b2642 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using PDFViewerSample +@using PDFViewerSample.Shared +@using Syncfusion.Blazor +@using Syncfusion.Blazor.PdfViewerServer \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.Development.json b/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.Development.json new file mode 100644 index 0000000..770d3e9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.json b/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer/PDFViewerSample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Open and Save for Blazor PDF Viewer/PDFViewerSample/wwwroot/favicon.png b/Open and Save for Blazor PDF Viewer/PDFViewerSample/wwwroot/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8422b59695935d180d11d5dbe99653e711097819 GIT binary patch literal 1148 zcmV-?1cUpDP)9h26h2-Cs%i*@Moc3?#6qJID|D#|3|2Hn7gTIYEkr|%Xjp);YgvFmB&0#2E2b=| zkVr)lMv9=KqwN&%obTp-$<51T%rx*NCwceh-E+=&e(oLO`@Z~7gybJ#U|^tB2Pai} zRN@5%1qsZ1e@R(XC8n~)nU1S0QdzEYlWPdUpH{wJ2Pd4V8kI3BM=)sG^IkUXF2-j{ zrPTYA6sxpQ`Q1c6mtar~gG~#;lt=s^6_OccmRd>o{*=>)KS=lM zZ!)iG|8G0-9s3VLm`bsa6e ze*TlRxAjXtm^F8V`M1%s5d@tYS>&+_ga#xKGb|!oUBx3uc@mj1%=MaH4GR0tPBG_& z9OZE;->dO@`Q)nr<%dHAsEZRKl zedN6+3+uGHejJp;Q==pskSAcRcyh@6mjm2z-uG;s%dM-u0*u##7OxI7wwyCGpS?4U zBFAr(%GBv5j$jS@@t@iI8?ZqE36I^4t+P^J9D^ELbS5KMtZ z{Qn#JnSd$15nJ$ggkF%I4yUQC+BjDF^}AtB7w348EL>7#sAsLWs}ndp8^DsAcOIL9 zTOO!!0!k2`9BLk25)NeZp7ev>I1Mn={cWI3Yhx2Q#DnAo4IphoV~R^c0x&nw*MoIV zPthX?{6{u}sMS(MxD*dmd5rU(YazQE59b|TsB5Tm)I4a!VaN@HYOR)DwH1U5y(E)z zQqQU*B%MwtRQ$%x&;1p%ANmc|PkoFJZ%<-uq%PX&C!c-7ypis=eP+FCeuv+B@h#{4 zGx1m0PjS~FJt}3mdt4c!lel`1;4W|03kcZRG+DzkTy|7-F~eDsV2Tx!73dM0H0CTh zl)F-YUkE1zEzEW(;JXc|KR5{ox%YTh{$%F$a36JP6Nb<0%#NbSh$dMYF-{ z1_x(Vx)}fs?5_|!5xBTWiiIQHG<%)*e=45Fhjw_tlnmlixq;mUdC$R8v#j( zhQ$9YR-o%i5Uc`S?6EC51!bTRK=Xkyb<18FkCKnS2;o*qlij1YA@-nRpq#OMTX&RbL<^2q@0qja!uIvI;j$6>~k@IMwD42=8$$!+R^@5o6HX(*n~ Date: Tue, 9 Jan 2024 18:30:25 +0530 Subject: [PATCH 2/3] new gen commit --- .../PDFViewerSample.sln | 25 ++++++ .../PDFViewerSample/App.razor | 12 +++ .../PDFViewerSample/Data/WeatherForecast.cs | 13 +++ .../Data/WeatherForecastService.cs | 20 +++++ .../PDFViewerSample/PDFViewerSample.csproj | 15 ++++ .../PDFViewerSample/Pages/Counter.razor | 18 ++++ .../PDFViewerSample/Pages/Error.cshtml | 42 +++++++++ .../PDFViewerSample/Pages/Error.cshtml.cs | 27 ++++++ .../PDFViewerSample/Pages/FetchData.razor | 47 ++++++++++ .../PDFViewerSample/Pages/Index.razor | 83 ++++++++++++++++++ .../PDFViewerSample/Pages/_Host.cshtml | 38 ++++++++ .../PDFViewerSample/Program.cs | 34 +++++++ .../Properties/launchSettings.json | 37 ++++++++ .../PDFViewerSample/Shared/MainLayout.razor | 19 ++++ .../Shared/MainLayout.razor.css | 70 +++++++++++++++ .../PDFViewerSample/Shared/NavMenu.razor | 39 ++++++++ .../PDFViewerSample/Shared/NavMenu.razor.css | 68 ++++++++++++++ .../PDFViewerSample/Shared/SurveyPrompt.razor | 16 ++++ .../PDFViewerSample/_Imports.razor | 12 +++ .../appsettings.Development.json | 9 ++ .../PDFViewerSample/appsettings.json | 9 ++ .../PDFViewerSample/wwwroot/favicon.png | Bin 0 -> 1148 bytes 22 files changed, 653 insertions(+) create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln new file mode 100644 index 0000000..0566411 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34219.65 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFViewerSample", "PDFViewerSample\PDFViewerSample.csproj", "{122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58F1D4B3-EEB0-4A76-AC65-81120F954551} + EndGlobalSection +EndGlobal diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor new file mode 100644 index 0000000..6fd3ed1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs new file mode 100644 index 0000000..e676c4d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PDFViewerSample.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; } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs new file mode 100644 index 0000000..41a1070 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs @@ -0,0 +1,20 @@ +namespace PDFViewerSample.Data +{ + public class WeatherForecastService + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + public Task 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()); + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj new file mode 100644 index 0000000..29e4e3f --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor new file mode 100644 index 0000000..ef23cb3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +

Counter

+ +

Current count: @currentCount

+ + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml new file mode 100644 index 0000000..39e9928 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model PDFViewerSample.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+
+
+ + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs new file mode 100644 index 0000000..9b888f9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace PDFViewerSample.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 _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor new file mode 100644 index 0000000..f47eac3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor @@ -0,0 +1,47 @@ +@page "/fetchdata" +@using PDFViewerSample.Data +@inject WeatherForecastService ForecastService + +Weather forecast + +

Weather forecast

+ +

This component demonstrates fetching data from a service.

+ +@if (forecasts == null) +{ +

Loading...

+} +else +{ + + + + + + + + + + + @foreach (var forecast in forecasts) + { + + + + + + + } + +
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
+} + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor new file mode 100644 index 0000000..61a895c --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor @@ -0,0 +1,83 @@ +@using Box.V2; +@using Box.V2.Auth; +@using Box.V2.Config; +@using Box.V2.Models; +@using Syncfusion.Blazor.SfPdfViewer; +@using Syncfusion.Blazor.Buttons + +@page "/" +Save file to Box storage + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath { get; set; } + private readonly string accessToken = "Your Box Storage Access Token"; + private readonly string folderID = "Your Folder ID"; + private readonly string clientID = "Your Box Storage ClientID"; + private readonly string clientSecret = "Your Box Storage ClientSecret"; + private readonly string fileName = "File Name to be loaded into Syncfusion PDF Viewer"; + + protected override async Task OnInitializedAsync() + { + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + // Download the file from Box storage + var items = await client.FoldersManager.GetFolderItemsAsync(folderID, 1000, autoPaginate: true); + var files = items.Entries.Where(i => i.Type == "file"); + + // Filter the files based on the objectName + var matchingFile = files.FirstOrDefault(file => file.Name == fileName); + + if (matchingFile != null) + { + // Fetch the file from Box storage by its ID + using (var fileStream = await client.FilesManager.DownloadAsync(matchingFile.Id).ConfigureAwait(false)) + { + using (MemoryStream stream = new MemoryStream()) + { + await fileStream.CopyToAsync(stream).ConfigureAwait(false); + + // Reset the position to the beginning of the stream + stream.Position = 0; + DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(stream.ToArray()); + } + } + } + else + { + // Handle case where the file is not found + Console.WriteLine("File not found in the specified folder."); + } + } + + public async void OnClick(MouseEventArgs args) + { + byte[] data = await viewer.GetDocumentAsync(); + string result = Path.GetFileNameWithoutExtension(fileName); + string FileName = result + "_downloaded.pdf"; + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + var fileRequest = new BoxFileRequest + { + Name = FileName, + Parent = new BoxFolderRequest { Id = folderID }, + }; + + using (var stream = new MemoryStream(data)) + { + var boxFile = await client.FilesManager.UploadAsync(fileRequest, stream); + } + + } +} \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml new file mode 100644 index 0000000..fd788a7 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml @@ -0,0 +1,38 @@ +@page "/" +@using Microsoft.AspNetCore.Components.Web +@namespace PDFViewerSample.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + + + + + + + + + + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs new file mode 100644 index 0000000..04f9dd4 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; +using PDFViewerSample.Data; +using Syncfusion.Blazor; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; }); +// Add Syncfusion Blazor service to the container. +builder.Services.AddSyncfusionBlazor(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json new file mode 100644 index 0000000..feed45c --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:51985", + "sslPort": 44327 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5263", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7024;http://localhost:5263", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor new file mode 100644 index 0000000..5eda93d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor @@ -0,0 +1,19 @@ +@inherits LayoutComponentBase + +PDFViewerSample + +
+ + +
+
+ About +
+ +
+ @Body +
+
+
diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css new file mode 100644 index 0000000..551e4b2 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css @@ -0,0 +1,70 @@ +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.top-row { + background-color: #f7f7f7; + border-bottom: 1px solid #d6d5d5; + justify-content: flex-end; + height: 3.5rem; + display: flex; + align-items: center; +} + + .top-row ::deep a, .top-row .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + } + + .top-row a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + +@media (max-width: 640.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row a, .top-row .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .top-row, article { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor new file mode 100644 index 0000000..7b06af0 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor @@ -0,0 +1,39 @@ + + + + +@code { + private bool collapseNavMenu = true; + + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css new file mode 100644 index 0000000..604b7a1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css @@ -0,0 +1,68 @@ +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.nav-item { + font-size: 0.9rem; + padding-bottom: 0.5rem; +} + + .nav-item:first-of-type { + padding-top: 1rem; + } + + .nav-item:last-of-type { + padding-bottom: 1rem; + } + + .nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; + } + +.nav-item ::deep a.active { + background-color: rgba(255,255,255,0.25); + color: white; +} + +.nav-item ::deep a:hover { + background-color: rgba(255,255,255,0.1); + color: white; +} + +@media (min-width: 641px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } + + .nav-scrollable { + /* Allow sidebar to scroll for tall menus */ + height: calc(100vh - 3.5rem); + overflow-y: auto; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor new file mode 100644 index 0000000..ec64baa --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor @@ -0,0 +1,16 @@ +
+ + @Title + + + Please take our + brief survey + + and tell us what you think. +
+ +@code { + // Demonstrates how a parent component can supply parameters + [Parameter] + public string? Title { get; set; } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor new file mode 100644 index 0000000..443f30d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using PDFViewerSample +@using PDFViewerSample.Shared +@using Syncfusion.Blazor; +@using Syncfusion.Blazor.SfPdfViewer; \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json new file mode 100644 index 0000000..770d3e9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8422b59695935d180d11d5dbe99653e711097819 GIT binary patch literal 1148 zcmV-?1cUpDP)9h26h2-Cs%i*@Moc3?#6qJID|D#|3|2Hn7gTIYEkr|%Xjp);YgvFmB&0#2E2b=| zkVr)lMv9=KqwN&%obTp-$<51T%rx*NCwceh-E+=&e(oLO`@Z~7gybJ#U|^tB2Pai} zRN@5%1qsZ1e@R(XC8n~)nU1S0QdzEYlWPdUpH{wJ2Pd4V8kI3BM=)sG^IkUXF2-j{ zrPTYA6sxpQ`Q1c6mtar~gG~#;lt=s^6_OccmRd>o{*=>)KS=lM zZ!)iG|8G0-9s3VLm`bsa6e ze*TlRxAjXtm^F8V`M1%s5d@tYS>&+_ga#xKGb|!oUBx3uc@mj1%=MaH4GR0tPBG_& z9OZE;->dO@`Q)nr<%dHAsEZRKl zedN6+3+uGHejJp;Q==pskSAcRcyh@6mjm2z-uG;s%dM-u0*u##7OxI7wwyCGpS?4U zBFAr(%GBv5j$jS@@t@iI8?ZqE36I^4t+P^J9D^ELbS5KMtZ z{Qn#JnSd$15nJ$ggkF%I4yUQC+BjDF^}AtB7w348EL>7#sAsLWs}ndp8^DsAcOIL9 zTOO!!0!k2`9BLk25)NeZp7ev>I1Mn={cWI3Yhx2Q#DnAo4IphoV~R^c0x&nw*MoIV zPthX?{6{u}sMS(MxD*dmd5rU(YazQE59b|TsB5Tm)I4a!VaN@HYOR)DwH1U5y(E)z zQqQU*B%MwtRQ$%x&;1p%ANmc|PkoFJZ%<-uq%PX&C!c-7ypis=eP+FCeuv+B@h#{4 zGx1m0PjS~FJt}3mdt4c!lel`1;4W|03kcZRG+DzkTy|7-F~eDsV2Tx!73dM0H0CTh zl)F-YUkE1zEzEW(;JXc|KR5{ox%YTh{$%F$a36JP6Nb<0%#NbSh$dMYF-{ z1_x(Vx)}fs?5_|!5xBTWiiIQHG<%)*e=45Fhjw_tlnmlixq;mUdC$R8v#j( zhQ$9YR-o%i5Uc`S?6EC51!bTRK=Xkyb<18FkCKnS2;o*qlij1YA@-nRpq#OMTX&RbL<^2q@0qja!uIvI;j$6>~k@IMwD42=8$$!+R^@5o6HX(*n~ Date: Tue, 9 Jan 2024 18:32:23 +0530 Subject: [PATCH 3/3] new gen commit --- .../PDFViewerSample.sln | 25 ++++++ .../PDFViewerSample/App.razor | 12 +++ .../PDFViewerSample/Data/WeatherForecast.cs | 13 +++ .../Data/WeatherForecastService.cs | 20 +++++ .../PDFViewerSample/PDFViewerSample.csproj | 15 ++++ .../PDFViewerSample/Pages/Counter.razor | 18 ++++ .../PDFViewerSample/Pages/Error.cshtml | 42 +++++++++ .../PDFViewerSample/Pages/Error.cshtml.cs | 27 ++++++ .../PDFViewerSample/Pages/FetchData.razor | 47 ++++++++++ .../PDFViewerSample/Pages/Index.razor | 83 ++++++++++++++++++ .../PDFViewerSample/Pages/_Host.cshtml | 38 ++++++++ .../PDFViewerSample/Program.cs | 34 +++++++ .../Properties/launchSettings.json | 37 ++++++++ .../PDFViewerSample/Shared/MainLayout.razor | 19 ++++ .../Shared/MainLayout.razor.css | 70 +++++++++++++++ .../PDFViewerSample/Shared/NavMenu.razor | 39 ++++++++ .../PDFViewerSample/Shared/NavMenu.razor.css | 68 ++++++++++++++ .../PDFViewerSample/Shared/SurveyPrompt.razor | 16 ++++ .../PDFViewerSample/_Imports.razor | 12 +++ .../appsettings.Development.json | 9 ++ .../PDFViewerSample/appsettings.json | 9 ++ .../PDFViewerSample/wwwroot/favicon.png | Bin 0 -> 1148 bytes 22 files changed, 653 insertions(+) create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json create mode 100644 Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln new file mode 100644 index 0000000..0566411 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34219.65 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PDFViewerSample", "PDFViewerSample\PDFViewerSample.csproj", "{122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Debug|Any CPU.Build.0 = Debug|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Release|Any CPU.ActiveCfg = Release|Any CPU + {122086AC-F5C1-4E02-A2F7-9FD64A0C9C38}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {58F1D4B3-EEB0-4A76-AC65-81120F954551} + EndGlobalSection +EndGlobal diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor new file mode 100644 index 0000000..6fd3ed1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/App.razor @@ -0,0 +1,12 @@ + + + + + + + Not found + +

Sorry, there's nothing at this address.

+
+
+
diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs new file mode 100644 index 0000000..e676c4d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecast.cs @@ -0,0 +1,13 @@ +namespace PDFViewerSample.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; } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs new file mode 100644 index 0000000..41a1070 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Data/WeatherForecastService.cs @@ -0,0 +1,20 @@ +namespace PDFViewerSample.Data +{ + public class WeatherForecastService + { + private static readonly string[] Summaries = new[] + { + "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" + }; + + public Task 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()); + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj new file mode 100644 index 0000000..29e4e3f --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/PDFViewerSample.csproj @@ -0,0 +1,15 @@ + + + + net7.0 + enable + enable + + + + + + + + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor new file mode 100644 index 0000000..ef23cb3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Counter.razor @@ -0,0 +1,18 @@ +@page "/counter" + +Counter + +

Counter

+ +

Current count: @currentCount

+ + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml new file mode 100644 index 0000000..39e9928 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml @@ -0,0 +1,42 @@ +@page +@model PDFViewerSample.Pages.ErrorModel + + + + + + + + Error + + + + + +
+
+

Error.

+

An error occurred while processing your request.

+ + @if (Model.ShowRequestId) + { +

+ Request ID: @Model.RequestId +

+ } + +

Development Mode

+

+ Swapping to the Development environment displays detailed information about the error that occurred. +

+

+ The Development environment shouldn't be enabled for deployed applications. + It can result in displaying sensitive information from exceptions to end users. + For local debugging, enable the Development environment by setting the ASPNETCORE_ENVIRONMENT environment variable to Development + and restarting the app. +

+
+
+ + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs new file mode 100644 index 0000000..9b888f9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Error.cshtml.cs @@ -0,0 +1,27 @@ +using Microsoft.AspNetCore.Mvc; +using Microsoft.AspNetCore.Mvc.RazorPages; +using System.Diagnostics; + +namespace PDFViewerSample.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 _logger; + + public ErrorModel(ILogger logger) + { + _logger = logger; + } + + public void OnGet() + { + RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier; + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor new file mode 100644 index 0000000..f47eac3 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/FetchData.razor @@ -0,0 +1,47 @@ +@page "/fetchdata" +@using PDFViewerSample.Data +@inject WeatherForecastService ForecastService + +Weather forecast + +

Weather forecast

+ +

This component demonstrates fetching data from a service.

+ +@if (forecasts == null) +{ +

Loading...

+} +else +{ + + + + + + + + + + + @foreach (var forecast in forecasts) + { + + + + + + + } + +
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
+} + +@code { + private WeatherForecast[]? forecasts; + + protected override async Task OnInitializedAsync() + { + forecasts = await ForecastService.GetForecastAsync(DateOnly.FromDateTime(DateTime.Now)); + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor new file mode 100644 index 0000000..61a895c --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/Index.razor @@ -0,0 +1,83 @@ +@using Box.V2; +@using Box.V2.Auth; +@using Box.V2.Config; +@using Box.V2.Models; +@using Syncfusion.Blazor.SfPdfViewer; +@using Syncfusion.Blazor.Buttons + +@page "/" +Save file to Box storage + + + +@code { + private SfPdfViewer2 viewer; + private string DocumentPath { get; set; } + private readonly string accessToken = "Your Box Storage Access Token"; + private readonly string folderID = "Your Folder ID"; + private readonly string clientID = "Your Box Storage ClientID"; + private readonly string clientSecret = "Your Box Storage ClientSecret"; + private readonly string fileName = "File Name to be loaded into Syncfusion PDF Viewer"; + + protected override async Task OnInitializedAsync() + { + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + // Download the file from Box storage + var items = await client.FoldersManager.GetFolderItemsAsync(folderID, 1000, autoPaginate: true); + var files = items.Entries.Where(i => i.Type == "file"); + + // Filter the files based on the objectName + var matchingFile = files.FirstOrDefault(file => file.Name == fileName); + + if (matchingFile != null) + { + // Fetch the file from Box storage by its ID + using (var fileStream = await client.FilesManager.DownloadAsync(matchingFile.Id).ConfigureAwait(false)) + { + using (MemoryStream stream = new MemoryStream()) + { + await fileStream.CopyToAsync(stream).ConfigureAwait(false); + + // Reset the position to the beginning of the stream + stream.Position = 0; + DocumentPath = "data:application/pdf;base64," + Convert.ToBase64String(stream.ToArray()); + } + } + } + else + { + // Handle case where the file is not found + Console.WriteLine("File not found in the specified folder."); + } + } + + public async void OnClick(MouseEventArgs args) + { + byte[] data = await viewer.GetDocumentAsync(); + string result = Path.GetFileNameWithoutExtension(fileName); + string FileName = result + "_downloaded.pdf"; + // Initialize the Box API client with your authentication credentials + var auth = new OAuthSession(accessToken, "YOUR_REFRESH_TOKEN", 3600, "bearer"); + var config = new BoxConfigBuilder(clientID, clientSecret, new Uri("http://boxsdk")).Build(); + var client = new BoxClient(config, auth); + + var fileRequest = new BoxFileRequest + { + Name = FileName, + Parent = new BoxFolderRequest { Id = folderID }, + }; + + using (var stream = new MemoryStream(data)) + { + var boxFile = await client.FilesManager.UploadAsync(fileRequest, stream); + } + + } +} \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml new file mode 100644 index 0000000..fd788a7 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Pages/_Host.cshtml @@ -0,0 +1,38 @@ +@page "/" +@using Microsoft.AspNetCore.Components.Web +@namespace PDFViewerSample.Pages +@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers + + + + + + + + + + + + + + + + + + + + +
+ + An error has occurred. This application may no longer respond until reloaded. + + + An unhandled exception has occurred. See browser dev tools for details. + + Reload + 🗙 +
+ + + + diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs new file mode 100644 index 0000000..04f9dd4 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Program.cs @@ -0,0 +1,34 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.AspNetCore.Components.Web; +using PDFViewerSample.Data; +using Syncfusion.Blazor; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. +builder.Services.AddRazorPages(); +builder.Services.AddServerSideBlazor().AddHubOptions(o => { o.MaximumReceiveMessageSize = 102400000; }); +// Add Syncfusion Blazor service to the container. +builder.Services.AddSyncfusionBlazor(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (!app.Environment.IsDevelopment()) +{ + app.UseExceptionHandler("/Error"); + // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. + app.UseHsts(); +} + +app.UseHttpsRedirection(); + +app.UseStaticFiles(); + +app.UseRouting(); + +app.MapBlazorHub(); +app.MapFallbackToPage("/_Host"); + +app.Run(); \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json new file mode 100644 index 0000000..feed45c --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Properties/launchSettings.json @@ -0,0 +1,37 @@ +{ + "iisSettings": { + "windowsAuthentication": false, + "anonymousAuthentication": true, + "iisExpress": { + "applicationUrl": "http://localhost:51985", + "sslPort": 44327 + } + }, + "profiles": { + "http": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "http://localhost:5263", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "https": { + "commandName": "Project", + "dotnetRunMessages": true, + "launchBrowser": true, + "applicationUrl": "https://localhost:7024;http://localhost:5263", + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + }, + "IIS Express": { + "commandName": "IISExpress", + "launchBrowser": true, + "environmentVariables": { + "ASPNETCORE_ENVIRONMENT": "Development" + } + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor new file mode 100644 index 0000000..5eda93d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor @@ -0,0 +1,19 @@ +@inherits LayoutComponentBase + +PDFViewerSample + +
+ + +
+
+ About +
+ +
+ @Body +
+
+
diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css new file mode 100644 index 0000000..551e4b2 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/MainLayout.razor.css @@ -0,0 +1,70 @@ +.page { + position: relative; + display: flex; + flex-direction: column; +} + +main { + flex: 1; +} + +.sidebar { + background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); +} + +.top-row { + background-color: #f7f7f7; + border-bottom: 1px solid #d6d5d5; + justify-content: flex-end; + height: 3.5rem; + display: flex; + align-items: center; +} + + .top-row ::deep a, .top-row .btn-link { + white-space: nowrap; + margin-left: 1.5rem; + } + + .top-row a:first-child { + overflow: hidden; + text-overflow: ellipsis; + } + +@media (max-width: 640.98px) { + .top-row:not(.auth) { + display: none; + } + + .top-row.auth { + justify-content: space-between; + } + + .top-row a, .top-row .btn-link { + margin-left: 0; + } +} + +@media (min-width: 641px) { + .page { + flex-direction: row; + } + + .sidebar { + width: 250px; + height: 100vh; + position: sticky; + top: 0; + } + + .top-row { + position: sticky; + top: 0; + z-index: 1; + } + + .top-row, article { + padding-left: 2rem !important; + padding-right: 1.5rem !important; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor new file mode 100644 index 0000000..7b06af0 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor @@ -0,0 +1,39 @@ + + + + +@code { + private bool collapseNavMenu = true; + + private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; + + private void ToggleNavMenu() + { + collapseNavMenu = !collapseNavMenu; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css new file mode 100644 index 0000000..604b7a1 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/NavMenu.razor.css @@ -0,0 +1,68 @@ +.navbar-toggler { + background-color: rgba(255, 255, 255, 0.1); +} + +.top-row { + height: 3.5rem; + background-color: rgba(0,0,0,0.4); +} + +.navbar-brand { + font-size: 1.1rem; +} + +.oi { + width: 2rem; + font-size: 1.1rem; + vertical-align: text-top; + top: -2px; +} + +.nav-item { + font-size: 0.9rem; + padding-bottom: 0.5rem; +} + + .nav-item:first-of-type { + padding-top: 1rem; + } + + .nav-item:last-of-type { + padding-bottom: 1rem; + } + + .nav-item ::deep a { + color: #d7d7d7; + border-radius: 4px; + height: 3rem; + display: flex; + align-items: center; + line-height: 3rem; + } + +.nav-item ::deep a.active { + background-color: rgba(255,255,255,0.25); + color: white; +} + +.nav-item ::deep a:hover { + background-color: rgba(255,255,255,0.1); + color: white; +} + +@media (min-width: 641px) { + .navbar-toggler { + display: none; + } + + .collapse { + /* Never collapse the sidebar for wide screens */ + display: block; + } + + .nav-scrollable { + /* Allow sidebar to scroll for tall menus */ + height: calc(100vh - 3.5rem); + overflow-y: auto; + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor new file mode 100644 index 0000000..ec64baa --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/Shared/SurveyPrompt.razor @@ -0,0 +1,16 @@ +
+ + @Title + + + Please take our + brief survey + + and tell us what you think. +
+ +@code { + // Demonstrates how a parent component can supply parameters + [Parameter] + public string? Title { get; set; } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor new file mode 100644 index 0000000..443f30d --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/_Imports.razor @@ -0,0 +1,12 @@ +@using System.Net.Http +@using Microsoft.AspNetCore.Authorization +@using Microsoft.AspNetCore.Components.Authorization +@using Microsoft.AspNetCore.Components.Forms +@using Microsoft.AspNetCore.Components.Routing +@using Microsoft.AspNetCore.Components.Web +@using Microsoft.AspNetCore.Components.Web.Virtualization +@using Microsoft.JSInterop +@using PDFViewerSample +@using PDFViewerSample.Shared +@using Syncfusion.Blazor; +@using Syncfusion.Blazor.SfPdfViewer; \ No newline at end of file diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json new file mode 100644 index 0000000..770d3e9 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.Development.json @@ -0,0 +1,9 @@ +{ + "DetailedErrors": true, + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + } +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json new file mode 100644 index 0000000..10f68b8 --- /dev/null +++ b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Information", + "Microsoft.AspNetCore": "Warning" + } + }, + "AllowedHosts": "*" +} diff --git a/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png b/Open and Save for Blazor PDF Viewer(next gen)/PDFViewerSample/wwwroot/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..8422b59695935d180d11d5dbe99653e711097819 GIT binary patch literal 1148 zcmV-?1cUpDP)9h26h2-Cs%i*@Moc3?#6qJID|D#|3|2Hn7gTIYEkr|%Xjp);YgvFmB&0#2E2b=| zkVr)lMv9=KqwN&%obTp-$<51T%rx*NCwceh-E+=&e(oLO`@Z~7gybJ#U|^tB2Pai} zRN@5%1qsZ1e@R(XC8n~)nU1S0QdzEYlWPdUpH{wJ2Pd4V8kI3BM=)sG^IkUXF2-j{ zrPTYA6sxpQ`Q1c6mtar~gG~#;lt=s^6_OccmRd>o{*=>)KS=lM zZ!)iG|8G0-9s3VLm`bsa6e ze*TlRxAjXtm^F8V`M1%s5d@tYS>&+_ga#xKGb|!oUBx3uc@mj1%=MaH4GR0tPBG_& z9OZE;->dO@`Q)nr<%dHAsEZRKl zedN6+3+uGHejJp;Q==pskSAcRcyh@6mjm2z-uG;s%dM-u0*u##7OxI7wwyCGpS?4U zBFAr(%GBv5j$jS@@t@iI8?ZqE36I^4t+P^J9D^ELbS5KMtZ z{Qn#JnSd$15nJ$ggkF%I4yUQC+BjDF^}AtB7w348EL>7#sAsLWs}ndp8^DsAcOIL9 zTOO!!0!k2`9BLk25)NeZp7ev>I1Mn={cWI3Yhx2Q#DnAo4IphoV~R^c0x&nw*MoIV zPthX?{6{u}sMS(MxD*dmd5rU(YazQE59b|TsB5Tm)I4a!VaN@HYOR)DwH1U5y(E)z zQqQU*B%MwtRQ$%x&;1p%ANmc|PkoFJZ%<-uq%PX&C!c-7ypis=eP+FCeuv+B@h#{4 zGx1m0PjS~FJt}3mdt4c!lel`1;4W|03kcZRG+DzkTy|7-F~eDsV2Tx!73dM0H0CTh zl)F-YUkE1zEzEW(;JXc|KR5{ox%YTh{$%F$a36JP6Nb<0%#NbSh$dMYF-{ z1_x(Vx)}fs?5_|!5xBTWiiIQHG<%)*e=45Fhjw_tlnmlixq;mUdC$R8v#j( zhQ$9YR-o%i5Uc`S?6EC51!bTRK=Xkyb<18FkCKnS2;o*qlij1YA@-nRpq#OMTX&RbL<^2q@0qja!uIvI;j$6>~k@IMwD42=8$$!+R^@5o6HX(*n~