Printing: Replace WinziPrint with iText
Some checks failed
Test / Run tests (push) Has been cancelled
Some checks failed
Test / Run tests (push) Has been cancelled
This commit is contained in:
@@ -3,6 +3,7 @@ using Elwig.Documents;
|
||||
using Elwig.Helpers.Billing;
|
||||
using Elwig.Models;
|
||||
using Elwig.Models.Entities;
|
||||
using iText.Layout.Element;
|
||||
using LinqKit;
|
||||
using MailKit.Net.Smtp;
|
||||
using MailKit.Security;
|
||||
@@ -304,23 +305,18 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public class Footer {
|
||||
private string Text = "";
|
||||
private readonly List<List<object>> Items = [[]];
|
||||
private readonly string LineBreak;
|
||||
private readonly string Seperator;
|
||||
private bool FirstLine = true;
|
||||
private bool FirstItemInLine = true;
|
||||
private readonly string Separator;
|
||||
|
||||
public Footer(string lineBreak, string seperator) {
|
||||
public Footer(string lineBreak, string separator) {
|
||||
LineBreak = lineBreak;
|
||||
Seperator = seperator;
|
||||
Separator = separator;
|
||||
}
|
||||
|
||||
public Footer Item(string? text) {
|
||||
public Footer Item(object? text) {
|
||||
if (text == null) return this;
|
||||
Text += FirstItemInLine ? (FirstLine ? "" : LineBreak) : Seperator;
|
||||
Text += text;
|
||||
FirstLine = false;
|
||||
FirstItemInLine = false;
|
||||
Items[^1].Add(text);
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -329,12 +325,28 @@ namespace Elwig.Helpers {
|
||||
}
|
||||
|
||||
public Footer NextLine() {
|
||||
FirstItemInLine = true;
|
||||
Items.Add([]);
|
||||
return this;
|
||||
}
|
||||
|
||||
public override string ToString() {
|
||||
return Text;
|
||||
return string.Join(LineBreak, Items.Select(l => string.Join(Separator, l.ToString())));
|
||||
}
|
||||
|
||||
public IList<ILeafElement> ToLeafElements() {
|
||||
var l = new List<ILeafElement>();
|
||||
var first1 = true;
|
||||
foreach (var line in Items) {
|
||||
if (!first1) l.Add(new Text(LineBreak));
|
||||
var first2 = true;
|
||||
foreach (var item in line) {
|
||||
if (!first2) l.Add(new Text(Separator));
|
||||
l.Add(item as ILeafElement ?? new Text(item.ToString()));
|
||||
first2 = false;
|
||||
}
|
||||
first1 = false;
|
||||
}
|
||||
return l;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user