Serve PDF file at url with variable Is it possible to serve a file in a Twig template? I need to get a file (asset) from a global setting, and serve it at a particular URL.

This code is close, but it seems that source() is the wrong method to get the file contents with.

{% header "Content-type: application/pdf" %}
{% header "Content-Disposition: inline" %}

{% set filePath = [craft.config.environmentVariables.assetPath, filesImages.deliveryCalendar[0].filename]|join('') %}

{{ source( filePath ) }}


The variable filePath contains the correct system path to the file (/var/www/site.com/html/assets/file.pdf), but source() is clearly for templates and not files.

How can the contents of a file be streamed out to the browser?
You'd need to make a simple Craft plugin that added a Twig filter/function that wrapped PHP's file_get_contents to grab the file contents, but at that point, you might as well just make it a wrapper for craft()->request->sendFile().