- Why he generate the PDF again and again when nothing changes? Is there a hidden option for that?
- I tried to use it with the Google Font
Rubik
but no chance. Any Ideas? - Is it possible to Save the generated PDF in an Asset field to the Post?
I've a preparse Field at the Moment but I've nothing what I can prompt if it's exist or not. He also regenerate the PDF on every Save. No cool :/
Here is my Preparse Field
{% spaceless %}
{% if not entry.preparsePrintmakerCertificate|length %}
{% set html %}
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<style>
@page {
margin: 0in;
}
@font-face {
font-family: 'Rubik Webfont';
src: url('/assets/fonts/Rubik-Black.ttf') format('truetype');
font-weight: 900;
font-style: normal;
}
body {
font-family: "Rubik Webfont", sans-serif;
font-weight: 900;
margin: 0;
padding: 0;
font-size: 160px;
line-height: 1;
width: 100%;
height: 100%;
position: relative;
color: #2e3743;
text-transform: uppercase;
letter-spacing: -6px;
background-image: url('/assets/images/bitmap/printmaker/certificate_background.png');
}
.background {
position: fixed;
width: 100%;
height: 100%;
left: 0;
right: 0;
top: 0;
bottom: 0;
}
.name {
position: fixed;
width: 1000px;
left: 356px;
top: 2764px;
}
.date {
position: fixed;
width: 900px;
left: 356px;
top: 4318px;
}
</style>
</head>
<body>
<div class="background">
<div class="name">
{{ entry.title }}
</div>
<div class="date">
<span class="month">{{ entry.postDate.format('M') }}</span>
<span class="day">{{ entry.postDate.format('d') }}</span><br/>
<span class="year">{{ entry.postDate.format('Y') }}</span>
</div>
</div>
</body>
</html>
{% endset %}
{% set settings = {
filename : 'bestwebsite-gallery_sotd_' ~ entry.postDate.format('Y-m-d') ~ '_' ~ entry.slug|kebab
} %}
{% set pdfUrl = craft.printmaker.pdfFromHtml(html, settings).url %}
{{ pdfUrl }}
{% endif %}
{% endspaceless %}