04-21-2017 02:39 AM
Dear all,
I have problem to hide Download Button on Preview.
How to Disabling Preview Download in Alfresco 5.2
Thanks & regards,
Iwan K
08-24-2017 10:33 AM
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.
08-17-2017 03:30 AM
Hi, have you resolved this issue? I have same problem with you.
08-24-2017 10:33 AM
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.
03-06-2018 02:28 AM
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
04-05-2018 12:57 PM
You can try using an evaluator on the module extension, see Conditional Rendering (Evaluators) | Alfresco Documentation
04-25-2018 02:35 AM
Thank you sooo much for your answer, I know what I should to do now
04-25-2018 11:35 PM
You're welcome, I'm glad it helped!
03-29-2019 01:09 PM
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?
01-24-2019 03:58 AM
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
01-28-2019 10:31 AM
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
Explore our Alfresco products with the links below. Use labels to filter content by product module.