AnsweredAssumed Answered

Customizing Aikau PdfJs Preview Widget

Question asked by keith.bailey@synapps-solutions.com on Feb 23, 2017
Latest reply on Mar 1, 2017 by keith.bailey@synapps-solutions.com

Hi,

 

I'm pretty new to Share development so please bear with me.

 

What I'd like to do is the following :

 

1) Change the behaviour of the Aikau PdfJs viewer, so that it is maximized by default.

2) Show the PDF outline/thumbnail sidebar by default.

 

So, far I'm failing to make much progress on 1) - i've got the following config, and I suspect the <targetPackageRoot> is incorrect, but i've tried 'preview' and 'document-details' packages. The preview one seems the most logical.

 

What else do I need ? Is the below sufficient to push an updated config to the widget ? 

 

What about the ID's ?

I couldnt figure out what the ID should be for AlfDocumentPreview, so I tried finding by name. At the moment, I dont think the .js is even being run, so its a non-starter.

Can you push a config to the widget without an ID ?

 

On the off-chance that i'm on the right track, is using 'widgetsForPluginsOverrides' the correct mechanism to use? 

 

Finally, can I use the same mechanism to perform requirement 2) - It doesnt look like there is a flag for the sidebar, although the vanilla mozilla pdfjs appears to have a "sidebarViewOnLoad"... I can see there is a onSideBarToggle() method, but how can I cause this to fire ?

 

For what its worth, I have been through the excellent Aikau tutorials by Dave Draper, but I cant help feeling i'm missing something fundamental when it comes to lightly modifying a widget through a surf extension module.

 

Thanks for any help / pointers.

 

Cheers,

 

Keith

 

/src/main/amp/config/alfresco/web-extension/site-data/extensions/myco-custom-viewer.xml

<extension>
     <modules>
          <module>
               <id>Custom Document Preview Widget</id>
               <description>Instantiate a Document Preview Widget</description>
               <auto-deploy>true</auto-deploy>
               <customizations>
                    <customization>
                         <targetPackageRoot>org.alfresco.modules.preview</targetPackageRoot>
                         <sourcePackageRoot>com.myco.modules.preview</sourcePackageRoot>
                    </customization>
               </customizations>
          </module>
     </modules>
</extension>

/src/main/amp/config/alfresco/web-extension/site-webscripts/com/myco/modules/preview/myco-preview.get.js

var docPreview = widgetUtils.findObject(model.jsonModel, "name",
          "alfresco/preview/AlfDocumentPreview");
this.alfLog("log", "In override viewer Widget", config);

if (docPreview != null) {
this.alfLog("log", "Found Preview Widget ", config);
     docPreview.config.widgets.push({
          name : "alfresco/preview/AlfDocumentPreview",
          config : {
               heightMode : 600,

               widgetsForPluginsOverrides : [ {
                    id : "PdfJs",                    
                    name: "alfresco/preview/PdfJs/PdfJs",
                    replace: true,
                    config: {
                         maximized : "true" }
               } ]
          }
     });
}

Outcomes