Dear all,
I have problem to hide Download Button on Preview.
How to Disabling Preview Download in Alfresco 5.2
Thanks & regards,
Iwan K
Solved! Go 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.
Hi, have you resolved this issue? I have same problem with you.
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.
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
You can try using an evaluator on the module extension, see Conditional Rendering (Evaluators) | Alfresco Documentation
Thank you sooo much for your answer, I know what I should to do now
You're welcome, I'm glad it helped!
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.
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
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
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.