Which product are you using?
PDF.js Express Viewer
PDF.js Express Version
8.7.4
Detailed description of issue
I’m just setting up a starting point to display a pdf in a html document using your documentation here PDF.js Express Viewer Download & Integration | Documentation
After following al required stesp, my browser shows only a set of nested iframes without any pdf
Expected behaviour
Display of selected pdf file
Does your issue happen with every document, or just one?
I’ve tried local pdf and base64 string without success
Link to document
{Provide a link to the document in question if possible}
Code snippet
my source code is the following:
<!DOCTYPE html>
<html>
<head>
<title>PDF.js Express</title>
</head>
<!-- Import PDF.js Express as a script tag from the lib folder using a relative path -->
<script src='/lib/webviewer.min.js'></script>
<style>
#viewer{width:1024px,height:600px,margin:0 auto;}
</style>
<body>
<div id='viewer'></div>
<script>
const myBase64String = "JVBERi0xLjUKJeLjz9MKMyAwIG9iago8PC9GaWx0ZXIvRmxhdGVEZWNvZGUvTGVuZ3RoIDQxOT4+c3RyZWFtCnicpZJNb9swDIbv+hU8doe0khJ/9EhbrKtAFh1JCTAPO61YgQE9bGf9+MlugrXF1g2YD7Kgl6T4PqIEBRsFEmqly/rlSXwXXRLbGqqmhvQgKImD0LBfTpc4CZfo9CRu7hQoCemruPqQvi2xv0LWYq+SqlZfN2/y5Kr+eBRXutJabaSUtxstVbvpsiFHA/aWPTiMMFqPMXfs0c+YHUfoORgKNpWtIcDhiNA7DJhrqWRpsamWcqccrTtZhBEHg448guOJZog4duwwj5TQndeJQ2JPMeuSKq+lzEov1iQ8/sbep8/l/7Diedd43bxvXDaL8ebZuAkvnRuaMCQcyZf2YAjo0WA2NljMQzhODJGdNRgsX1RYVSAHGAJ/5Kzbna7lbtsung45sl9phMKCoMNwOFIodQq5gimX6yiif7VLOOMLJtv6/5lUfxkGJRcm7ZnJn5H0pe2Zs2HHobzbWybPMpxl2C6TMuIKRelK3pZ7yufyniPBXQHY29gznKiMXOEyQ07HYOPI+Z7jRAb3lO+xs2ntpVTEmz63FzC79p/A/AQt6dOCCmVuZHN0cmVhbQplbmRvYmoKMSAwIG9iago8PC9UYWJzL1MvR3JvdXA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IDY1NTM1IGYgCjAwMDAwMDA1MDEgMDAwMDAgbiAKMDAwMDAwMDc4NyAwMDAwMCBuIAowMDAwMDAwMDE1IDAwMDAwIG4gCjAwMDAwMDA4NzUgMDAwMDAgbiAKMDAwMDAwMDc1MiAwMDAwMCBuIAowMDAwMDAwOTM4IDAwMDAwIG4gCjAwMDAwMDA5OTIgMDAwMDAgbiAKMDAwMDAwMTAyNCAwMDAwMCBuIAowMDAwMDAxMTI3IDAwMDAwIG4gCnRyYWlsZXIKPDwvSW5mbyA5IDAgUi9JRCBbPGRjNzM0ZDIxZGM4MzE2YjI0Yjc0Y2UzNzg0Y2U3OGE4PjxjNzk5ODBiZTcwOThkMTg0ZGZkNTdmM2E1MTVlZGU2NT5dL1Jvb3QgOCAwIFIvU2l6ZSAxMD4+CnN0YXJ0eHJlZgoxMjk0CiUlRU9GCg\u003d\u003d";
WebViewer({
path: 'WebViewer/lib', // path to the PDF.js Express'lib' folder on your server
licenseKey: 'Insert commercial license key here after purchase',
// initialDoc: '/path/to/my/file.pdf', // You can also use documents on your server
}, document.getElementById('viewer'))
.then(instance => {
instance.UI.loadDocument(base64ToBlob(myBase64String), { filename: 'myfile.pdf' });
const { documentViewer } = instance.Core;
documentViewer.addEventListener('documentLoaded', () => {
// perform document operations
});
});
function base64ToBlob(base64) {
const binaryString = window.atob(base64);
const len = binaryString.length;
const bytes = new Uint8Array(len);
for (let i = 0; i < len; ++i) {
bytes[i] = binaryString.charCodeAt(i);
}
return new Blob([bytes], { type: 'application/pdf' });
};
</script>
</body>
</html>