<p>What do you mean by 'display the asset'? Showing a thumbnail is not an option, because no thumbs are made for PDF files. If you'd want to show the filename, for example, use the <a href="http://buildwithcraft.com/docs/templating/assetfilemodel#filename" rel="nofollow">filename</a> property of the asset.</p>

<p>If the page contains multiple entries, you'd have to loop through the entries first. Then, for each entry, check if it has an asset in the desired field (by using <code>| length</code>, after which you can display the asset.</p>

<pre><code>{% for entry in craft.entries.section('bla').relatedTo('bla') %}
    {% if entry.dataCard | length %}
        {% set asset = entry.dataCard.first() %}
        &lt;a href="{{ asset.url }}"&gt;{{ asset.filename }}&lt;/a&gt;
    {% endif %}
{% endfor %}
</code></pre>

CC BY-SA 3.0
2015-05-07T12:21:37.023Z
FYI - you _can_ use [PThumb](https://github.com/carnesmedia/pthumb) or [pdfthumbnails](https://github.com/johndryan/pdfthumbnails) if your server supports ImageMagick. This allows you to create thumbnails for PDFs.
crawf
CC BY-SA 3.0
2015-05-06T17:52:50.367Z
2015-05-06T17:52:50.367Z
Paul
<p>I have an asset field (dataCard) which I use to upload a single PDF file tied to an entry. I'm trying, unsuccessfully, to display the asset tied to the entry on a page listing multiple entries. How would I do this? This is what I have so far:</p>

<pre><code>{% set asset = entry.dataCard.first() %}

{% if asset %}
    &lt;a href="{{ asset.url }}"&gt;{{category.title}}&lt;/a&gt;
{% endif %}
</code></pre>

<templating><entries><assets>
How do you display a file asset (PDF) in the template?
# How do you display a file asset (PDF) in the template?

(Asked by: username_0 on 2015-05-06)

I have an asset field (dataCard) which I use to upload a single PDF file tied to an entry. I'm trying, unsuccessfully, to display the asset tied to the entry on a page listing multiple entries. How would I do this? This is what I have so far:
{% set asset = entry.dataCard.first() %}

{% if asset %}
    {{category.title}}
{% endif %}

**Tags:** templating, entries, assets

---

## 1 answers

### Answer by username_1 on 2015-05-06. Score: 2 | Accepted answer

What do you mean by 'display the asset'? Showing a thumbnail is not an option, because no thumbs are made for PDF files. If you'd want to show the filename, for example, use the filename property of the asset.
If the page contains multiple entries, you'd have to loop through the entries first. Then, for each entry, check if it has an asset in the desired field (by using | length, after which you can display the asset.
{% for entry in craft.entries.section('bla').relatedTo('bla') %}
    {% if entry.dataCard | length %}
        {% set asset = entry.dataCard.first() %}
        {{ asset.filename }}
    {% endif %}
{% endfor %}

> **Comments:**
> **username_2**: FYI - you _can_ use [PThumb](https://github.com/carnesmedia/pthumb) or [pdfthumbnails](https://github.com/johndryan/pdfthumbnails) if your server supports ImageMagick. This allows you to create thumbnails for PDFs.  

---

