Can I configure my dispatcher to inline PDFs? | Community
Skip to main content
Level 2
April 24, 2024

Can I configure my dispatcher to inline PDFs?

  • April 24, 2024
  • 6 replies
  • 1794 views

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

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

6 replies

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 24, 2024

Hi, 

I guess you are talking about this reference: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/apache-sling-content-disposition-filter/td-p/539510 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
aanchal-sikka
Community Advisor
Community Advisor
April 25, 2024

@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
chaudharynick
Level 4
April 25, 2024

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

EstebanBustamante
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
April 26, 2024

@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
Level 2
May 3, 2024

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

HrishikeshKagne
Community Advisor
Community Advisor
May 5, 2024

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.

Hrishikesh Kagane
kautuk_sahni
Community Manager
Community Manager
May 16, 2024

@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
Level 2
May 19, 2024

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