feat: better PDF

This commit is contained in:
2025-08-24 00:24:40 +02:00
parent 0267e6e578
commit 5b664234e9
18 changed files with 540 additions and 228 deletions

View File

@@ -1,88 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Generator: Adobe Illustrator 20.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
version="1.1"
id="Ebene_2"
x="0px"
y="0px"
viewBox="0 0 128 128"
xml:space="preserve"
sodipodi:docname="ch-cross.svg"
width="128"
height="128"
inkscape:export-filename="/home/irvin/Work/repos/swiss-qr-invoice/assets/raw/ch-cross.png"
inkscape:export-xdpi="232.22856"
inkscape:export-ydpi="232.22856"
inkscape:version="0.92.4 (5da689c313, 2019-01-14)"
style="shape-rendering:crispEdges"><metadata
id="metadata17"><rdf:RDF><cc:Work
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
id="defs15" /><sodipodi:namedview
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1"
objecttolerance="10"
gridtolerance="10"
guidetolerance="10"
inkscape:pageopacity="0"
inkscape:pageshadow="2"
inkscape:window-width="1668"
inkscape:window-height="1021"
id="namedview13"
showgrid="false"
inkscape:document-units="px"
units="px"
inkscape:zoom="2.8284271"
inkscape:cx="-38.018193"
inkscape:cy="61.405051"
inkscape:window-x="0"
inkscape:window-y="31"
inkscape:window-maximized="0"
inkscape:current-layer="Ebene_2"><inkscape:grid
type="xygrid"
id="grid916" /></sodipodi:namedview>
<style
type="text/css"
id="style2">
.st0{fill:#FFFFFF;}
.st1{fill:none;stroke:#FFFFFF;stroke-width:1.4357;stroke-miterlimit:10;}
</style>
<g
id="g4736"
transform="matrix(4.8380969,0,0,4.8380389,-1.9834927e-5,9.0008541e-4)"><polygon
transform="matrix(1.3598365,0,0,1.3598365,-0.23403522,-0.23403522)"
style="fill:#000000;fill-opacity:1;stroke-width:0.73538256"
id="polygon4"
points="0.7,0.7 0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 18.3,0.7 1.6,0.7 " /><rect
style="fill:#ffffff;fill-opacity:1;stroke-width:1"
id="rect6"
height="14.958201"
width="4.4874606"
class="st0"
y="5.2231627"
x="11.034758" /><rect
style="fill:#fffff9;fill-opacity:1;stroke-width:1"
id="rect8"
height="4.4874606"
width="14.958201"
class="st0"
y="10.526525"
x="5.7313952" /><polygon
transform="matrix(1.3598207,0,0,1.3598361,-0.2338788,-0.23403126)"
style="fill:none;stroke:#ffffff;stroke-width:1.05601561;stroke-miterlimit:10;stroke-dasharray:none;stroke-opacity:1"
id="polygon10"
points="1.6,0.7 0.7,0.7 0.7,1.6 0.7,18.3 0.7,19.1 1.6,19.1 18.3,19.1 19.1,19.1 19.1,18.3 19.1,1.6 19.1,0.7 18.3,0.7 "
class="st1" /></g>
</svg>

Before

Width:  |  Height:  |  Size: 3.0 KiB

View File

@@ -1,8 +1,28 @@
@page {
size: A4;
padding: 2cm;
}
@page:first {
padding: 0;
}
@media print {
.page,
.page-break {
break-after: page;
}
}
.first-page {
margin-left: 2cm;
margin-right: 2cm;
}
body {
font-family: sans-serif;
margin: 40px;
font-size: 12pt;
color: #333;
}
section {
margin-bottom: 3em;
}
@@ -10,6 +30,7 @@ p {
margin-top: 0.25em;
margin-bottom: 0.5em;
}
header {
display: flex;
justify-content: space-between;
@@ -23,10 +44,10 @@ h1 {
margin: 0;
font-size: 2em;
}
.company,
.client {
margin-bottom: 20px;
h2 {
margin-top: 0.5em;
}
table {
width: 100%;
border-collapse: collapse;
@@ -39,96 +60,27 @@ td {
}
th,
td {
padding: 10px;
padding: 0.25em 0.5em;
text-align: left;
}
th {
background-color: #f2f2f2;
}
tfoot td {
font-weight: bold;
}
h2 {
margin-top: 40px;
}
article {
margin-bottom: 20px;
}
footer {
margin-top: 40px;
font-size: 0.9em;
text-align: center;
color: #666;
}
.totals {
float: right;
width: 300px;
margin-top: -15px;
}
.totals table {
border: none;
margin: 0;
}
.totals td {
border: none;
padding: 5px 10px;
text-align: right;
}
@media print {
.page,
.page-break {
break-after: page;
}
}
.qr-section {
position: absolute;
bottom: 0;
display: grid;
grid-template-columns: 250px 1fr;
grid-template-rows: 1fr;
gap: 1em;
width: 100%;
/* border-top: 2px solid #000; */
/* padding-top: 1rem; */
h4 {
margin-bottom: 0.1em;
}
.qr-code {
display: flex;
flex-direction: column;
justify-content: space-between;
.qr-section-img {
position: relative;
width: 100%;
img {
width: 100%;
}
svg {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
z-index: 1;
width: 40px;
}
}
.qr-section-info {
display: grid;
grid-template-columns: 1fr 1fr;
grid-template-rows: 1fr 1fr;
justify-items: center;
}
}
.payment-details {
font-size: 0.9rem;
line-height: 1.4;
.issue-title {
display: flex;
justify-content: space-between;
align-items: end;
margin-top: 2em;
margin-bottom: 0.5em;
h3,
p {
margin: 0;
}
}

View File

@@ -8,9 +8,13 @@
<style>
{{ .Style }}
</style>
<style>
{{.Invoice.CSS}}
</style>
</head>
<body>
<header>
<header class="first-page" style="margin-top: 2cm">
<div class="company">
<h2>{{ .Company.Name }}</h2>
<p>
@@ -23,12 +27,12 @@
</div>
<div class="invoice-info">
<p>
<strong>Rechnung:</strong> {{ .ID }} <br />
<strong>Rechnung:</strong> {{ .Invoice.Reference }} <br />
<strong>Datum:</strong> {{ .Date | date }} <br />
</p>
</div>
</header>
<section class="client">
<section class="client first-page">
<h2>Rechnung an:</h2>
<p>
{{ .Client.Name }} <br />
@@ -38,90 +42,52 @@
</p>
</section>
<section class="page p1">
<section class="page p1 first-page">
<article>
<table>
<thead>
<tr>
<th>FID</th>
<th style="min-width: 3.5em">FID</th>
<th>Name</th>
<th>Zeitaufwand</th>
<th>Stundensatz</th>
<th>Preis CHF</th>
<th>Fertiggestellt</th>
<th>Aufwand</th>
<th style="min-width: 5.5em">Preis</th>
</tr>
</thead>
<tbody>
{{ range .Issues }}
<tr>
<td>{{ .Index }}</td>
<td style="font-family: monospace">{{ .Shorthand }}</td>
<td>{{ .Title }}</td>
<td>{{ .Duration | duration }}</td>
<td>16 CHF/h</td>
<td>{{ .Duration | price }} CHF</td>
<td>{{ .Closed | time }}</td>
</tr>
{{ end }}
</tbody>
</table>
<div class="totals">
<table>
<tfoot>
<tr>
<td>Gesamtbetrag:</td>
<td>{{ .Total }} CHF</td>
</tr>
</table>
</div>
</article>
<article class="qr-section">
<div class="qr-code">
<!-- Replace with your QR code image or generated SVG -->
<div class="qr-section-img">
<image src="{{ .QRInvoice }}"></image>
{{ .ChCross }}
</div>
<th colspan="2" style="text-align: right">Summe:</th>
<div class="qr-section-info">
<h4>Währung</h4>
<h4>Betrag</h4>
<p>CHF</p>
<p>{{ .Total}}</p>
</div>
</div>
<div class="payment-details">
<div>
<h4 style="margin-top: 0">Konto / Zahlbar an</h4>
<p>
{{ .Company.IBAN }} <br />
{{ .Company.Contact }} <br />
{{ .Company.Address.Street}} {{.Company.Address.Number}} <br />
{{ .Company.Address.ZIPCode }} {{ .Company.Address.Place }}
</p>
</div>
<div>
<h4>Referenz</h4>
<p></p>
</div>
<div>
<h4>Zahlbar durch</h4>
<p>
{{ .Client.Contact }} <br />
{{ .Client.Address.Street}} {{.Client.Address.Number}} <br />
{{ .Client.Address.ZIPCode }} {{ .Client.Address.Place }}
</p>
</div>
</div>
<td>{{ .Total | duration }}</td>
<td>{{ .Total | price}}</td>
</tr>
</tfoot>
</table>
</article>
{{ .Invoice.HTML }}
</section>
<section>
<h2>Details zu den Features</h2>
<h2 style="margin-top: 0">Details zu den Features</h2>
{{ range .Issues }}
<article>
<h3>{{ .Index }}: {{ .Title }}</h3>
{{ .Body | md | oh 3 }}
<div class="issue-title">
<h3>
<span style="font-family: monospace">{{ .Shorthand }}</span>: {{
.Title }}
</h3>
<p>Fertiggestellt: {{ .Closed | time }}</p>
</div>
{{ .CleanBody | md | oh 3 }}
</article>
{{ end }}
</section>