Briefe und Rechnungen
Letter ordnet einen Brief um die Absätze darin an. In Adressen beginnt \n eine neue Zeile:
<KScript.Document template="letter" to="'letter.pdf'">
<Letter from="{'Life Lab\n12 Grid Street\nCambridge'}" to="{'Dr Ada Lovelace\nExample University'}" subject="Invitation to speak" opening="Dear Dr Lovelace," closing="Yours sincerely," signature="Alan Turing">
<Paragraph>We would be delighted if you would give the opening talk.</Paragraph>
</Letter>
</KScript.Document>import KScript.Document
Document(template: letter, to: 'letter.pdf') {
Letter(from: 'Life Lab\n12 Grid Street\nCambridge', to: 'Dr Ada Lovelace\nExample University', subject: 'Invitation to speak', opening: 'Dear Dr Lovelace,', closing: 'Yours sincerely,', signature: 'Alan Turing') {
Paragraph "We would be delighted if you would give the opening talk."
}
}Invoice erstellt die gesamte Rechnung aus einer Liste von Positionen. Jede Position hat eine description, eine quantity (Standard: 1) und einen price oder einen amount. Zwischensumme, Steuer und Gesamtbetrag werden für dich berechnet:
<let name="items" value="[{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]" />
<import package="KScript.Document" />
<Document template="invoice" to="'invoice.pdf'">
<Invoice number="INV-042" from="{'Life Lab Ltd\n12 Grid Street'}" to="Example University" due="20 December 2026" items="$items" currency="GBP" tax="20" notes="Please pay within 30 days." />
</Document>$items = [{ description: 'Consulting', quantity: 3, price: 450 }, { description: 'Travel', price: 64.2 }]
import KScript.Document
Document(template: invoice, to: 'invoice.pdf') {
Invoice(number: 'INV-042', from: 'Life Lab Ltd\n12 Grid Street', to: 'Example University', due: '20 December 2026', items: $items, currency: 'GBP', tax: 20, notes: 'Please pay within 30 days.')
}currency: ist ein Code wie GBP, USD, EUR oder JPY oder ein beliebiges Symbol. tax: ist ein Prozentsatz, tax_name: dessen Bezeichnung (Standard-USt.) und paid: ein bereits gezahlter Betrag, der einen offenen Restbetrag ergibt.