-
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 #69 from SyncfusionExamples/897381_customfont
897381: Documentation for loading custom fonts in to PDFIUM in Blazor
- Loading branch information
Showing
32 changed files
with
1,273 additions
and
0 deletions.
There are no files selected for viewing
25 changes: 25 additions & 0 deletions
25
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts.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.34728.123 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LoadCustomFonts", "LoadCustomFonts\LoadCustomFonts.csproj", "{2FE22EC7-FF34-41A4-A63F-1ED0E6CBFF70}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{2FE22EC7-FF34-41A4-A63F-1ED0E6CBFF70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{2FE22EC7-FF34-41A4-A63F-1ED0E6CBFF70}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{2FE22EC7-FF34-41A4-A63F-1ED0E6CBFF70}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{2FE22EC7-FF34-41A4-A63F-1ED0E6CBFF70}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {9D9EB5B0-5BE6-4155-9CBE-83CC68E49B46} | ||
EndGlobalSection | ||
EndGlobal |
12 changes: 12 additions & 0 deletions
12
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/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> |
14 changes: 14 additions & 0 deletions
14
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/LoadCustomFonts.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,14 @@ | ||
<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="26.1.42" /> | ||
<PackageReference Include="Syncfusion.Blazor.Themes" Version="26.1.42" /> | ||
</ItemGroup> | ||
|
||
</Project> |
6 changes: 6 additions & 0 deletions
6
... Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/LoadCustomFonts.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> |
13 changes: 13 additions & 0 deletions
13
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/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,13 @@ | ||
@page "/" | ||
|
||
<SfPdfViewer2 DocumentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf" | ||
Height="100%" | ||
Width="100%" CustomFonts="@customFonts"> | ||
</SfPdfViewer2> | ||
|
||
|
||
@code { | ||
|
||
public List<string> customFonts = new List<string> { "wwwroot/SIMSUN.TTC", "wwwroot/SIMSUNB.TTF", "https://cdn.jsdelivr.net/npm/[email protected]/fonts/arial-geo-bold-webfont.ttf" }; | ||
|
||
} |
38 changes: 38 additions & 0 deletions
38
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Pages/_Host.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,38 @@ | ||
@page "/" | ||
@using Microsoft.AspNetCore.Components.Web | ||
@namespace LoadCustomFonts.Pages | ||
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<base href="~/" /> | ||
<link rel="stylesheet" href="css/bootstrap/bootstrap.min.css" /> | ||
<link href="css/site.css" rel="stylesheet" /> | ||
<link href="LoadCustomFonts.styles.css" rel="stylesheet" /> | ||
<link rel="icon" type="image/png" href="favicon.png"/> | ||
<!-- Syncfusion Blazor PDF Viewer (Next Gen) control's theme style sheet --> | ||
<link href="_content/Syncfusion.Blazor.Themes/bootstrap5.css" rel="stylesheet" /> | ||
<!-- Syncfusion Blazor PDF Viewer (Next Gen) control's scripts --> | ||
<script src="_content/Syncfusion.Blazor.SfPdfViewer/scripts/syncfusion-blazor-sfpdfviewer.min.js" type="text/javascript"></script> | ||
<component type="typeof(HeadOutlet)" render-mode="ServerPrerendered" /> | ||
</head> | ||
<body> | ||
<component type="typeof(App)" render-mode="ServerPrerendered" /> | ||
|
||
<div id="blazor-error-ui"> | ||
<environment include="Staging,Production"> | ||
An error has occurred. This application may no longer respond until reloaded. | ||
</environment> | ||
<environment include="Development"> | ||
An unhandled exception has occurred. See browser dev tools for details. | ||
</environment> | ||
<a href="" class="reload">Reload</a> | ||
<a class="dismiss">🗙</a> | ||
</div> | ||
|
||
<script src="_framework/blazor.server.js"></script> | ||
</body> | ||
</html> |
34 changes: 34 additions & 0 deletions
34
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Program.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,34 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Web; | ||
using Syncfusion.Blazor; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
// Add services to the container. | ||
builder.Services.AddRazorPages(); | ||
builder.Services.AddServerSideBlazor(); | ||
builder.Services.AddSignalR(o => { o.MaximumReceiveMessageSize = 102400000; }); | ||
|
||
// Add Syncfusion Blazor service to the container. | ||
builder.Services.AddSyncfusionBlazor(); | ||
|
||
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(); |
37 changes: 37 additions & 0 deletions
37
...ve/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Properties/launchSettings.json
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,37 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:6957", | ||
"sslPort": 44384 | ||
} | ||
}, | ||
"profiles": { | ||
"http": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "http://localhost:5044", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"https": { | ||
"commandName": "Project", | ||
"dotnetRunMessages": true, | ||
"launchBrowser": true, | ||
"applicationUrl": "https://localhost:7210;http://localhost:5044", | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
} | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
... and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Shared/MainLayout.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,19 @@ | ||
@inherits LayoutComponentBase | ||
|
||
<PageTitle>LoadCustomFonts</PageTitle> | ||
|
||
<div class="page"> | ||
<div class="sidebar"> | ||
<NavMenu /> | ||
</div> | ||
|
||
<main> | ||
<div class="top-row px-4"> | ||
<a href="https://docs.microsoft.com/aspnet/" target="_blank">About</a> | ||
</div> | ||
|
||
<article class="content px-4"> | ||
@Body | ||
</article> | ||
</main> | ||
</div> |
70 changes: 70 additions & 0 deletions
70
... Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Shared/MainLayout.razor.css
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,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; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
Load and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Shared/NavMenu.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,39 @@ | ||
<div class="top-row ps-3 navbar navbar-dark"> | ||
<div class="container-fluid"> | ||
<a class="navbar-brand" href="">LoadCustomFonts</a> | ||
<button title="Navigation menu" class="navbar-toggler" @onclick="ToggleNavMenu"> | ||
<span class="navbar-toggler-icon"></span> | ||
</button> | ||
</div> | ||
</div> | ||
|
||
<div class="@NavMenuCssClass nav-scrollable" @onclick="ToggleNavMenu"> | ||
<nav class="flex-column"> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="" Match="NavLinkMatch.All"> | ||
<span class="oi oi-home" aria-hidden="true"></span> Home | ||
</NavLink> | ||
</div> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="counter"> | ||
<span class="oi oi-plus" aria-hidden="true"></span> Counter | ||
</NavLink> | ||
</div> | ||
<div class="nav-item px-3"> | ||
<NavLink class="nav-link" href="fetchdata"> | ||
<span class="oi oi-list-rich" aria-hidden="true"></span> Fetch data | ||
</NavLink> | ||
</div> | ||
</nav> | ||
</div> | ||
|
||
@code { | ||
private bool collapseNavMenu = true; | ||
|
||
private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; | ||
|
||
private void ToggleNavMenu() | ||
{ | ||
collapseNavMenu = !collapseNavMenu; | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...and Save/Load CustomFonts pdfium/LoadCustomFonts/LoadCustomFonts/Shared/NavMenu.razor.css
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,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; | ||
} | ||
} |
Oops, something went wrong.