Skip to content

Commit

Permalink
Merge pull request #82 from SyncfusionExamples/EJ2-912651-MauiAndroidApp
Browse files Browse the repository at this point in the history
912651: updated index.razor
  • Loading branch information
KameshRajendran authored Nov 22, 2024
2 parents 9baa398 + 810a777 commit d037f0b
Showing 1 changed file with 17 additions and 3 deletions.
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();
}
}

0 comments on commit d037f0b

Please sign in to comment.