|
1 |
| -CUSTOM TEMPLATE HERE |
| 1 | +{# This is an example template for customizing the HTML2PDF export of your StrictDoc documents. |
| 2 | +
|
| 3 | +Notes: |
| 4 | +
|
| 5 | +- This template is interpreted in a environment without loader, therefore it is not possible |
| 6 | + to use jinja extend or include directives. The template must be fully self-contained. |
| 7 | +
|
| 8 | +- To use Images, place them in the same folder as this template file. They will be included in the |
| 9 | + HTML export under "/_static/html2pdf_template/. As the user can constomize the static asset path, |
| 10 | + it is necessary to use the link renderer's to get the full URL to an image. |
| 11 | + |
| 12 | + For example: |
| 13 | + |
| 14 | + <img src="{{ view_object.render_static_url('html2pdf_template/logo_top_page.png') }}"> |
| 15 | +
|
| 16 | +#} |
| 17 | + |
| 18 | +{# customize the front page ---------------------------------------------------------------------------- #} |
| 19 | + |
| 20 | +<style html2pdf-frontpage-style> |
| 21 | +.html2pdf-frontpage-grid { |
| 22 | + display: grid; |
| 23 | + height: 100%; |
| 24 | +} |
| 25 | +.html2pdf-frontpage-grid-middle { |
| 26 | + display: flex; |
| 27 | + align-items: center; |
| 28 | + justify-content: center; |
| 29 | + text-align: center; |
| 30 | +} |
| 31 | +.html2pdf-frontpage-grid-bottom { |
| 32 | + display: flex; |
| 33 | + justify-content: center; |
| 34 | + align-items: flex-end; |
| 35 | +} |
| 36 | +</style> |
| 37 | +<template html2pdf-frontpage> |
| 38 | + {#- add here frontpage html -#} |
| 39 | + <div class="html2pdf-frontpage-grid"> |
| 40 | + <div class="html2pdf-frontpage-grid-top"> </div> |
| 41 | + <div class="html2pdf-frontpage-grid-middle"> |
| 42 | + <h1 data-testid="document-title"> |
| 43 | + <img src="{{ view_object.render_static_url('html2pdf_template/logo_top_page.png') }}" |
| 44 | + alt="Company Logo" |
| 45 | + style="width: 80%" /> |
| 46 | + <br> |
| 47 | + <br> |
| 48 | + {{ view_object.document.title }}</h1> |
| 49 | + </div> |
| 50 | + <div class="html2pdf-frontpage-grid-bottom"> |
| 51 | +{%- if view_object.document.config.has_meta() -%} |
| 52 | + <sdoc-meta> |
| 53 | + {%- if view_object.document.config.uid -%} |
| 54 | + <sdoc-meta-label data-testid="document-config-uid-label">UID:</sdoc-meta-label> |
| 55 | + <sdoc-meta-field data-testid="document-config-uid-field"> |
| 56 | + {%- with field_content = view_object.document.config.uid %} |
| 57 | + <sdoc-autogen>{{ field_content }}</sdoc-autogen> |
| 58 | + {%- endwith -%} |
| 59 | + </sdoc-meta-field> |
| 60 | + {%- endif -%} |
| 61 | + |
| 62 | + {% set document_version_ = view_object.render_document_version() %} |
| 63 | + {%- if document_version_ is not none -%} |
| 64 | + <sdoc-meta-label data-testid="document-config-version-label">VERSION:</sdoc-meta-label> |
| 65 | + <sdoc-meta-field data-testid="document-config-version-field"> |
| 66 | + {%- with field_content = document_version_ %} |
| 67 | + <sdoc-autogen>{{ field_content }}</sdoc-autogen> |
| 68 | + {%- endwith -%} |
| 69 | + </sdoc-meta-field> |
| 70 | + {# FIXME: Task #1229 / Uncomment example when validation logic is implemented: #} |
| 71 | + {# |
| 72 | + {% with issue_field_name = 'meta' %} |
| 73 | + <div id="field_issue_ID" class="field_issue"> |
| 74 | + <div class="field_issue-ribbon"> |
| 75 | + <b>Warning:</b> '{{ issue_field_name }}' field has issue: description in details |
| 76 | + </div> |
| 77 | + </div> |
| 78 | + {% endwith %} |
| 79 | + #} |
| 80 | + {%- endif -%} |
| 81 | + |
| 82 | + {% set document_date_ = view_object.render_document_date() %} |
| 83 | + {%- if document_date_ is not none -%} |
| 84 | + <sdoc-meta-label data-testid="document-config-version-label">DATE:</sdoc-meta-label> |
| 85 | + <sdoc-meta-field data-testid="document-config-version-field"> |
| 86 | + {%- with field_content = document_date_ %} |
| 87 | + <sdoc-autogen>{{ field_content }}</sdoc-autogen> |
| 88 | + {%- endwith -%} |
| 89 | + </sdoc-meta-field> |
| 90 | + {%- endif -%} |
| 91 | + |
| 92 | + {%- if view_object.document.config.classification -%} |
| 93 | + <sdoc-meta-label data-testid="document-config-classification-label">CLASSIFICATION:</sdoc-meta-label> |
| 94 | + <sdoc-meta-field data-testid="document-config-classification-field"> |
| 95 | + {%- with field_content = view_object.document.config.classification %} |
| 96 | + <sdoc-autogen>{{ field_content }}</sdoc-autogen> |
| 97 | + {%- endwith -%} |
| 98 | + </sdoc-meta-field> |
| 99 | + {%- endif -%} |
| 100 | + </sdoc-meta> |
| 101 | +{%- endif -%} |
| 102 | + </div> |
| 103 | + </div> |
| 104 | +</template> |
| 105 | + |
| 106 | + |
| 107 | +{# customize the page header ---------------------------------------------------------------------------- #} |
| 108 | + |
| 109 | +<style html2pdf-header-style> |
| 110 | +html2pdf-header { |
| 111 | + padding-top: 0; |
| 112 | +} |
| 113 | +.html2pdf-header { |
| 114 | + display: flex; |
| 115 | + justify-content: space-between; |
| 116 | + align-items: flex-end; |
| 117 | + column-gap: 32px; |
| 118 | + font-size: small; |
| 119 | + line-height: 1; |
| 120 | + color: rgba(0,0,0,0.5); |
| 121 | + border-bottom: 1px solid rgba(0,0,0,0.25); |
| 122 | + padding-bottom: 8px; |
| 123 | +} |
| 124 | +.html2pdf-header-left { |
| 125 | + text-align: left; |
| 126 | + flex-shrink: 0; |
| 127 | +} |
| 128 | +.html2pdf-header-right { |
| 129 | + text-align: right; |
| 130 | + font-weight: bold; |
| 131 | +} |
| 132 | +</style> |
| 133 | +<template html2pdf-header> |
| 134 | + {#- uncomment html2pdf-page-number to print page numbers: -#} |
| 135 | + {#- <div html2pdf-page-number> |
| 136 | + <span html2pdf-page-number-current></span>/<span html2pdf-page-number-total></span> |
| 137 | + </div> -#} |
| 138 | + |
| 139 | + {#- add here header html: -#} |
| 140 | + <div class="html2pdf-header"> |
| 141 | + <div class="html2pdf-header-left">{{ view_object.document.title }}</div> |
| 142 | + <div class="html2pdf-header-right"> |
| 143 | + <img src="{{ view_object.render_static_url('html2pdf_template/logo_top_page.png') }}" |
| 144 | + alt="Company Logo" |
| 145 | + style="height: 20px;" /> |
| 146 | + </div> |
| 147 | + </div> |
| 148 | +</template> |
| 149 | + |
| 150 | + |
| 151 | +{# customize the page footer ---------------------------------------------------------------------------- #} |
| 152 | + |
| 153 | +<style html2pdf-footer-style> |
| 154 | +html2pdf-footer { |
| 155 | + padding-bottom: 0; |
| 156 | +} |
| 157 | +.html2pdf-footer { |
| 158 | + display: flex; |
| 159 | + justify-content: space-between; |
| 160 | + column-gap: 16px; |
| 161 | + font-size: small; |
| 162 | + line-height: 1; |
| 163 | + color: rgba(0,0,0,0.5); |
| 164 | + border-top: 1px solid rgba(0,0,0,0.25); |
| 165 | + padding-top: 8px; |
| 166 | +} |
| 167 | +.html2pdf-footer-left { |
| 168 | + text-align: left; |
| 169 | +} |
| 170 | +.html2pdf-footer-right { |
| 171 | + text-align: right; |
| 172 | +} |
| 173 | +.html2pdf-header-page_placeholder { |
| 174 | + width: 54px; /* max for pattern 888/888 */ |
| 175 | + flex-shrink: 0; |
| 176 | + text-indent: -10000px; |
| 177 | +} |
| 178 | +</style> |
| 179 | +<template html2pdf-footer> |
| 180 | + {#- uncomment html2pdf-page-number to print page numbers: -#} |
| 181 | + <div html2pdf-page-number> |
| 182 | + <span html2pdf-page-number-current></span>/<span html2pdf-page-number-total></span> |
| 183 | + </div> |
| 184 | + {#- add here footer html -#} |
| 185 | + <div class="html2pdf-footer"> |
| 186 | + <div class="html2pdf-footer-left">{{ view_object.date_today() }}</div> |
| 187 | + <div class="html2pdf-footer-right">ACME Laboratories Inc. {{view_object.document.config.classification}}</div> |
| 188 | + <div class="html2pdf-header-page_placeholder">{#- must be left empty! -#}</div> |
| 189 | + </div> |
| 190 | +</template> |
0 commit comments