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

justinliyh
Champ in-the-making
Champ in-the-making

Hi, have you resolved this issue? I have same problem with you.

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.

sychel
Champ on-the-rise
Champ on-the-rise

Hi Jeff,

Your answer is really helpful.

However, do you know how can I conditionally disable the download button in viewer? For example, I want to disable it only if it's Consumer or SiteConsumer.

Thank you

jpotts
World-Class Innovator
World-Class Innovator

You can try using an evaluator on the module extension, see Conditional Rendering (Evaluators) | Alfresco Documentation 

sychel
Champ on-the-rise
Champ on-the-rise

Thank you sooo much for your answer, I know what I should to do now Smiley Happy

jpotts
World-Class Innovator
World-Class Innovator

You're welcome, I'm glad it helped!

facha
Champ in-the-making
Champ in-the-making

Hello,

I'm new with alfresco and i have your same request about how can I conditionally disable the download button in viewer? For example, I want to disable it only if it's Consumer or SiteConsumer.

Can you help me please?

abbask01
Star Collaborator
Star Collaborator

Hi Jeff Potts‌,

I tried to hide the buttons as described by you. but while using it with an evaluator only the "node-header.get.js" button gets affected not the PDF.js (i still see the download button in the preview is enabled). below is my module extension file (package changed).

<extension>
<modules>
<module>
<id>Hide all download buttons</id>
<version>${project.version}</version>
<auto-deploy>true</auto-deploy>
<evaluator type="group.module.evaluator">
<params>
<groups>SiteConsumer</groups>
</params>
</evaluator>
<customizations>
<customization>
<targetPackageRoot>org.alfresco</targetPackageRoot>
<sourcePackageRoot>com.someco</sourcePackageRoot>
</customization>
</customizations>
</module>
</modules>
</extension>‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Please help if i've missed some configuration.

Thanks!

Abbas

Regards,
Abbas

jpotts
World-Class Innovator
World-Class Innovator

Abbas,

I see that you've configured a Share module extension but did you also do the second part, which is to override the web script controller with your own modified pdfjs.get.js script as shown in my earlier post?

Jeff