Purpose
Creating PDF exports in Confluence can impact and seriously degrade system performance, as described in the KB article: Exporting page or space to PDF fails and causes high load or OutOfMemory Error. To prevent performance issues, you may wish to limit the ability to export within Confluence to System Administrators and Space Administrators only, or disable the ability all together.
Solution
Disable PDF Space Exports
PDF Space exports can be entirely disabled with the below steps
- Go to
Confluence Admin
>General Configuration
- Choose
Manage Add-ons
from the left hand panel - Select
All Add-ons
from drop-down menu - Search for
Confluence PDF Export
Click 18 of 18 modules enabled to expand the module list
- Mouse over XML Export Format
- Click on
Disable on the right side
- PDF Space exports are now disabled globally
Restrict Space Exports to Confluence Administrators and Space Administrators
Create default Space Permissions for new Spaces
- Go to
Confluence Admin
>General Configuration
- Select
Space Permissions
from the left-hand panel - Click the
Edit Permissions
button - Edit the Default Permissions for the
confluence-users
group - Uncheck the
Space/Export
permission - Click Save
Change Permissions on existing Spaces
- Choose
Confluence Admin
>General Configuration
- Select
Space Permissions
from the left-hand panel - Select
Manage Permissions
link- This will need to be done for each Space individually
- Click the
Edit Permissions
button to remove the Export permission from the group confluence-users - Save
How to disable attachment downloads
This guide is for informational purposes and is not eligible for support from Atlassian. If you have any questions about the information on this page, please reach out to our community at Atlassian Answers for help.
Purpose
To make attachments not available to download. Follow the instructions below to disable attachment downloads.
Solution
Code Changes Required
This configuration requires changing the Confluence code in your installation. You will need to reapply these changes whenever you upgrade Confluence. Proceed with caution.
At the moment, permissions for downloading attachments can't be set. To disable attachment downloading you need to edit your velocity files. Attachments can currently be downloaded in two separate ways:
- Viewing the attachments for a page
- Viewing all the attachments for a Space (Browse > Attachments)
These customizations will disable attachment downloads for all users, including administrators.
Disable attachments for a whole Space
To disable downloading attachments from a Space, you need to edit the listattachmentsforspace.vm file. Delete or comment out the following line:
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td>
and replace it with either of the following two code blocks:
Disabling downloading for all attachments
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td>
Disabling downloading for specific file types
#set($disabledDownloads = ['ext1', 'ext2'])
#set($disabled = false)
#set($attachmentExtension = $attachment.fileExtension)
<tr id="attachment_$!attachment.id">
#foreach($doNotDownload in $disabledDownloads)
#if($attachmentExtension == $doNotDownload)
#set($disabled = true)
#break
#end
#end
#if(!$disabled)
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> <a href="$req.contextPath$!attachment.downloadPathWithoutVersion">$generalUtil.shortenString($attachment.fileName, 50)</a></td>
#else
<td><a name="$!generalUtil.urlEncode($!attachment.content.displayTitle)-attachment-$!generalUtil.urlEncode($!attachment.fileName)">#parse ("/pages/includes/attachment_icon.vm")</a> $generalUtil.shortenString($attachment.fileName, 50)</td>
#end
To specify which files you want disabled, change the
'ext1', 'ext2'
in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read
#set($disabledDownloads = ['jpg', 'doc', 'png'])
Disable attachments for a specific page
If you take the steps in this section but not in the section above, the files you disable can still be downloaded by browsing all attachments for a Space.
To disable downloading attachments from a specific page, you need to edit the attachments-table.vm file. Delete or comment out the line
<a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a>
and replace it with either of the following two code blocks:
Disabling downloading for all attachments
$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))
Disabling downloading for specific file types
#set($disabledDownloads = ['ext1', 'ext2'])
#set($disabled = false)
#set($attachmentExtension = $attachment.fileExtension)
#foreach($doNotDownload in $disabledDownloads)
#if($attachmentExtension == $doNotDownload)
#set($disabled = true)
#break
#end
#end
#if(!$disabled) <a class="filename" href="$generalUtil.htmlEncode("${req.contextPath}${attachment.downloadPathWithoutVersion}")" title="$generalUtil.htmlEncodeAndReplaceSpaces($attachment.fileName)" >$generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))</a>
#else $generalUtil.htmlEncode($generalUtil.shortenString($attachment.fileName, 35))
#end
Again, to specify which files you want disabled, change the
'ext1', 'ext2'
in the first line to the extensions for which you want to disable downloading. You can specify as many extensions as you want, as long as they are in quotes, are comma separated and do not include the '.' at the start. For example, if I did not want users to download .jpg and .doc and .png files, the line would read
#set($disabledDownloads = ['jpg', 'doc', 'png'])
Removing the 'Download All' button
If you do not take the steps in this section, users will still be able to download all attachments regardless of whether they have been disabled or not.
- Click
, then General Configuration
- Click Stylesheet, then the Edit button
- Add the following to the Global Stylesheet
- a.download-all-link
none
!important;- }
- a#download-all-link
none
!important;
}
- Save
You can alternatively just disable Download All on a space by space basis by adding the above CSS to individual Space Stylesheets instead:
- Go to the space and choose Space Tools > Look and Feel from the bottom of the sidebar
- Choose Stylesheet then Edit.
- Paste the above CSS into the text field.
- Save
Removing the 'Download All' button along with the 'download' Icon while previewing the attachment
You can also remove download options by suppressing HTML elements using the Custom HTML section within Confluence. While the above steps can remove the 'Download All' option, users can still manage to download the attachment by previewing it and using the 'Download Icon'. You can use the following steps to suppress both download all and download icon.
- Go to Confluence 'gear' icon and click on 'General Configuration'
- Go to 'Custom HTML'
- Edit and insert the following code into the 'At end of the HEAD' section.
- Save.
<style type="text/css">
.cp-control-panel-download {
display:none !important;
}
.cp-waiting-message-download {
display:none !important;
}
a.download-all-link {
display: none !important;
}
a#download-all-link {
display: none !important;
}
</style>
Disable attachments download, export, print and other functions in specific spaces
Apr 12, 2021
Recently, some teams using Confluence have put forward more advanced requirements for information confidentiality.
These space administrators want to prohibit users from downloading, exporting, and printing attachments in designated spaces.
Last week, I checked a lot of related setting posts in the community. According to the community’s suggestions, I adjusted the space configuration for your reference.
Hide the download button on the preview page
Space Tools--Look and feel--Layout--Content Layouts---Page Layout
<style type="text/css">
.cp-control-panel-download {
display:none !important;
}
.cp-waiting-message-download {
display:none !important;
}
a.download-all-link {
display: none !important;
}
a#download-all-link {
display: none !important;
}
</style>
Hide attachment button
Space Tools--Look and feel--Layout--Content Layouts---Main Layout
#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#view-attachments-link').hide();
AJS.$('#view-in-hierarchy-link').hide();
AJS.$('#content-metadata-attachments').hide();
});
</script>
#end
#if ($userAccessor.hasMembership('confluence-administrators', $helper.action.remoteUser.name))
#else
<script type="text/javascript">
AJS.toInit(function(){
AJS.$('#space-tools-menu-trigger').hide();
});
</script>
#end
disable right mouse click
Space Tools--Look and feel--Layout--Content Layouts---Page Layout
<script type="application/javascript">
content_dom = document.getElementsByClassName("confluence-embedded-file");
for (var i = 0; i < content_dom.length; i++) {
content_dom[i].oncontextmenu = function () {
return false;
}
}
a_dom = document.querySelectorAll('a[data-linked-resource-type="attachment"]')
for (var i = 0; i < a_dom.length; i++) {
a_dom[i].oncontextmenu = function () {
return false;
}
}
</script>
print out a blank page
Space Tools--Look and feel--Layout--Content Layouts---Page Layout
<style type="text/css" media="print">
body { visibility: hidden; display: none }
</style>
加到最后