Generating PDF Documents

PDF documents are generated using a text format called RML (ReportLab Markup Language). A reference for this language can be found on the ReportLab site.

This example document generates a simple PDF file. The RML format provides facilities for tables and other layout options. Please see the references above for more examples.

<!DOCTYPE document SYSTEM "rml.dtd">
<document filename="annotate.pdf">
    <template title="Simple Annotate"
              author="{{ user.username }}">
        <pageTemplate id="main">
            <frame id="first" x1="2cm" y1="2cm" width="17cm" height="26cm"/>
        </pageTemplate>
    </template>

    <stylesheet>
    </stylesheet>
    <story>
        <h1>Annotate for {{draft.DraftName}}</h1>
        <para>{{ settings.get('preamble','No Preamble has been set') }}</para>
        <!--
             Decide whether to include forms based on the setting value called "do_forms"
             with a default of True
        -->
        {% if settings.get('do_forms', True) %}

            <!--
                 Loop through all the forms in the Draft, ordering the Forms by the "form_order setting
                 with a default of by "OID". This value must match one of the attributes of Forms
                 (OID, DraftFormName, Ordinal etc - see reference)
            -->

            {% for form in draft.als_forms_set.all().order_by(settings.get('form_order','OID')) %}
            <h2>{{ form.DraftFormName }}</h2>
            {% endfor %}
        {% endif %}
    </story>
</document>