Tools
To create the exact visuals for a new PDF, it is highly recommended to use the ink PDF Prototyper (only available in demo environments). The tool includes its own docs, instructions for use, and example PDF layouts and visuals.
Prince is what we use to create our PDFs. It converts HTML and CSS in Django templates to PDF.
Our print kit is located in carta-web/static/lib/eshares/css/print/pdf_kit.scss
./manage.py collectstatic
and type yes
when promptedCreate a new prince file and add this to your body.prince
:
<!DOCTYPE html><html><head><meta charset="utf-8" /><meta http-equiv="X-UA-Compatible" content="IE=edge" /><title>{{ file_name }}</title><link rel="stylesheet" href="static_files/lib/eshares/css/pdf_kit.css" charset="utf-8" />{% stylesheet 'pdf_kit' %}</head><body>// your code here</body></html>
Basic styling for PDFs will create a page that looks like this:
class='page'
for the page divclass='title'
for the page titleclass='subtitle'
for the subtitle<div class="page page__cover"><StaticImage style="width: 150px" src="{{ image_src }}" alt="img alt" /><h1 class="title">{{ title }}</h1><h2 class="subtitle">{{ subtitle }}</h2><h4>For the period {{ begin_date }} - {{ end_date }}</h4></div>
For page headers and footers, see the Settings
tab in the prototype tool for options.
Most tables will not need any extra classes. Use the html tags table
, thead
, tbody
, tr
, th
, and td
to build one
col\_\_x
classes on the <td>
class='text-right'
on the <td>
For table titles, use a h3
along side a <table>
like this:
<h3>Capital account summary</h3><table><thead><tr><th>Table header</th></tr></thead><tbody><tr><td>Table cell</td></tr></tbody></table>
Reach out on the #ink channel on Slack if you have questions regarding PDFs :)
Is this page helpful?