Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Can I configure my dispatcher to inline PDFs?

Avatar

Level 2

Hi,

 

I want my pdfs to be inlined rather than downloaded. I found this suggestion:

 

<LocationMatch "\.(?i:pdf)$">

   ForceType application/pdf Header set Content-Disposition inline

</LocationMatch>

 

Which file do I add this to? I tried dispatcher_vhost.conf without success.

 

Thanks

Joel

 

 

8 Replies

Avatar

Community Advisor

Hi, 

I guess you are talking about this reference: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/apache-sling-content-dispo... Can you try to add this to your .vhost file, I guess you will have a file named like "yourBrand.vhost" 



Hope this helps



Esteban Bustamante

Avatar

Community Advisor

@joel_at_verb 

 

Please add it to the vhost file under conf.d/available_vhosts.

 

Also, assure that the "Content-Disposition" header allowed in farm file.


Aanchal Sikka

Avatar

Level 2

Hi @joel_at_verb ,

 

you can use something like this to ensure the inline value is always set. 

add this in the file dispatcher/src/conf.d/available_vhosts/<your_custom_project_vhost>.vhost 

<LocationMatch "\.(?i:pdf)$">
            Header unset "Content-Disposition"
            Header set Content-Disposition inline
    </LocationMatch>

 add this at last inside VirtualHost tag

Avatar

Community Advisor

@joel_at_verb Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community



Esteban Bustamante

Sorry for the delay. Just other priorities. No this did not work. But I am re-learning dispatcher.

The last answer appeared to be the best. Please give me time to evaluate and I will update.

 

I am hoping to have an update by the end of June at the latest.

 

-Joel

Avatar

Level 8

HI @joel_at_verb ,

To configure your Apache Dispatcher to inline PDFs instead of downloading them, you can indeed use the suggested configuration snippet you provided. However, you need to ensure that it's placed in the correct Apache configuration file.

Here's how you can do it:

  1. Locate Apache Configuration Files: Typically, the configuration files for Apache are located in /etc/apache2/ or /etc/httpd/ directory. Within this directory, there should be a configuration file for your virtual host, such as httpd.conf, vhosts.conf, or dispatcher_vhost.conf.

  2. Add Configuration Snippet: Open the appropriate Apache configuration file in a text editor and add the following lines:

 

<LocationMatch "\.(?i:pdf)$">
    ForceType application/pdf
    Header set Content-Disposition inline
</LocationMatch>

 

  1. Make sure you place this snippet within the <VirtualHost> section corresponding to your website or within a separate <IfModule disp_apache2.c> block if you're using Apache Dispatcher.

  2. Restart Apache: After saving the changes to the Apache configuration file, restart Apache to apply the new configuration. You can do this using the following command:

 

sudo systemctl restart apache2   # For systemd-based systems

 

  1. Replace apache2 with httpd if you're using a different distribution or init system.

  2. Test: Once Apache has been restarted, access a PDF file on your website to verify that it's now being served inline instead of being downloaded.

By adding the configuration snippet to the appropriate Apache configuration file and restarting Apache, you should be able to configure your Apache Dispatcher to inline PDFs. If you're unsure about the location of your Apache configuration files or encounter any issues, consult your server administrator or Apache documentation for further assistance.

Avatar

Administrator

@joel_at_verb Did you find the suggestions from users helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.



Kautuk Sahni

Avatar

Level 2

I will comment when we try. Been busy with other things.