Last active
May 24, 2020 03:50
-
-
Save kmrobin/fa0230ccd5d75b76c9e00c7d3a318013 to your computer and use it in GitHub Desktop.
AEM PDF Search & Preview (JS)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Include the View SDK JS from https://documentcloud.adobe.com/view-sdk/main.js | |
const viewerConfig = { //You can make these options configurable and read them from AEM Dialog | |
showAnnotationTools: true, enableFormFilling: true, showLeftHandPanel: true, showDownloadPDF: true, showPrintPDF: true, showPageControls: true,dockPageControls: true, defaultViewMode: "FIT_WIDTH" | |
}; | |
function initializePDF(pdfFilePath, title) { | |
var adobeDCView = new AdobeDC.View({ clientId: "<YOUR_VIEW_SDK_CLIENT_ID>", divId: "adobe-dc-view", reportSuiteId: "<YOUR_ANALYTICS_REPORT_SUITE_ID>"}); | |
adobeDCView.previewFile({content:{location: {url: pdfFilePath}}, metaData:{fileName: title}}, viewerConfig); | |
adobeDCView.registerCallback( | |
AdobeDC.View.Enum.CallbackType.EVENT_LISTENER, | |
function(event) { if(event.type=="APP_RENDERING_DONE"){ // Your custom logic after PDF Rendering completes}}, | |
{enablePDFAnalytics: true} | |
); | |
} | |
$(document).ready(function() {//click event of individual search result item | |
$(".type_pdf").click(function(){ | |
initializePDF($(this).siblings('a').attr('href'), $(this).siblings('a').text()); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment