-
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 #82 from SyncfusionExamples/EJ2-912651-MauiAndroidApp
912651: updated index.razor
- Loading branch information
Showing
1 changed file
with
17 additions
and
3 deletions.
There are no files selected for viewing
20 changes: 17 additions & 3 deletions
20
Server Deployment/Maui/MauiBlazorAndroid/MauiBlazorAndroid/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 |
---|---|---|
@@ -1,11 +1,25 @@ | ||
@page "/" | ||
@using System.Web; | ||
|
||
|
||
<SfPdfViewer2 @ref="viewer" DocumentPath="@DocumentPath" Height="100%" Width="100%"></SfPdfViewer2> | ||
|
||
@code { | ||
SfPdfViewer2 viewer; | ||
private string DocumentPath { get; set; } = "https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf"; | ||
private string DocumentPath { get; set; } = ""; | ||
|
||
protected override void OnInitialized() | ||
{ | ||
string basePath = "MauiBlazorAndroid.wwwroot.data.pdf_succinctly.pdf"; | ||
Stream DocumentStream = this.GetType().Assembly.GetManifestResourceStream(basePath); | ||
DocumentStream.Position = 0; | ||
using (MemoryStream memoryStream = new MemoryStream()) | ||
{ | ||
DocumentStream.CopyTo(memoryStream); | ||
byte[] bytes = memoryStream.ToArray(); | ||
string base64String = Convert.ToBase64String(bytes); | ||
string base64prefix = "data:application/pdf;base64,"; | ||
//Assigned the base64 path to the PDF document path. | ||
DocumentPath = $"{base64prefix}{base64String}"; | ||
} | ||
base.OnInitialized(); | ||
} | ||
} |