편지와 청구서
Letter은 그 안의 단락을 중심으로 편지를 구성해요. 주소에서는 \n가 새 줄을 시작해요:
<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는 항목 목록으로 전체 청구서를 만듭니다. 각 항목에는 description, quantity(기본값 1), 그리고 price 또는 amount가 있습니다. 소계, 세금, 합계는 자동으로 계산됩니다:
<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:는 GBP, USD, EUR 또는 JPY와 같은 코드이거나 임의의 기호입니다. tax:는 백분율이고, tax_name:는 이름입니다(기본 VAT). paid:는 이미 지불된 금액이며, 이 금액이 있으면 잔액이 남습니다.