AEM: PDF links in Text component always download due to Content-Disposition header
This article explains why PDF links created in the Adobe Experience Manager (AEM) Text component may always trigger downloads instead of opening in a new tab and provides steps to resolve the issue.
Description description
Environment
Adobe Experience Manager (AEM), all versions
Issue/Symptoms
- When a PDF link is authored in the AEM out-of-the-box Text component (Rich Text Editor), clicking the link always causes the PDF to be downloaded, regardless of whether the link is set to open in a new tab or the same tab.
- The browser response header for the PDF includes
content-disposition: attachment. - This behavior persists even when attempting to override the header via Dispatcher configuration or by adding the PDF path to the Excluded Resource Paths in the Apache Sling Disposition Filter.
- Unchecking Enable for All Resource Paths in the Disposition Filter allows PDFs to open in a new tab as expected.
- The issue may not be reproducible on all environments or browsers. In some cases, clearing the CDN cache resolves the issue.
Cause
The Content-Disposition header is set to attachment by default for binary assets (such as PDFs) on AEM Publish. This causes browsers to download the file instead of displaying it inline. Overriding this header at the Dispatcher layer or adjusting the Disposition Filter can resolve the issue.
Resolution resolution
Follow the steps below to resolve the issue:
-
Verify the environment to determine whether the issue occurs on Author, Publish, or both. Adobe recommends only modifying Content-Disposition headers on the Publish tier.
-
Review the Apache Sling Disposition Filter settings.
- In the AEM Web Console, navigate to Apache Sling Disposition Filter.
- If Enable for All Resource Paths is checked, try unchecking it and test whether PDFs open in a new tab.
- If you need to keep Enable for All Resource Paths checked, add the relevant PDF paths to Excluded Resource Paths and test again.
-
Adjust the Dispatcher configuration for the Publish tier.
Add or update the following rule to override the Content-Disposition header for PDF files:
code language-none Header unset Content-Disposition Header set Content-Disposition inline -
Reload the Dispatcher configuration and clear any relevant caches.
-
Clear the CDN and browser cache after making configuration changes to ensure the new headers are applied.
-
Test the PDF link by authoring a PDF link in the AEM Text component and verify that clicking the link opens the PDF in a new tab instead of downloading it.