cancel
Showing results for 
Search instead for 
Did you mean: 

How to Disabling Preview Download in Alfresco 5.2

i_kurnia
Champ in-the-making
Champ in-the-making

Dear all,

I have problem to hide Download Button on Preview.

How to Disabling Preview Download in Alfresco 5.2 

Thanks & regards,

Iwan K

1 ACCEPTED ANSWER

jpotts
World-Class Innovator
World-Class Innovator

There are two download buttons on the document details page. One is in the upper right-hand corner. The other is in the PDF.js viewer itself.

To hide both buttons you can use a Share module extension.

Everything in this post assumes you are using SDK 3.0.0 and a fairly recent version of Alfresco (5.1 or 5.2). Your mileage may vary with other versions.

First, the PDF.js button...

In src/main/resources/alfresco/web-extension/site-data/extensions create an XML file called hide-download-pdf.xml with the following:

<extension>
    <modules>
        <module>
            <id>Hide Download Buttons</id>
            <auto-deploy>true</auto-deploy>
            <customizations>
                <customization>
                    <targetPackageRoot>org.alfresco</targetPackageRoot>
                    <sourcePackageRoot>com.someco</sourcePackageRoot>
                </customization>
            </customizations>
        </module>
    </modules>
</extension>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Obviously, do not use "com.someco". Instead, use your own reverse domain package structure namespace.

Now, under src/main/resources/alfresco/web-extension/site-webscripts/com/someco/modules/preview create a file called pdfjs.get.js with the following:

for (var i = 0; i < model.toolbarItems.length; i++) {
    if (model.toolbarItems[i].id == "download") {
        model.toolbarItems[i].disabled = true;
    }
}‍‍‍‍‍

That's it, the PDF.js download button will be disabled.

Next, let's look at the Download button on the page...

Under src/main/resources/alfresco/web-extension/site-webscripts/com/someco/components/node-details create a file called node-header.get.js with the following:

model.showDownload = "false";

Now build your AMP with mvn package and deploy. The buttons will be gone.

View answer in original post

11 REPLIES 11

abbask01
Star Collaborator
Star Collaborator

Yes Jeff, i've created the same script as you mentioned following the correct path. the evaluator somehow only works with the node-header.get.js. i also placed a logger in the pdfjs.get.js - it works fine without the evaluator.

Regards,
Abbas

sanjaybandhaniya
Elite Collaborator
Elite Collaborator

Hi Jeff,

Here you have mention that use "com.alfresco" as source package but i have other extension module(hide-custom-workflow) like  I want to hide custom workflow from drop downlist,

For that i have use extension module.

Like this way

<targetPackageRoot>org.alfresco.components.workflow</targetPackageRoot>
<sourcePackageRoot>com.mbs.components.workflow</sourcePackageRoot>

If i use hide download button extension module then it will hide my hide-custom-workflow also.

In future i want to unable my extension module(hide-custom-workflow) then i have to unable hide-download button module.