Skip to content

Commit ca32778

Browse files
Merge pull request #469 from SyncfusionExamples/986459-Update-Blazor-Samples
986459 - Updated Blazor Server and WASM Samples to Run State
2 parents 314b5db + 7d063af commit ca32778

File tree

8 files changed

+259
-25
lines changed

8 files changed

+259
-25
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
@page "/DocIO"
2+
@using System.IO;
3+
@using Create_Word_document;
4+
@inject Create_Word_document.Data.WordService service
5+
@inject Microsoft.JSInterop.IJSRuntime JS
6+
7+
<h2>Syncfusion DocIO library (Essential DocIO)</h2>
8+
<p>Syncfusion DocIO library (Essential DocIO) is a Blazor DocIO library used to create, read, edit, and convert Word files in your applications without Microsoft Office dependencies.</p>
9+
<button class="btn btn-primary" @onclick="@CreateWord">Create Word</button>
10+
11+
12+
@code {
13+
MemoryStream documentStream;
14+
15+
/// <summary>
16+
/// Create and download the Word document
17+
/// </summary>
18+
protected async void CreateWord()
19+
{
20+
documentStream = service.CreateWord();
21+
await JS.SaveAs("Sample.docx", documentStream.ToArray());
22+
}
23+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@page "/docio"
2+
@using Convert_Word_Document_to_Image;
3+
@inject Convert_Word_Document_to_Image.Data.WordService service;
4+
@inject Microsoft.JSInterop.IJSRuntime JS;
5+
6+
<h2>Syncfusion DocIO library </h2>
7+
<p>Syncfusion DocIO library is a Blazor DocIO library used to create, read, edit, and convert Word files in your applications without Microsoft Office dependencies.</p>
8+
<button class="btn btn-primary" @onclick="@ConvertWordtoImage">Convert Word to Image</button>
9+
10+
11+
@code {
12+
MemoryStream documentStream;
13+
/// <summary>
14+
/// Convert Word to image and download the image file
15+
/// </summary>
16+
protected async void ConvertWordtoImage()
17+
{
18+
documentStream = service.ConvertWordtoImage();
19+
await JS.SaveAs("WordToImage.Jpeg", documentStream.ToArray());
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace Convert_Word_Document_to_Image.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
}
28+
29+
.top-row a:first-child {
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
@media (max-width: 640.98px) {
35+
.top-row:not(.auth) {
36+
display: none;
37+
}
38+
39+
.top-row.auth {
40+
justify-content: space-between;
41+
}
42+
43+
.top-row a, .top-row .btn-link {
44+
margin-left: 0;
45+
}
46+
}
47+
48+
@media (min-width: 641px) {
49+
.page {
50+
flex-direction: row;
51+
}
52+
53+
.sidebar {
54+
width: 250px;
55+
height: 100vh;
56+
position: sticky;
57+
top: 0;
58+
}
59+
60+
.top-row {
61+
position: sticky;
62+
top: 0;
63+
z-index: 1;
64+
}
65+
66+
.top-row, article {
67+
padding-left: 2rem !important;
68+
padding-right: 1.5rem !important;
69+
}
70+
}

Word-to-PDF-Conversion/Convert-Word-document-to-PDF/Blazor/Server-app/Convert-Word-Document-to-PDF/Pages/Convert-Word-Document-to-PDF.sln

Lines changed: 0 additions & 25 deletions
This file was deleted.
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@page "/docio"
2+
@using Convert_Word_Document_to_PDF;
3+
@inject Convert_Word_Document_to_PDF.Data.WordService service
4+
@inject Microsoft.JSInterop.IJSRuntime JS
5+
6+
<h2>Syncfusion DocIO library </h2>
7+
<p>Syncfusion DocIO library is a Blazor DocIO library used to create, read, edit, and convert Word files in your applications without Microsoft Office dependencies.</p>
8+
<button class="btn btn-primary" @onclick="@ConvertWordtoPDF">Convert Word to PDF</button>
9+
10+
11+
@code {
12+
MemoryStream documentStream;
13+
/// <summary>
14+
/// Convert Word to PDF and download the PDF document
15+
/// </summary>
16+
protected async void ConvertWordtoPDF()
17+
{
18+
documentStream = service.ConvertWordtoPDF();
19+
await JS.SaveAs("Sample.pdf", documentStream.ToArray());
20+
}
21+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.AspNetCore.Mvc.RazorPages;
3+
using System.Diagnostics;
4+
5+
namespace Convert_Word_Document_to_PDF.Pages
6+
{
7+
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
8+
[IgnoreAntiforgeryToken]
9+
public class ErrorModel : PageModel
10+
{
11+
public string? RequestId { get; set; }
12+
13+
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
14+
15+
private readonly ILogger<ErrorModel> _logger;
16+
17+
public ErrorModel(ILogger<ErrorModel> logger)
18+
{
19+
_logger = logger;
20+
}
21+
22+
public void OnGet()
23+
{
24+
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
.page {
2+
position: relative;
3+
display: flex;
4+
flex-direction: column;
5+
}
6+
7+
main {
8+
flex: 1;
9+
}
10+
11+
.sidebar {
12+
background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%);
13+
}
14+
15+
.top-row {
16+
background-color: #f7f7f7;
17+
border-bottom: 1px solid #d6d5d5;
18+
justify-content: flex-end;
19+
height: 3.5rem;
20+
display: flex;
21+
align-items: center;
22+
}
23+
24+
.top-row ::deep a, .top-row .btn-link {
25+
white-space: nowrap;
26+
margin-left: 1.5rem;
27+
}
28+
29+
.top-row a:first-child {
30+
overflow: hidden;
31+
text-overflow: ellipsis;
32+
}
33+
34+
@media (max-width: 640.98px) {
35+
.top-row:not(.auth) {
36+
display: none;
37+
}
38+
39+
.top-row.auth {
40+
justify-content: space-between;
41+
}
42+
43+
.top-row a, .top-row .btn-link {
44+
margin-left: 0;
45+
}
46+
}
47+
48+
@media (min-width: 641px) {
49+
.page {
50+
flex-direction: row;
51+
}
52+
53+
.sidebar {
54+
width: 250px;
55+
height: 100vh;
56+
position: sticky;
57+
top: 0;
58+
}
59+
60+
.top-row {
61+
position: sticky;
62+
top: 0;
63+
z-index: 1;
64+
}
65+
66+
.top-row, article {
67+
padding-left: 2rem !important;
68+
padding-right: 1.5rem !important;
69+
}
70+
}

0 commit comments

Comments
 (0)