Skip to content

379783: UG Documentation on How to Open PDF From Base64 Data #3780

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions ej2-asp-core-mvc/pdfviewer/EJ2_ASP.MVC/open-pdf-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
---
layout: post
title: Open PDF files in EJ2 ASP.NET MVC PDF Viewer | Syncfusion
description: Learn here all about Opening PDF in ASP.NET MVC PDF Viewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: How to Open PDF From Base64
publishingplatform: ##Platform_Name##
documentation: ug
---

# Opening a PDF from Base64 data in PDF Viewer
### Overview

This guide demonstrates how to load a PDF document from a Base64 string into the Syncfusion PDF Viewer using ASP.NET MVC. This feature is useful for loading PDF data received from a client, database, or other sources where the document is encoded in Base64.

### Opening PDF from Base64 data

**Step 1:** Set Up the PdfViewer in Your ASP.NET MVC Project

Follow the steps provided in the [link](https://ej2.syncfusion.com/aspnetmvc/documentation/pdfviewer/getting-started) to create a simple PDF Viewer sample.

**Step 2:** Use the following code snippet to load PDF document using base64 string.


{% tabs %}
{% highlight html tabtitle="Standalone" %}

@using Syncfusion.EJ2
@{
ViewBag.Title = "Home Page";
}
<div>
<div style="height:500px;width:100%;">
<button type="button" onclick="LoadFromBase64()">:Load From Base64</button>
<!-- Render PDF Viewer using the Html helper method -->
@Html.EJS().PdfViewer("pdfViewer").DocumentPath("https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf").ResourceUrl("https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib").Render()
</div>
</div>

<script type="text/javascript">
//Load PDF document from base64 String
function LoadFromBase64() {
var viewer = document.getElementById('pdfViewer').ej2_instances[0];
//Enter Base64 Data
viewer.load('Enter Base64 Data',null);
}
</script>

{% endhighlight %}
{% endtabs %}

[View sample in GitHub](https://github.com/SyncfusionExamples/mvc-pdf-viewer-examples/tree/master/How%20to)
53 changes: 53 additions & 0 deletions ej2-asp-core-mvc/pdfviewer/EJ2_ASP.NETCORE/open-pdf-file.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
---
layout: post
title: Open PDF files in EJ2 ASP.NET CORE PDF Viewer | Syncfusion
description: Learn here all about Opening PDF in ASP.NET CORE PDF Viewer component of Syncfusion Essential JS 2 and more.
platform: ej2-asp-core-mvc
control: PDF Viewer
publishingplatform: ##Platform_Name##
documentation: ug
---

# Opening a PDF from Base64 data in PDF Viewer
### Overview

This guide demonstrates how to load a PDF document from a Base64 string into the Syncfusion PDF Viewer using ASP.NET CORE. This feature is useful for loading PDF data received from a client, database, or other sources where the document is encoded in Base64.

### Opening PDF from Base64 data

**Step 1:** Set Up the PdfViewer in Your ASP.NET CORE Project

Follow the steps provided in the [link](https://ej2.syncfusion.com/aspnetcore/documentation/pdfviewer/getting-started) to create a simple PDF Viewer sample.

**Step 2:** Use the following code snippet to load PDF document using base64 string.


{% tabs %}
{% highlight html tabtitle="Standalone" %}

@page "{handler?}"
@model IndexModel
@{
ViewData["Title"] = "Home page";
}

<div class="text-center">
<button type="button" id="loadButton">Load PDF from Base64</button>
<ejs-pdfviewer id="pdfviewer" style="height:600px" resourceUrl="https://cdn.syncfusion.com/ej2/28.1.33/dist/ej2-pdfviewer-lib" documentPath="https://cdn.syncfusion.com/content/pdf/pdf-succinctly.pdf">
</ejs-pdfviewer>
</div>

<script type="text/javascript">
document.getElementById('loadButton').addEventListener('click', function () {
var pdfViewer = document.getElementById('pdfviewer').ej2_instances[0];
//Enter the base 64 Data
var base64String = 'Enter Base64 Data';
// Load the PDF document using the load() method with Base64 string
pdfViewer.load(base64String, null); // Pass null for filename if not required
});
</script>

{% endhighlight %}
{% endtabs %}

[View sample in GitHub](https://github.com/SyncfusionExamples/asp-core-pdf-viewer-examples/tree/master/How%20to)
2 changes: 1 addition & 1 deletion ej2-asp-core-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1886,7 +1886,7 @@
</li>
<li><a href="/ej2-asp-core/pdfviewer/feature-module">Feature Modules</a></li>
<li>
Open PDF files
<a href="/ej2-asp-core/pdfviewer/open-pdf-file">Open PDF files</a>
<ul>
<li><a href="/ej2-asp-core/pdfviewer/open-pdf-file/from-azure-blob-storage">From Azure Blob Storage</a></li>
<li><a href="/ej2-asp-core/pdfviewer/open-pdf-file/from-google-drive">From Google Drive</a></li>
Expand Down
2 changes: 1 addition & 1 deletion ej2-asp-mvc-toc.html
Original file line number Diff line number Diff line change
Expand Up @@ -1840,7 +1840,7 @@
</li>
<li><a href="/ej2-asp-mvc/pdfviewer/feature-module">Feature Modules</a></li>
<li>
Open PDF files
<a href="/ej2-asp-mvc/pdfviewer/open-pdf-file">Open PDF files</a>
<ul>
<li><a href="/ej2-asp-mvc/pdfviewer/open-pdf-file/from-azure-blob-storage">From Azure Blob Storage</a></li>
<li><a href="/ej2-asp-mvc/pdfviewer/open-pdf-file/from-google-drive">From Google Drive</a></li>
Expand Down