Skip to content

Commit d037f0b

Browse files
Merge pull request #82 from SyncfusionExamples/EJ2-912651-MauiAndroidApp
912651: updated index.razor
2 parents 9baa398 + 810a777 commit d037f0b

File tree

1 file changed

+17
-3
lines changed
  • Server Deployment/Maui/MauiBlazorAndroid/MauiBlazorAndroid/Pages

1 file changed

+17
-3
lines changed
Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,25 @@
11
@page "/"
2-
@using System.Web;
3-
42

53
<SfPdfViewer2 @ref="viewer" DocumentPath="@DocumentPath" Height="100%" Width="100%"></SfPdfViewer2>
64

75
@code {
86
SfPdfViewer2 viewer;
9-
private string DocumentPath { get; set; } = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf";
7+
private string DocumentPath { get; set; } = "";
108

9+
protected override void OnInitialized()
10+
{
11+
string basePath = "MauiBlazorAndroid.wwwroot.data.pdf_succinctly.pdf";
12+
Stream DocumentStream = this.GetType().Assembly.GetManifestResourceStream(basePath);
13+
DocumentStream.Position = 0;
14+
using (MemoryStream memoryStream = new MemoryStream())
15+
{
16+
DocumentStream.CopyTo(memoryStream);
17+
byte[] bytes = memoryStream.ToArray();
18+
string base64String = Convert.ToBase64String(bytes);
19+
string base64prefix = "data:application/pdf;base64,";
20+
//Assigned the base64 path to the PDF document path.
21+
DocumentPath = $"{base64prefix}{base64String}";
22+
}
23+
base.OnInitialized();
24+
}
1125
}

0 commit comments

Comments
 (0)