symfonypdfbrowsercontent-management-systemsulu

How to Display a Document (PDF) in the Browser with Sulu CMS


Is there a simple way to Display a Document like a PDF that was included with the media_selection type. I want it to be displayed in the browser. Maybe I just didn´t saw it the documentation.

I can download the file with my current setup:

document.xml:

            <meta>
                <title lang="en">Document</title>
                <title lang="de">Document</title>
            </meta>
        </property>

document.html.twig:

<ul>
        {% for document in content.documents %}
            <li>
                <a href="{{ document.url }}">
                    {{ document.title }}
                </a>
            </li>
        {% endfor %}
    </ul>

Solution

  • You can force another Disposition Type by using the following twig extension or general configure PDF to be inlined instead of downloaded.

    See https://docs.sulu.io/en/2.5/reference/twig-extensions/functions/sulu_get_media_url.html