<p>You can link to the CSS in this way, but if it's not working for you then try changing the path to</p>

<pre><code>&lt;link href="./pdf.css" rel="stylesheet" type="text/css"&gt;
</code></pre>

<p>assuming that your CSS is in the site root.</p>

CC BY-SA 4.0
2018-09-30T19:59:13.477Z
Yes. That does it.
seth
CC BY-SA 4.0
2018-09-30T20:01:38.823Z
An include in the head works as well:

`<head><style type="text/css">{% include '_includes/_pdf/pdf.css' %}</style></head>`
seth
CC BY-SA 4.0
2018-09-30T16:53:53.187Z
2018-09-30T16:53:53.187Z
foamcow
<p>Similar to this issue <a href="https://craftcms.stackexchange.com/questions/16567/render-styled-output-using-printmaker-plugin">Render styled output using Printmaker plugin</a></p>

<p>I am having the same issue and can't seem to figure out how to style the PDF.</p>

<p>Here is my code to generate the PDF:</p>

<pre><code>    {% set html %}
        {% include '_includes/_pdf/social.twig' %}
    {% endset %}

    {% set pdfUrl = craft.printmaker.pdfFromHtml(html).url %}

    &lt;a href="{{ pdfUrl }}" target="_blank"&gt;Print Page&lt;/a&gt;
</code></pre>

<p>This opens the PDF in a separate tab.</p>

<p>and then I am loading <code>pdf.css</code> into the head of <code>_includes/_pdf/social.twig</code> but the PDF is not styled.</p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html lang="en" dir="ltr"&gt;
    &lt;head&gt;
        &lt;meta charset="utf-8"&gt;
        &lt;title&gt;PDF Template&lt;/title&gt;
        &lt;link href="pdf.css" rel="stylesheet" type="text/css"&gt;
    &lt;/head&gt;
    &lt;body&gt;

        // PDF HTML

    &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and here is my directory structure</p>

<pre><code>_includes
    _pdf
        pdf.css
        social.twig
</code></pre>

<p>Is it possible to style the PDF this way or do I need to use <code>&lt;style&gt;</code> tag or inline styles?</p>

<craft2><plugin-printmaker>
Trying to style Printmaker Plugin PDF by linking css in head of PDF template
# Trying to style Printmaker Plugin PDF by linking css in head of PDF template

(Asked by: username_0 on 2018-09-30)

Similar to this issue Render styled output using Printmaker plugin
I am having the same issue and can't seem to figure out how to style the PDF.
Here is my code to generate the PDF:
    {% set html %}
        {% include '_includes/_pdf/social.twig' %}
    {% endset %}

    {% set pdfUrl = craft.printmaker.pdfFromHtml(html).url %}

    Print Page

This opens the PDF in a separate tab.
and then I am loading pdf.css into the head of _includes/_pdf/social.twig but the PDF is not styled.


    
        
        PDF Template
        
    
    

        // PDF HTML

    


and here is my directory structure
_includes
    _pdf
        pdf.css
        social.twig

Is it possible to style the PDF this way or do I need to use

**Tags:** craft2, plugin-printmaker

---

## 1 answers

### Answer by username_1 on 2018-09-30. Score: 1 | Accepted answer

You can link to the CSS in this way, but if it's not working for you then try changing the path to


assuming that your CSS is in the site root.

> **Comments:**
> **username_0**: Yes. That does it.  
> **username_0**: An include in the head works as well:  `<head><style type="text/css">{% include '_includes/_pdf/pdf.css' %}</style></head>`  

---

