Skip to content

Instantly share code, notes, and snippets.

@kmrobin
Last active May 24, 2020 03:50
Show Gist options
  • Save kmrobin/fa0230ccd5d75b76c9e00c7d3a318013 to your computer and use it in GitHub Desktop.
Save kmrobin/fa0230ccd5d75b76c9e00c7d3a318013 to your computer and use it in GitHub Desktop.
AEM PDF Search & Preview (JS)
//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