<html>
<head>
<title><?= $title ?></title>
<style>
#adobe-dc-view {
width: 100%;
height: 100%;
margin: 0 auto;
padding: 0;
}
</style>
</head>
<body>
<div id="adobe-dc-view"></div>
<script src="https://documentcloud.adobe.com/view-sdk/main.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.2.1/crypto-js.min.js" crossorigin="anonymous"
referrerpolicy="no-referrer"></script>
<script>
var DataLink = "<?= $cir_link ?>";
var DataKey = CryptoJS.enc.Utf8.parse("01234567890123456789012345678901");
var DataVector = CryptoJS.enc.Utf8.parse("1234567890123412");
var CipherText = CryptoJS.AES.decrypt(DataLink, DataKey, {
iv: DataVector
});
var urlToPDF = CryptoJS.enc.Utf8.stringify(CipherText);
var viewerOptions = {
embedMode: "FULL_WINDOW",
defaultViewMode: "FIT_WIDTH",
showDownloadPDF: false, // false removes the download PDF button from the viewer
showPrintPDF: false, // false removes the print PDF button from the viewer
showLeftHandPanel: true,
showAnnotationTools: false
}
document.addEventListener("adobe_dc_view_sdk.ready", function() {
fetch(urlToPDF)
.then((res) => res.blob())
.then((blob) => {
var adobeDCView = new AdobeDC.View({
// This clientId can be used for any CodePen example
clientId: "e7a993b52d0542a386354399254a4b37",
// The id of the container for the PDF Viewer
divId: "adobe-dc-view"
});
adobeDCView.previewFile({
// The file content
content: {
promise: Promise.resolve(blob.arrayBuffer())
},
/*
required - A filename that will be used in the PDF View.
The fileName value here does not need to match the filename of
the source PDF. If the PDF View permits download, the value
of the fileName proprty will be used as the download
filename. This is also the name that will be passed
as the fileName in event objects when events are enabled
*/
metaData: {
fileName: urlToPDF.split("/").slice(-1)[0]
},
headers: {
"Content-Length": blob.size.toString() // Set the Content-Length header
}
},
viewerOptions
);
});
});
// Add arrayBuffer if necessary i.e. Safari
(function() {
if (Blob.arrayBuffer != "function") {
Blob.prototype.arrayBuffer = myArrayBuffer;
}
function myArrayBuffer() {
return new Promise((resolve) => {
let fileReader = new FileReader();
fileReader.onload = () => {
resolve(fileReader.result);
};
fileReader.readAsArrayBuffer(this);
});
}
})();
</script>
</body>
</html> |