idea-html2pdf
Advanced tools
Comparing version 2.0.6 to 2.0.7
@@ -105,2 +105,2 @@ /// <reference types="node" /> | ||
} | ||
export declare const PDF_DEFAULT_TEMPLATE = "\n <!DOCTYPE html>\n <html>\n\n <head>\n <meta charset=\"utf8\" />\n <title>\n PDF template\n </title>\n <link href=\"https://fonts.googleapis.com/css?family=Lato\" rel=\"stylesheet\">\n <style>\n html,\n body {\n margin: 0;\n padding: 0;\n font-size: 10pt;\n font-family: 'Lato', Arial, Helvetica, sans-serif;\n }\n\n table {\n width: 100%;\n table-layout: fixed;\n font-size: 1rem;\n }\n\n table,\n tr,\n td {\n margin: 0;\n padding: 0;\n border-spacing: 0;\n border-collapse: collapse;\n vertical-align: middle;\n }\n\n .dontBreak {\n page-break-inside: avoid !important;\n }\n .pageBreak {\n page-break-after: always;\n }\n\n table.border td {\n border: 1px solid #eee;\n }\n\n td > p {\n margin: 0;\n padding: 0;\n }\n\n .normalRow td {\n padding: 6px 8px;\n letter-spacing: -0.2px;\n }\n\n td .label {\n display: block;\n font-size: 0.8rem;\n font-weight: bold;\n color: #555;\n }\n\n .headerTable {\n margin-top: 20px;\n page-break-inside: avoid;\n }\n .headerTable::after {\n /* trick to avoid a page break right after the header */\n content: \"-\";\n color: white;\n display: block;\n height: 150px;\n margin-bottom: -150px;\n }\n .headerTitle {\n padding: 4px 8px;\n background-color: #444;\n border: 1px solid transparent;\n border-radius: 5px;\n font-size: 0.9rem;\n font-weight: 500;\n color: white;\n }\n\n .numericField {\n text-align: right;\n }\n .checkbox {\n width: 12px;\n padding-top: 2px;\n }\n </style>\n </head>\n\n <body>\n\n <!-- PDF TEMPLATE BEGIN -->\n\n <div class=\"pdfTemplate\">\n {{#each _template as |section|}}\n {{! page break }}\n {{#ifEqual section.type 0}}\n <div class=\"pageBreak\"></div>\n {{/ifEqual}}\n {{! empty row }}\n {{#ifEqual section.type 1}}\n <br />\n {{/ifEqual}}\n {{! row }}\n {{#ifEqual section.type 2}}\n <table class=\"normalRow dontBreak {{#if row.border}}border{{/if}}\">\n <tr>\n {{#each section.columns as |content|}}\n {{#if content}}\n {{#if (doesColumnContainAField section @index)}}{{! field (that may be repeated for more cols) }}\n {{#with content as |field|}}\n {{! simple field }}\n {{#if field.code}}\n <td\n colspan=\"{{getColumnFieldSize section @index}}\"\n class=\"{{#if (isFieldANumber _data field.code)}}numericField{{/if}}\"\n >\n <span class=\"label\">\n {{translate (label field.label)}} \n </span>\n {{#if (isFieldABoolean _data field.code)}}\n {{#if (get _data field.code)}}\n <img\n class=\"checkbox\"\n src=\"https://s3.eu-west-2.amazonaws.com/scarlett-app/assets/icons/check-true.png\"\n />\n {{else}}\n <img\n class=\"checkbox\"\n src=\"https://s3.eu-west-2.amazonaws.com/scarlett-app/assets/icons/check-false.png\"\n />\n {{/if}}\n {{else}}\n {{mdToHTML (translate (getOrDash _data field.code))}}\n {{/if}}\n </td>\n {{! complext field }}\n {{else}}\n <td colspan=\"{{getColumnFieldSize section @index}}\">\n {{#ifEqual 12 (getColumnFieldSize section @index)}}\n {{! no extra spacing }}\n {{else}}\n <span class=\"label\"> </span>\n {{/ifEqual}}\n {{mdToHTML (substituteVars _data (translate (label field.content)))}}\n </td>\n {{/if}}\n {{/with}}\n {{/if}}\n {{else}}\n {{! empty col }}\n <td colspan=\"1\"></td>\n {{/if}}\n {{/each}}\n </tr>\n </table>\n {{/ifEqual}}\n {{! header }}\n {{#ifEqual section.type 3}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{mdToHTML (substituteVars _data (translate (label section.title)))}}\n </td>\n </tr>\n </table>\n {{/ifEqual}}\n {{! inner section }}\n {{#ifEqual section.type 4}}\n {{#if (get _data section.context)}}\n {{#if (label section.title)}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{translate (label section.title)}}\n </td>\n </tr>\n </table>\n {{/if}}\n {{inception section.innerTemplate (get _data section.context)}}\n {{/if}}\n {{/ifEqual}}\n {{! repeated inner section }}\n {{#ifEqual section.type 5}}\n {{#with (get _data section.context) as |innerSections|}}\n {{#if innerSections.length}}\n {{#if (label section.title)}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{translate (label section.title)}}\n </td>\n </tr>\n </table>\n {{/if}}\n {{/if}}\n {{#each innerSections as |innerSection|}}\n {{inception section.innerTemplate innerSection}}\n {{/each}}\n {{/with}}\n {{/ifEqual}}\n {{/each}}\n </div>\n\n </body>\n\n </html>\n"; | ||
export declare const PDF_DEFAULT_TEMPLATE = "\n <!DOCTYPE html>\n <html>\n\n <head>\n <meta charset=\"utf8\" />\n <title>\n PDF template\n </title>\n <link href=\"https://fonts.googleapis.com/css?family=Lato\" rel=\"stylesheet\">\n <style>\n html,\n body {\n margin: 0;\n padding: 0;\n font-size: 10pt;\n font-family: 'Lato', Arial, Helvetica, sans-serif;\n }\n\n table {\n width: 100%;\n table-layout: fixed;\n font-size: 1rem;\n }\n\n table,\n tr,\n td {\n margin: 0;\n padding: 0;\n border-spacing: 0;\n border-collapse: collapse;\n vertical-align: middle;\n }\n\n .dontBreak {\n page-break-inside: avoid !important;\n }\n .pageBreak {\n page-break-after: always;\n }\n\n table.border td {\n border: 1px solid #eee;\n }\n\n td > p {\n margin: 0;\n padding: 0;\n }\n\n .normalRow td {\n padding: 6px 8px;\n letter-spacing: -0.2px;\n }\n\n td .label {\n display: block;\n font-size: 0.8rem;\n font-weight: bold;\n color: #555;\n }\n\n .headerTable {\n margin-top: 20px;\n page-break-inside: avoid;\n }\n .headerTable::after {\n /* trick to avoid a page break right after the header */\n content: \"-\";\n color: white;\n display: block;\n height: 150px;\n margin-bottom: -150px;\n }\n .headerTitle {\n padding: 4px 8px;\n background-color: #444;\n border: 1px solid transparent;\n border-radius: 5px;\n font-size: 0.9rem;\n font-weight: 500;\n color: white;\n }\n\n .numericField {\n text-align: right;\n }\n .checkbox {\n width: 12px;\n padding-top: 2px;\n }\n </style>\n </head>\n\n <body>\n\n <!-- PDF TEMPLATE BEGIN -->\n\n <div class=\"pdfTemplate\">\n {{#each _template as |section|}}\n {{! page break }}\n {{#ifEqual section.type 0}}\n <div class=\"pageBreak\"></div>\n {{/ifEqual}}\n {{! empty row }}\n {{#ifEqual section.type 1}}\n <br />\n {{/ifEqual}}\n {{! row }}\n {{#ifEqual section.type 2}}\n <table class=\"normalRow dontBreak {{#if row.border}}border{{/if}}\">\n <tr>\n {{#each section.columns as |content|}}\n {{#if content}}\n {{#if (doesColumnContainAField section @index)}}{{! field (that may be repeated for more cols) }}\n {{#with content as |field|}}\n {{! simple field }}\n {{#if field.code}}\n <td\n colspan=\"{{getColumnFieldSize section @index}}\"\n class=\"{{#if (isFieldANumber _data field.code)}}numericField{{/if}}\"\n >\n <span class=\"label\">\n {{translate (label field.label)}} \n </span>\n {{#if (isFieldABoolean _data field.code)}}\n {{#if (get _data field.code)}}\n <img\n class=\"checkbox\"\n src=\"https://s3.eu-west-2.amazonaws.com/scarlett-app/assets/icons/check-true.png\"\n />\n {{else}}\n <img\n class=\"checkbox\"\n src=\"https://s3.eu-west-2.amazonaws.com/scarlett-app/assets/icons/check-false.png\"\n />\n {{/if}}\n {{else}}\n {{mdToHTML (translate (getOrNewLine _data field.code))}}\n {{/if}}\n </td>\n {{! complext field }}\n {{else}}\n <td colspan=\"{{getColumnFieldSize section @index}}\">\n {{#ifEqual 12 (getColumnFieldSize section @index)}}\n {{! no extra spacing }}\n {{else}}\n <span class=\"label\"> </span>\n {{/ifEqual}}\n {{mdToHTML (substituteVars _data (translate (label field.content)))}}\n </td>\n {{/if}}\n {{/with}}\n {{/if}}\n {{else}}\n {{! empty col }}\n <td colspan=\"1\"></td>\n {{/if}}\n {{/each}}\n </tr>\n </table>\n {{/ifEqual}}\n {{! header }}\n {{#ifEqual section.type 3}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{mdToHTML (substituteVars _data (translate (label section.title)))}}\n </td>\n </tr>\n </table>\n {{/ifEqual}}\n {{! inner section }}\n {{#ifEqual section.type 4}}\n {{#if (get _data section.context)}}\n {{#if (label section.title)}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{translate (label section.title)}}\n </td>\n </tr>\n </table>\n {{/if}}\n {{inception section.innerTemplate (get _data section.context)}}\n {{/if}}\n {{/ifEqual}}\n {{! repeated inner section }}\n {{#ifEqual section.type 5}}\n {{#with (get _data section.context) as |innerSections|}}\n {{#if innerSections.length}}\n {{#if (label section.title)}}\n <table class=\"headerTable\">\n <tr>\n <td class=\"headerTitle\">\n {{translate (label section.title)}}\n </td>\n </tr>\n </table>\n {{/if}}\n {{/if}}\n {{#each innerSections as |innerSection|}}\n {{inception section.innerTemplate innerSection}}\n {{/each}}\n {{/with}}\n {{/ifEqual}}\n {{/each}}\n </div>\n\n </body>\n\n </html>\n"; |
@@ -69,2 +69,3 @@ "use strict"; | ||
getOrDash: (context, x) => (context[x] !== null && context[x] !== undefined ? context[x] : '-'), | ||
getOrNewLine: (context, x) => context[x] !== null && context[x] !== undefined ? context[x].toString().trim() : '<br>', | ||
substituteVars: (data, str) => { | ||
@@ -313,3 +314,3 @@ if (!str || !data) | ||
{{else}} | ||
{{mdToHTML (translate (getOrDash _data field.code))}} | ||
{{mdToHTML (translate (getOrNewLine _data field.code))}} | ||
{{/if}} | ||
@@ -316,0 +317,0 @@ </td> |
{ | ||
"name": "idea-html2pdf", | ||
"version": "2.0.6", | ||
"version": "2.0.7", | ||
"description": "IDEA helper for generating a PDF from HTML contents", | ||
@@ -13,3 +13,3 @@ "engines": { | ||
"compile": "tsc --build", | ||
"docs": "typedoc index.ts", | ||
"docs": "typedoc index.ts --customCss ./docs.style.css", | ||
"build": "./build.sh", | ||
@@ -16,0 +16,0 @@ "publishPackage": "./build.sh && npm publish" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26637
9
531