Changed the styling for generate_pdf_emoji_support.py

main
David 3 days ago
parent 79ca7ab62a
commit 4bc2190d27

@ -29,6 +29,7 @@ def main():
# Read the TSV data # Read the TSV data
with open(input_tsv, 'r', encoding='utf-8-sig') as f: with open(input_tsv, 'r', encoding='utf-8-sig') as f:
reader = csv.DictReader(f, delimiter='\t') reader = csv.DictReader(f, delimiter='\t')
rows = list(reader)
rows = sorted(rows, key=lambda r: r.get("Sending locality:", "").strip()) rows = sorted(rows, key=lambda r: r.get("Sending locality:", "").strip())
pdf = FPDF(format='Letter', unit='pt') pdf = FPDF(format='Letter', unit='pt')

@ -102,102 +102,143 @@ def main():
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="UTF-8"> <meta charset="UTF-8">
""" + rf""" <title>Data Report</title>
<title>{os.path.basename(output_pdf)}</title>
""" + r"""
<style> <style>
@page { @page {
size: Letter; size: Letter;
margin: 50px; margin: 50px;
} }
body { body {
font-family: sans-serif; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
font-size: 12pt; font-size: 11pt;
line-height: 1.3; /* Slightly tighter than 1.4 */ line-height: 1.5;
margin: 0; margin: 0;
padding: 0; padding: 0;
color: #2c3e50;
} }
.trainee-page { .trainee-page {
margin-bottom: 1em; margin-bottom: 2em;
page-break-after: always; /* Force new page for each trainee */ page-break-after: always;
} }
h1 { h1 {
font-size: 16pt; font-size: 18pt;
margin: 0 0 0.3em 0; /* reduced bottom margin */ margin: 0 0 0.5em 0;
color: #1a365d;
} }
h2 { h2 {
font-size: 14pt; font-size: 14pt;
margin: 0 0 0.7em 0; /* reduced bottom margin */ margin: 0 0 1em 0;
color: #4a5568;
} }
/* General paragraph spacing reduced */
p { p {
margin: 0.2em 0; /* Very small vertical margin */ margin: 0.5em 0;
white-space: pre-wrap; /* preserve any line breaks from the data */ white-space: pre-wrap;
} }
.comments-label { .comments-label {
font-weight: 500;
margin-top: 1em;
margin-bottom: 0.2em;
color: #7c3aed;
font-size: 10.5pt;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.comments-value {
margin-top: 0;
margin-bottom: 1em;
color: #6c757d;
font-style: italic; font-style: italic;
margin-top: 0.4em; /* smaller gap before comments label */
} }
.bold { .bold {
font-weight: bold; font-weight: bold;
color: #2d3748;
} }
.italic {
font-style: italic; .evaluation-header {
font-weight: bold;
margin: 1em 0 0.5em 0;
color: #2d3748;
font-size: 11pt;
} }
.inline-answer { .evaluation-item {
margin-top: 0.4em; /* smaller top margin */ margin: 0.2em 0;
margin-bottom: 0.4em; /* smaller bottom margin */ }
.evaluation-item .bold {
color: #1a365d;
font-weight: 600;
min-width: 110px;
display: inline-block;
font-size: 10.5pt;
text-transform: uppercase;
letter-spacing: 0.3px;
} }
.block-label { .block-label {
font-weight: bold; font-weight: bold;
margin-top: 0.4em; /* smaller top margin */ margin-top: 1em;
margin-bottom: 0.1em; /* smaller bottom margin */ margin-bottom: 0.3em;
} }
.block-value { .block-value {
margin-left: 1em; margin-bottom: 0.5em;
margin-bottom: 0.2em; /* smaller bottom margin */ color: #4a5568;
} }
.entry-value {
color: #059669;
font-weight: 600;
font-size: 12pt;
}
</style> </style>
</head> </head>
<body>
<body>
{% for row in rows %} {% for row in rows %}
<div class="trainee-page"> <div class="trainee-page">
<!-- Name first -->
<h1>{{ row.name }}</h1> <h1>{{ row.name }}</h1>
<!-- Locality second -->
<h2>Sending Locality: {{ row.locality }}</h2> <h2>Sending Locality: {{ row.locality }}</h2>
{% for entry in row.entries %} {% for entry in row.entries %}
{% if entry.type == "comments" %} {% if entry.type == "comments" %}
<!-- Comments label in italic, value in normal font -->
<p class="comments-label">Comments:</p> <p class="comments-label">Comments:</p>
<p>{{ entry.value }}</p> <p class="comments-value">{{ entry.value }}</p>
{% elif entry.type == "inline" %} {% elif entry.type == "inline" %}
<!-- Numeric: label + value on one line --> <div class="inline-answer">
<p class="inline-answer"> {% if "Truth" in entry.label %}
<span class="bold">{{ entry.label }}</span> {{ entry.value }} <p class="evaluation-header">Please evaluate your progress for this past term (1-5, 5 indicating the most progress):</p>
</p> <p class="evaluation-item"><span class="bold">Truth:</span> <span class="entry-value">{{ entry.value }}</span></p>
{% elif "Life" in entry.label %}
<p class="evaluation-item"><span class="bold">Life:</span> <span class="entry-value">{{ entry.value }}</span></p>
{% elif "Gospel" in entry.label %}
<p class="evaluation-item"><span class="bold">Gospel:</span> <span class="entry-value">{{ entry.value }}</span></p>
{% elif "Character" in entry.label %}
<p class="evaluation-item"><span class="bold">Character:</span> <span class="entry-value">{{ entry.value }}</span></p>
{% elif "Service" in entry.label %}
<p class="evaluation-item"><span class="bold">Service:</span> <span class="entry-value">{{ entry.value }}</span></p>
{% else %}
<span class="bold">{{ entry.label }}</span>
<p class="entry-value">{{ entry.value }}</p>
{% endif %}
</div>
{% else %} {% else %}
<!-- label on one line, value on next -->
<p class="block-label">{{ entry.label }}</p> <p class="block-label">{{ entry.label }}</p>
<p class="block-value">{{ entry.value }}</p> <p class="comments-value block-value">{{ entry.value }}</p>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div> </div>
{% endfor %} {% endfor %}
</body> </body>
</html> </html>
""" """

Loading…
Cancel
Save