How can i render the pdf document based on the URL in PDF Viewer. I tried two ways and both are not working. There are given below :
1) using document-path :
Facing issue while using document-path : Pdf viewer is render, but the pdf document is not render within pdfviewer
2) using base64data :
Facing issue while using base64data : Some error dialog popup will trigger and the error message is like "Corrupted data"
Expectation output is : Need to render the online pdf (based on the URL) within the pdf viewer using vuejs and nodejs platform not in asp.net & C#
Please someone help me out in this issue
Thanks in Advance
|
Query |
Details | ||
|
How can i render the pdf document based on the URL in PDF Viewer. I tried two ways and both are not working. There are given below :
1) using document-path : <ejs-pdfviewer
id="pdfviewer"
ref="pdfViewer_instance"
:service-url="serviceUrl"
/>
Facing issue while using document-path : Pdf viewer is render, but the pdf document is not render within pdfviewer
2) using base64data :
async getBase64 (filePath) {
await new Promise((resolve, reject) => {
const xhr = new XMLHttpRequest()
xhr.open('GET', filePath, true)
xhr.responseType = 'blob'
xhr.onload = function (e) {
const myBlob = this.response
const reader = new window.FileReader()
// read the blob data
reader.readAsDataURL(myBlob)
reader.onloadend = function () {
const base64data = reader.result
// Typecast the HTMLElement to avoid Typescript lint issue
const pdfviewer = document.getElementById('pdfviewer').ej2_instances[0]
// load the base64 string
pdfviewer.load(base64data, null)
}
}
xhr.send()
})
Facing issue while using base64data : Some error dialog popup will trigger and the error message is like "Corrupted data"
|
You can’t load the PDF documents from a URL directly in our PDF Viewer control. You need to load them into the PDF Viewer control by creating your own web service as provided in the link and replacing the below load method on the created web service.
In this, you have to download the PDF document by using the WebClient class and loaded the same in the PDF Viewer control. Please find the below code snippet for loading the PDF file directly from the static URL.
Controller code:
Note: The service URL ('https://ej2services.syncfusion.com/production/web-services/api/pdfviewer') is only for demo purposes. We need to create the own web service and run the same and refer to the localhost link in the serviceUrl property of our PDF Viewer control.
Please find the UG documentation link for more details about using the PDF Viewer control
| ||
|
Expectation output is : Need to render the online pdf (based on the URL) within the pdf viewer using vuejs and nodejs platform not in asp.net & C#
Please someone help me out in this issue
|
At present there is no support for PDF Viewer Web service in Node Js and Vue Js applications. PDF Viewer control is client-server oriented. PDF viewer control processes the PDF document on the server-side (developed with the .NET environment) and sends the processed PDF data to the client using the web service to render the PDF document and for further operations in PDF viewer.
Please find the below UG link to getting started with PDF Viewer,
We need all the web action methods provided in the below link to rendering the PDF pages and for further operations in PDF Viewer. We will send the necessary data through the AJAX request from the source level. You can create the PDF Viewer Web Service project in ASP.NET Core/ ASP.NET MVC with the help of the below links.
ASP.NET Core: https://www.syncfusion.com/kb/10346/how-to-create-pdf-viewer-web-service-application-in-asp-net-core
|