Printing: Replace WinziPrint with iText
Some checks failed
Test / Run tests (push) Failing after 2m18s

This commit is contained in:
2026-02-18 23:00:21 +01:00
parent 4cd7ef85a1
commit a6e04ab1d2
17 changed files with 341 additions and 234 deletions

View File

@@ -21,14 +21,6 @@ namespace Elwig.Documents {
IncludeSender = includeSender;
var c = App.Client;
Header = $"<div class='name'>{c.Name}</div><div class='suffix'>{c.NameSuffix}</div><div class='type'>{c.NameTypeFull}</div>";
Footer = Utils.GenerateFooter("<br/>", " \u00b7 ")
.Item(c.NameFull).NextLine()
.Item(c.Address).Item($"{c.Plz} {c.Ort}").Item("Österreich").Item("Tel.", c.PhoneNr).Item("Fax", c.FaxNr).NextLine()
.Item(c.EmailAddress != null ? $"<a href=\"mailto:{c.Name} {c.NameSuffix} <{c.EmailAddress}>\">{c.EmailAddress}</a>" : null)
.Item(c.Website != null ? $"<a href=\"http://{c.Website}/\">{c.Website}</a>" : null)
.Item("Betriebs-Nr.", c.LfbisNr).Item("Bio-KSt.", c.OrganicAuthority).NextLine()
.Item("UID", c.UstIdNr).Item("BIC", c.Bic).Item("IBAN", c.Iban)
.ToString();
var uid = (m.UstIdNr ?? "-") + (m.IsBuchführend ? "" : " <i>(pauschaliert)</i>");
Aside = $"<table><colgroup><col span='1' style='width: 22.5mm;'/><col span='1' style='width: 42.5mm;'/></colgroup>" +
$"<thead><tr><th colspan='2'>Mitglied</th></tr></thead><tbody>" +

View File

@@ -1,19 +1,4 @@
.m1, .m2, .m3 {
height: 0;
width: 10mm;
position: fixed;
left: -25mm;
border-top: var(--border-thickness) solid black;
}
.m1.r, .m2.r, .m3.r {
left: initial;
right: -20mm;
}
.m1 {top: 80mm;}
.m2 {top: 123.5mm;}
.m3 {top: 185mm;}
.page-break {
break-before: page;
}
@@ -23,15 +8,15 @@ hr.page-break {
@page {
size: A4;
margin: 25mm 20mm 35mm 25mm;
margin: 25mm 20mm 25mm 25mm;
}
@bottom-center {
content: element(page-footer);
}
@page :first {
margin: 25mm 20mm 35mm 25mm;
}
@media screen {
body, header, .footer-wrapper {
body, header {
width: 210mm;
}
@@ -39,10 +24,6 @@ hr.page-break {
border: 1px solid lightgray;
}
.m1, .m2, .m3 {
display: none;
}
header {
top: 0;
}
@@ -54,23 +35,9 @@ hr.page-break {
.main-wrapper {
margin: 0 20mm 40mm 25mm;
}
.footer-wrapper {
position: fixed;
bottom: 0;
left: 0;
right: 0;
background: white;
}
}
@media print {
.page::after {
content: "Seite " counter(page) " von " counter(pages) !important;
}
a {
text-decoration: inherit;
color: inherit;
}
a {
text-decoration: inherit;
color: inherit;
}

View File

@@ -1,13 +1,13 @@
main table {
border-collapse: collapse;
margin-bottom: 10mm;
margin-bottom: 0mm;
font-size: 10pt;
}
main table.large {font-size: 12pt;}
main table.tiny {
font-size: 8pt;
margin-bottom: 5mm;
margin-bottom: 0mm;
}
main table.border {
@@ -30,7 +30,7 @@ main table.small th,
main table.small td,
main table.tiny th,
main table.tiny td {
padding: 0.125mm 0.125mm;
padding: 0mm 0.125mm;
}
main table td[rowspan] {

View File

@@ -31,7 +31,6 @@ namespace Elwig.Documents {
public string Title;
public string Author;
public string Header;
public string Footer;
public DateOnly Date;
public Document(string title) {
@@ -41,7 +40,6 @@ namespace Elwig.Documents {
Title = title;
Author = c.NameFull;
Header = "";
Footer = Utils.GenerateFooter("<br/>", " \u00b7 ").Item(c.NameFull).ToString();
Date = DateOnly.FromDateTime(Utils.Today);
}
@@ -122,12 +120,12 @@ namespace Elwig.Documents {
var tmpHtml = new TempFile("html");
await File.WriteAllTextAsync(tmpHtml.FilePath, await doc.Render(), Utils.UTF8);
tmpHtmls.Add(tmpHtml);
tmpFiles.Add((doc is Letterhead ? "#" : "") + tmpHtml.FileName);
tmpFiles.Add((doc is Letterhead ? "#" : "") + tmpHtml.FilePath);
i++;
progress?.Report(GenerationProportion * 100 * i / n);
}
progress?.Report(GenerationProportion * 100);
var pages = await Pdf.Convert(tmpFiles, pdf.FileName, IsDoublePaged, cancelToken, new Progress<double>(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion))));
var pages = Pdf.Convert(tmpFiles, pdf.FilePath, IsDoublePaged, m.Documents, cancelToken, new Progress<double>(v => progress?.Report(GenerationProportion * 100 + v * (1 - GenerationProportion))));
TotalPages = pages.Pages;
_pdfFile = pdf;
} catch {
@@ -146,7 +144,7 @@ namespace Elwig.Documents {
using var tmpHtml = new TempFile("html");
await File.WriteAllTextAsync(tmpHtml.FilePath, await Render(), Utils.UTF8);
progress?.Report(50.0);
var pages = await Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, IsDoublePaged, cancelToken);
var pages = Pdf.Convert(tmpHtml.FilePath, pdf.FilePath, this);
TotalPages = pages.Pages;
_pdfFile = pdf;
} catch {

View File

@@ -13,41 +13,12 @@
@if (Model.IsDoublePaged) {
<style>
@@page :left {
margin: 25mm 25mm 35mm 20mm;
@@bottom-center {
content: element(page-footer-left);
}
margin: 25mm 25mm 25mm 20mm;
}
</style>
}
</head>
<body>
@if (Model.ShowFoldMarks) {
<div class="m1"></div>
<div class="m2"></div>
<div class="m3"></div>
<div class="m1 r"></div>
<div class="m2 r"></div>
<div class="m3 r"></div>
}
<div class="footer-wrapper">
<div class="pre-footer">
<span class="date">@($"{Model.Date:dddd, d. MMMM yyyy}")</span>
<span class="doc-id">@Model.DocumentId</span>
<span><span class="page"></span>@Raw(Model.IsPreview ? " <b>(vorläufig)</b>" : "")</span>
</div>
<footer>@Raw(Model.Footer)</footer>
</div>
@if (Model.IsDoublePaged) {
<div class="footer-wrapper left">
<div class="pre-footer">
<span>@Raw(Model.IsPreview ? "<b>(vorläufig)</b> " : "")<span class="page"></span></span>
<span class="doc-id">@Model.DocumentId</span>
<span class="date">@($"{Model.Date:dddd, d. MMMM yyyy}")</span>
</div>
<footer>@Raw(Model.Footer)</footer>
</div>
}
<header>@Raw(Model.Header)</header>
<div class="spacing"></div>
<div class="main-wrapper">

View File

@@ -55,53 +55,6 @@ header .type {
font-weight: normal;
}
.footer-wrapper {
position: running(page-footer);
width: 165mm;
/* for some reason the position without the following statement changes on the second page */
border: var(--border-thickness) solid #00000000;
}
.footer-wrapper.left {
position: running(page-footer-left);
}
.pre-footer {
margin: 1em 0;
font-size: 10pt;
}
.pre-footer > * {
display: inline-block;
width: 33%;
}
.pre-footer > *:first-child {
text-align: left;
}
.pre-footer > *:nth-child(2) {
text-align: center;
font-style: italic;
}
.pre-footer > *:last-child {
text-align: right;
float: right;
}
.pre-footer .page::after {
content: "Seite 1 von 1";
}
footer {
font-size: 10pt;
border-top: var(--border-thickness) solid black;
height: 25mm;
padding-top: 1mm;
text-align: center;
}
.hidden {
visibility: hidden;
}

View File

@@ -166,7 +166,6 @@
}
@if (areaComs.Count != 0) {
<br class="area-commitements"/>
<h2>Flächenbindungen per @($"{Model.Date:dd.MM.yyyy}")</h2>
<table class="area-commitements">
<colgroup>

View File

@@ -1,5 +1,6 @@
h2 {
margin-top: 0;
margin-bottom: 0.5em !important;
}
@@ -22,9 +23,3 @@ table.area-commitements td.text {
table.area-commitements tr.sum {
font-size: 12pt;
}
@page :not(:first) {
br.area-commitements {
display: none;
}
}