2

I have managed to get Printmaker up & running, spitting out images, entry data, tags etc. However I cannot style the output.

I have built up a template which has a html structure and links to an internal (same domain) CSS file. However the outputted style is browser-default sans serif text and no styling whatsoever.

Here is my template code:

<html class="" lang="en-gb">
    <head>
        <link rel="stylesheet" href="/css/templates.css">
    </head>

<body>

    <div class="wrapper">

            <section class="page">

              // Page content here...

I have tried the .pdfFromTemplate method:

{% set vars = {
    entry: entry
} %}
{% set settings = { 
    orientation : 'portrait',
    filename: entry.slug,
    cacheDirectory: 'pdf/' ~ craft.request.getSegment(1) ~ '/' ~ craft.request.getSegment(2)
} %}
{% set pdfUrl = craft.printmaker.pdfFromTemplate('technical-information/_pdf', vars, settings).url %}

And also the .pdfFromHtml way, too:

{% set html %}
    {{ include('technical-information/_pdf') }}
{% endset %}
{% set settings = { 
    orientation : 'portrait',
    filename: entry.slug,
    cacheDirectory: 'pdf/' ~ craft.request.getSegment(1) ~ '/' ~ craft.request.getSegment(2)
} %}
{% set pdfUrl = craft.printmaker.pdfFromHtml(html, settings).url %}
1
  • Does Printmaker require CSS style to be inline, or even inline within <style> tags in the head of the document? Or does it allow linking to stylesheets? Aug 30 '16 at 8:50
2

I've had this same problem getting Printmaker use an external stylesheet.

Simply putting the styles in the head of the template sorted it out.

You could also try setting the path to your css with a . like so;

<link href="./path/to/styles.css" rel="stylesheet" type="text/css">

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.