How to Disabling Preview Download in Alfresco 5.2

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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 Solution

Accepted Solutions
Professional

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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 solution in original post

11 Replies
Member II

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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

Professional

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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 solution in original post

Active Member

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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

Professional

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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

Active Member

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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

Professional

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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

Senior Member II

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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.

Thanks & Regards,
Sanjay
Senior Member

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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
Professional

Re: How to Disabling Preview Download in Alfresco 5.2

Jump to solution

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