I am trying to display a pdf file using Base64data in the Lightning Web component, the PDF Viewer renders but it does not get the PDF file in it.
here's my HTML:
<template if:true={showModal}>
<c-modal show-modal={showModal} is-large="true" onclosemodal={handleCloseModal}>
<iframe id="pdfFrame" src="/resource/pdfjs/web/viewer.html" width="100%" height="600" class="pdfFrame" onload={loadpdf}></iframe>
</c-modal>
</template>
Here's my JS controller to load PDF :
loadpdf(event){
alert(this.pdfData);
this.template.querySelector('pdfFrame').contentWindow.postMessage(this.pdfData,'*');
}
in LoadPdf alert statement, the pdf data is coming just fine, the pdf viewer also renders fine like below but without the actual file :
is the code to postMessage in iFrame correct here?
Using this GitHub library.