n8n-nodes-json-html-to-pdf
Version:
Professional n8n node to convert JSON data or HTML content to PDF documents with Handlebars template support
322 lines (281 loc) • 8.07 kB
HTML
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>{{title}}</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: #333;
max-width: 210mm;
margin: 0 auto;
padding: 20mm;
background: white;
}
.report-header {
text-align: center;
margin-bottom: 30px;
padding-bottom: 20px;
border-bottom: 3px solid #0066cc;
}
.report-header h1 {
color: #0066cc;
font-size: 28px;
margin-bottom: 10px;
}
.report-header p {
color: #666;
font-size: 14px;
}
.metadata {
display: flex;
justify-content: space-between;
margin-bottom: 30px;
padding: 15px;
background-color: #f5f5f5;
border-radius: 5px;
}
.metadata-item {
text-align: center;
}
.metadata-item .label {
font-size: 12px;
color: #666;
text-transform: uppercase;
margin-bottom: 5px;
}
.metadata-item .value {
font-size: 16px;
font-weight: bold;
color: #333;
}
.executive-summary {
background-color: #e8f4f8;
padding: 20px;
border-left: 4px solid #0066cc;
margin-bottom: 30px;
}
.executive-summary h2 {
color: #0066cc;
font-size: 20px;
margin-bottom: 10px;
}
.executive-summary p {
font-size: 14px;
line-height: 1.8;
}
.section {
margin-bottom: 30px;
}
.section h2 {
color: #0066cc;
font-size: 22px;
margin-bottom: 15px;
padding-bottom: 5px;
border-bottom: 2px solid #e0e0e0;
}
.section h3 {
color: #333;
font-size: 18px;
margin-top: 20px;
margin-bottom: 10px;
}
.section p {
font-size: 14px;
line-height: 1.8;
margin-bottom: 10px;
}
.statistics {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 20px;
margin: 20px 0;
}
.stat-card {
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
color: white;
padding: 20px;
border-radius: 10px;
text-align: center;
}
.stat-card .stat-value {
font-size: 32px;
font-weight: bold;
margin-bottom: 5px;
}
.stat-card .stat-label {
font-size: 14px;
opacity: 0.9;
}
.data-table {
width: 100%;
border-collapse: collapse;
margin: 20px 0;
}
.data-table th {
background-color: #0066cc;
color: white;
padding: 12px;
text-align: left;
font-size: 14px;
}
.data-table td {
padding: 10px 12px;
border-bottom: 1px solid #e0e0e0;
font-size: 14px;
}
.data-table tr:nth-child(even) {
background-color: #f9f9f9;
}
.chart-container {
margin: 20px 0;
padding: 20px;
background-color: #f9f9f9;
border-radius: 5px;
text-align: center;
}
.recommendations {
background-color: #fff9e6;
padding: 20px;
border-left: 4px solid #ffa500;
margin: 30px 0;
}
.recommendations h3 {
color: #ff8c00;
margin-bottom: 15px;
}
.recommendations ul {
list-style-type: none;
padding-left: 0;
}
.recommendations li {
padding: 8px 0;
padding-left: 25px;
position: relative;
}
.recommendations li:before {
content: "→";
position: absolute;
left: 0;
color: #ff8c00;
font-weight: bold;
}
.conclusion {
background-color: #f0f8ff;
padding: 20px;
border-radius: 5px;
margin-top: 30px;
}
.conclusion h2 {
color: #0066cc;
margin-bottom: 10px;
}
.footer {
margin-top: 50px;
padding-top: 20px;
border-top: 1px solid #e0e0e0;
text-align: center;
font-size: 12px;
color: #666;
}
.page-break {
page-break-after: always;
}
</style>
</head>
<body>
<div class="report-header">
<h1>{{title}}</h1>
<p>{{subtitle}}</p>
<p>{{#if author}}Prepared by: {{author}} | {{/if}}{{reportDate}}</p>
</div>
<div class="metadata">
<div class="metadata-item">
<div class="label">Report Period</div>
<div class="value">{{period}}</div>
</div>
<div class="metadata-item">
<div class="label">Department</div>
<div class="value">{{department}}</div>
</div>
<div class="metadata-item">
<div class="label">Status</div>
<div class="value">{{status}}</div>
</div>
</div>
{{#if executiveSummary}}
<div class="executive-summary">
<h2>Executive Summary</h2>
<p>{{executiveSummary}}</p>
</div>
{{/if}}
{{#if statistics}}
<div class="section">
<h2>Key Metrics</h2>
<div class="statistics">
{{#each statistics}}
<div class="stat-card">
<div class="stat-value">{{value}}</div>
<div class="stat-label">{{label}}</div>
</div>
{{/each}}
</div>
</div>
{{/if}}
{{#each sections}}
<div class="section">
<h2>{{title}}</h2>
{{#if content}}
<p>{{content}}</p>
{{/if}}
{{#if table}}
<table class="data-table">
<thead>
<tr>
{{#each table.headers}}
<th>{{this}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each table.rows}}
<tr>
{{#each this}}
<td>{{this}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
{{/if}}
{{#if chart}}
<div class="chart-container">
<p>[Chart: {{chart.type}} - {{chart.description}}]</p>
</div>
{{/if}}
</div>
{{/each}}
{{#if recommendations}}
<div class="recommendations">
<h3>Recommendations</h3>
<ul>
{{#each recommendations}}
<li>{{this}}</li>
{{/each}}
</ul>
</div>
{{/if}}
{{#if conclusion}}
<div class="conclusion">
<h2>Conclusion</h2>
<p>{{conclusion}}</p>
</div>
{{/if}}
<div class="footer">
<p>{{#if confidential}}<strong>CONFIDENTIAL</strong> - {{/if}}This report was generated automatically on {{generatedDate}}</p>
<p>Page numbers and additional footer information will appear when printed</p>
</div>
</body>
</html>