src/templates/pdf.html
<!DOCTYPE html>
<html lang='en'>
<head>
<style>{{ css|raw }}</style>
{{ useCjk ? '<style>td { font-family:sun-extA; }</style>' }}
</head>
<body {{ useCjk ? " style='font-family:sun-extA;'" }}>
<htmlpagefooter name='footer'>
{% if pdfSig %}
<div class='footer-block signatures'>
User's signature:<br><br>
Witness' name:<br><br>
Witness' signature:<br><br>
</div>
{% endif %}
<div class='footer-block footer'>
<p style='font-size:6pt;'>PDF generated with <a href='https://www.elabftw.net'>elabftw</a>, a free and open source lab notebook<br>
File generated on {DATE d-m-Y} at {DATE H:i}</p>
<p>{PAGENO} / {nb}</p>
</div>
</htmlpagefooter>
<div id='header'>
<h1>{{ entityData.title }}</h1>
<p>
{{ entityDate }}
<strong>{{ 'Date'|trans }}:</strong> {{ date }}<br>
{% if entityData.tags %}
{% set tags = entityData.tags|split('|') %}
<strong>{{ 'Tags'|trans }}:</strong>
{% for tag in tags %}
<span class='tag'>{{ tag }}</span>
{% endfor %}<br>
{% endif %}
{% if entityData.category_title %}
<strong>{{ 'Category'|trans }}:</strong> {{ entityData.category_title }}<br>
{% endif %}
{% if entityData.status_title %}
<strong>{{ 'Status'|trans }}:</strong> {{ entityData.status_title }}<br>
{% endif %}
<strong>{{ 'Created by'|trans }}:</strong> {{ entityData.fullname }}<br>
</p>
</div>
{{ body|raw }}
{% if entityData.metadata %}
<section class='no-break no-list-style'>
{{ entityData.metadata|formatMetadata }}
</section>
{% endif %}
{% if entityData.experiments_links %}
<section class='no-break'>
<h3>{% trans %}
Linked experiment
{% plural entityData.experiments_links|length %}
Linked experiments
{% endtrans %}</h3>
{% for link in entityData.experiments_links %}
<p class='pdf-ul'>
<span style='color:#{{ link.color }}'>{{ link.category }}</span> - <a href='{{ linkBaseUrl.experiments }}?mode=view&id={{ link.itemid }}'>{{ link.title }}</a>
</p>
{% endfor %}
</section>
{% endif %}
{% if entityData.items_links %}
<section class='no-break'>
<h3>{% trans %}
Linked item
{% plural entityData.items_links|length %}
Linked items
{% endtrans %}</h3>
{% for link in entityData.items_links %}
<p class='pdf-ul'>
<span style='color:#{{ link.color }}'>{{ link.category }}</span> - <a href='{{ linkBaseUrl.items }}?mode=view&id={{ link.itemid }}'>{{ link.title }}</a>
</p>
{% endfor %}
</section>
{% endif %}
{% if entityData.steps %}
<section class='no-break'>
<h3>{{ 'Steps'|trans }}</h3>
{% for step in entityData.steps %}
<p class='pdf-ul'>{{ step.body }}
{% if step.finished %} ({{ step.finished_time }}){% endif %}
</p>
{% endfor %}
</section>
{% endif %}
{% if includeFiles and entityData.uploads %}
<section class='no-break'>
<h3>{% trans %}
Attached file
{% plural entityData.uploads|length %}
Attached files
{% endtrans %}
</h3>
{% for upload in entityData.uploads %}
<p class='pdf-ul'>{{ upload.real_name }}
{# add a comment? don't add if it's the default text or if it's null #}
{% if upload.comment and upload.comment != 'Click to add a comment' %} ({{ upload.comment|nl2br }}){% endif %}
{# add hash? don't add if we don't have it #}
{% if upload.hash|length >= 32 %}<br>{{ upload.hash_algorithm }}: {{ upload.hash }}{% endif %}
{% if upload.base64_thumbnail %}
{# Note: adding charset to the data string makes it fail #}
<br><img class='attached-image' src='data:image/jpeg;base64,{{ upload.base64_thumbnail }}' alt='{{ upload.comment|e('html_attr') }}' />
{% endif %}
</p>
{% endfor %}
</section>
{% endif %}
{% if entityData.comments %}
<section class='no-break'>
<h3>{% trans %}
Comment
{% plural entityData.comments|length %}
Comments
{% endtrans %}
</h3>
{% for comment in entityData.comments %}
<p class='pdf-ul'>On {{ comment.datetime }} {{ comment.fullname }} wrote:<br>{{ comment.comment|nl2br }}</p>
{% endfor %}
</section>
{% endif %}
<div id='infoblock'>
<table class='noborder' role='presentation'>
<tr>
<td class='noborder'>
{# use raw here as this is an mpdf special tag and the url needs to be passed unmodified #}
<barcode code='{{ url|raw }}' type='QR' class='barcode' size='0.8' error='M' />
</td>
<td class='noborder'>
<p class='elabid'>{{ 'Unique eLabID:'|trans }} {{ entityData.elabid }}</p>
{% if locked %}
<p class='elabid'>Locked by {{ lockerName }} on {{ lockDate }}</p>
{% endif %}
<p class='elabid'>Link: <a href='{{ url }}'>{{ url }}</a></p>
</td>
</tr>
</table>
</div>
{% if includeChangelog %}
<h3 id='changelogHeader'>{{ 'Changelog'|trans }}</h3>
<table class='table' aria-labelledby='changelogHeader'>
<thead>
<tr>
<th>{{ 'Date'|trans }}</th>
<th>{{ 'User'|trans }}</th>
<th>{{ 'Property changed'|trans }}</th>
<th>{{ 'New value'|trans }}</th>
</tr>
</thead>
<tbody>
{% for change in changes %}
<tr>
<td>{{ change.created_at }}</td>
<td>{{ change.fullname }}</td>
<td>{{ change.target }}</td>
<td>
{# cannot use ternary here as it is an expression and filters are applied after evaluation #}
{%- if change.target == 'body' -%}
{# use of raw to make the link to revisions page work #}
{{ change.content|raw }}
{%- else -%}
{{ change.content }}
{%- endif -%}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}