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

87 views Asked by At

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>
1

There are 1 answers

0
Alexander Schranz On BEST ANSWER

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