|
<button onclick="loadPdf()">Save PDF</button>
<script>
function loadPdf() {
var pdfviewer = document.getElementById('container').ej2_instances[0];
//pdfviewer.load('Hive_Succinctly.pdf', null);
pdfviewer.saveAsBlob().then(function (value) {
var testData = value;
var a = document.createElement("a");
document.body.appendChild(a);
var url = window.URL.createObjectURL(testData);
a.rel='nofollow' href = url;
a.download = "PDF_Doc.pdf";
a.click();
window.URL.revokeObjectURL(url);
console.log('value', value);
var reader = new FileReader();
reader.readAsDataURL(testData);
reader.onloadend = function() {
var base64data = reader.result;
console.log(base64data);
//var a = JSON.parse(value);
}// var annotation = a.pdfAnnotation;
});
}
</script>
|
hello sir I want to import annotation file when syncfusion load without mannually and export that changes
how to unique id from localstorage in pdf
Hi Vishal,
Sample - https://stackblitz.com/edit/react-hqtmm9-vvhz9v?file=index.js,index.html
Regards,
Visvesvar K V
i trying to do the same in my next application. but when I call viewer.saveAsBlob() it showing that "Web-service is not listening. PDF Viewer depends on web-service for all it's features. Please start the web service to continue."
do we need separate server for this ?
Hi Nayan,
Please find the code
snippet, sample and documentation for how to get the document base64 string
using the saveAsBlob method.
Code snippet:
|
const saveAsBlob = () => { var data; var base64data; viewer.saveAsBlob().then(function (value) { data = value; var reader = new FileReader(); reader.readAsDataURL(data); reader.onload = () => { base64data = reader.result; console.log(base64data); viewer.load(base64data, null); }; }); }; |
Sample: https://stackblitz.com/edit/github-hslfxx-htzvkd?file=pages%2Findex.tsx
Documentation: https://ej2.syncfusion.com/angular/documentation/pdfviewer/how-to/get-base-string-of-the-loaded-document
The "Web-service is not listening” error occurred for various reasons. To troubleshoot this issue, you can use the Network tab in your browser’s developer tools to gather more information. Please refer the below documentation and share the network tab response to proceed further.
Documentation: https://ej2.syncfusion.com/angular/documentation/pdfviewer/how-to/webservice-not-listening
Along with the network tab response, Please share the below details.
Note: You don't need a separate server for the saveAsBlob method.