# Format rendering of links to (local) pdf files?

**URL:** https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639
**Category:** Support
**Created:** [11 december 2019 om 10:30 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639 "2019-12-11T10:30:34Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [11 december 2019 om 10:30 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639/1 "2019-12-11T10:30:34Z")

</div>

Is there an easy way (e.g. via CSS) to change the way links to user-uploaded pdf files are shown?

Apparently, [pdf oneboxing is supported](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972/25) but I’m not sure [under what conditions](https://meta.discourse.org/t/oneboxing-of-pdfs-and-other-attachments/55972/24) this is supposed to work.

Anyway, I don’t intend to re-open the discussion about pdf-oneboxing but am rather looking for viable workarounds for displaying uploaded pdfs somewhat more prominently. Apparently, there was a [previous discussion on this](https://meta.discourse.org/t/custom-visualization-for-specific-attachment-types/14941/16), but it has been deleted.

A concrete example of a use case are posts created basen on a forwarded email. Here, if the email had a pdf document attached, it is easy to miss that as it appears as a simple link at the very bottom of the post, i.e. after the forwarded email’s signature, if any.

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [11 december 2019 om 19:31 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639/2 "2019-12-11T19:31:53Z")

</div>

As far as I know oneboxing will only work on externally linked PDFs, not uploaded ones.

With CSS you could do something like

```scss
a.attachment[href$=".pdf"] {
    color: red;
    &:before {
      // The attachment icon is added using a pseudo-selector 
     // so you'd need to edit its styles here
    }
}

```

This applies styles to links with the class `attachment` only if the `href` ends in `.pdf`

---

<div class="post-metadata">

### Author: ![tophee](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/tophee/32/73406_2.png) [@tophee](https://meta.discourse.org/u/tophee)
#### Post date: [13 december 2019 om 15:04 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639/3 "2019-12-13T15:04:01Z")

</div>

> [@awesomerobot](#):
>
> This applies styles to links with the class `attachment` only if the `href` ends in `.pdf`

And this excludes one-boxed pdf-links, right? In other words: the CSS code affects only local pdfs?

---

<div class="post-metadata">

### Author: ![awesomerobot](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/awesomerobot/32/142900_2.png) [@awesomerobot](https://meta.discourse.org/u/awesomerobot)
#### Post date: [13 december 2019 om 15:17 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639/4 "2019-12-13T15:17:31Z")

</div>

Correct, the oneboxes don’t have the `attachment` class, so it shouldn’t impact those.

---

<div class="post-metadata">

### Author: ![osioke](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/osioke/32/238946_2.png) [@osioke](https://meta.discourse.org/u/osioke)
#### Post date: [14 juli 2020 om 08:25 UTC](https://meta.discourse.org/t/format-rendering-of-links-to-local-pdf-files/135639/5 "2020-07-14T08:25:47Z")

</div>

And now there is a theme component that helps too @tophee 😉

> [@Inline PDF Previews](https://meta.discourse.org/t/inline-pdf-previews/157649):
>
> discourse2Summary Inline PDF Previews is a desktop-only theme component that will allow you to create previews for pdf attachments.eyeglassesPreview [Preview on Discourse Theme Creator](https://discourse.theme-creator.io/theme/Discourse/inline-pdf-previews) (desktop only)hammer_and_wrenchRepository Link [https://github.com/discourse/discourse-pdf-previews](https://github.com/discourse/discourse-pdf-previews)open_bookNew to Discourse Themes? [Beginner’s guide to using Discourse Themes](https://meta.discourse.org/t/beginners-guide-to-using-discourse-themes/91966) Install this theme component Features before after …
