KScript ドキュメント
JA

言語

英語から自動翻訳されています。原文は英語です。

ドキュメント: KScript.Document

手紙と請求書

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:は支払い済みの金額で、これにより未払い残高が加算されます。