Closed Dirk23 closed 7 months ago
Found the solution by my self:
let receipt = Receipt(.init(maxWidthDensity: 500, fontDensity: 12, encoding: .windowsCP1252))
<<~ .style(.clear)
<<~ .style(.initialize)
<<~ .layout(.justification(.center))
<<< umlautConverter(text: globalAddress)
<<~ .page(.printAndFeed(lines: 1))
<<< Dividing.default()
<<~ .page(.printAndFeed(lines: 1))
<<< "\(date)"
<<~ .page(.printAndFeed(lines: 1))
<<< Dividing.default()
for g in array {
receipt <<< KVItem(umlautConverter(text: g.name), String(format: "%.2f", g.preis) + " Eur")
summe = summe + g.preis
}
for s in speisen {
receipt <<< KVItem(umlautConverter(text: s.name), String(format: "%.2f", s.preis) + " Eur")
summe = summe + s.preis
}
receipt <<< Dividing.default()
<<~ .page(.printAndFeed(lines: 1))
<<< KVItem("Gesamt", String(format: "%.2f", summe) + " Eur")
<<~ .page(.printAndFeed(lines: 1))
<<< Dividing.default()
<<~ .page(.printAndFeed(lines: 5))
<<~ .style(.clear)
<<~ .page(.partialCut)
I want to loop through an Array to ceate a Receipt with multiple Lines in it.
Here is my Example Code:
But the compiler doesnt like it:![image](https://github.com/KevinGong2013/Printer/assets/4200682/96c9ee23-369f-4dad-8e95-d77c1ff98360)
How can i achieve this?
Regards
Dirk