I am using mozilla pdf js viewer. Initially I am showing my base 64 string into my page through the iframe.
const base64 = 'JVBERi0xLjMNJcjIyMjIyMgNMSAwIG9iago8PC9UeXBlL0NhdGFsb2cvT3V0bGluZXMgMiAwIFIvUGFnZXMgMyAwIFIvTWV0YWRhdGEgMTEgMCBSPj4NCmVuZG9iagoyIDAgb2JqCjw8L1R5cGUvT3V0bGluZXMvQ291bnQgMD4 DQplbmRvYmoKMyAwIG9iago8PC9UeXBlL1BhZ2VzL0NvdW50IDIvS2lkc1s0IDAgUiA2IDAgUl0 Pg0KZW5kb2JqCjQgMCBvYmoKPDwvVHlwZS9QYWdlL1BhcmVudCAzIDAgUi9SZXNvdXJjZXM8PC9Gb250PDwvRjEgOSAwIFI Pi9Qcm9jU2V0IDggMCBSPj4vTWVkaWFCb3hbMCAwIDYxMiA3OTJdL0NvbnRlbnRzIDUgMCBSL0Fubm90c1sxNiAwIFIgMTcgMCBSIDE4IDAgUiAxOSAwIFJdPj4NCmVuZG9iago1IDAgb2JqCjw8L0ZpbHRlci9GbGF0ZURlY29kZS9MZW5ndGggMzAyPj5zdHJlYW0NCnicvVPRSsMwFH3PV5xHBb22WdOmj5tuD8JAsfge1nTLaNPZpCJ va3bXgZmE8EkcHMezjncc7nsjXE8slnBIoy3W7O7RQyeoaiYyGiSCWScE5coSnaFKV5Ms6s1nh4WWJjhc41iy bFKDEy42hkpjlxgVRKSqMDs9gYh EpuEbVNUrdtNb5TnnTWtCurFCNerdBxTShLEr2itveeVRth95pGAu/0Xg1ne9VjaVebZQ1Kwff 7YzqnaEZdtpeP3hCVNbohlhyExwygTfm53QLoEhaS5JJsdMfyP6EwyZxSnJPA30MRsSsusbfI7nEsuQW5RQnhxG9Oe2ziYpck55zi9JMqQylEj 0zzEsFfxJDSPEzh/1/YbE 5b643tdYlhaXZqrcFBREe35y8iwhNSDQplbmRzdHJlYW0NCmVuZG9iago2IDAgb2JqCjw8L1R5cGUvUGFnZS9QYXJlbnQgMyAwIFIvUmVzb3Vy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MzJEMzUzNjJEMzEzMzJEMzEzMjJEMzQ XS9TaXplIDIwPj4Kc3RhcnR4cmVmCjY1MjUKJSVFT0YK'
function base64ToBlob(base64, type = "application/octet-stream") {
const binStr = atob(base64);
const len = binStr.length;
const arr = new Uint8Array(len);
for (let i = 0; i < len; i ) {
arr[i] = binStr.charCodeAt(i);
}
return new Blob([arr], { type: type });
}
const blob = base64ToBlob(base64, 'application/pdf');
const blobUrl = URL.createObjectURL(blob);
var url = "/web/viewer.html?file=" blobUrl;
var iframe = document.getElementById('pdf-viewer');
iframe.src = url;
iframe.addEventListener("load", function () {
setTimeout(() => {
let PDFViewerApplication = window.iframe.contentWindow.PDFViewerApplication;
console.log('PDFViewerApplication', PDFViewerApplication);
})
});
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>'Hello, world!' example</title>
<link rel="stylesheet" href="index.css">
</head>
<body>
<iframe id="pdf-viewer"></iframe>
<button >Download</button>
<script src="index.js"></script>
</body>
</html>
after I load the pdf I have option to add some other annotations for example free text feature or self drawing
but I can't find a way to access to the reference of this file, and transform it to base 64. So after the user makes all of the modifications I will get base 64 with all annotations in my pdf old and new ones.
I can't find such an example for that.
I access to the pdf viewer reference through the PDFViewerApplication
property. I have such a variable and there are a bunch of properties and methods availvable from pdf js viewer library.
How can i get base 64 with all of the annotations or binary format ?
CodePudding user response:
There is absolutely no problem here.
- YOU (as a user) make alterations to a PDF downloaded by the html instructions, to add text or lines in a browser PDF binary extension, like Acrobat Reader or SumatraPDF Plugin or Chrome (Foxit) or FireFox (Mozilla PDF.js). They all do roughly the same with one or two odd differences. E.G. thy all use different temporary storage filenames thus no common one.
YOU save the annotation modifications, by renaming the file into a folder on the CPU (device) filesystem. (you can set that the same name if the user complies). See the filename above is only the temporary local name. So need rename to a drive:\folder\file.pdf
You then run that OS (Systems Native) Base64 utility so for Windows users that's via certutil.exe. For Linux or Mac its supposedly base64 -e
You then ask the user to upload their base64 file from their file system. (much easier to use a file picker for the NEW.PDF.
CodePudding user response:
To get binary data from a PDF file with annotations, you can use a PDF library or tool that allows programmatic manipulation of PDFs. Extract the binary data, add annotations, save and extract the data again. Check the library's documentation for specific methods.