mirror of
https://github.com/tomru/pdfer.git
synced 2026-03-02 22:17:18 +01:00
60 lines
1.3 KiB
TypeScript
60 lines
1.3 KiB
TypeScript
import { IDocProps } from '../interfaces/IDocProps'
|
|
|
|
function convertLineBreaks(lines: string) {
|
|
return lines.replace(/\n/g, '\\\\')
|
|
}
|
|
|
|
export function brief(options: IDocProps) {
|
|
const {
|
|
letterOption,
|
|
subject,
|
|
yourRef,
|
|
yourRefName,
|
|
yourMail,
|
|
myRef,
|
|
customer,
|
|
invoice,
|
|
date,
|
|
signature,
|
|
specialMail,
|
|
address,
|
|
opening,
|
|
body,
|
|
closing,
|
|
ps,
|
|
enclosing,
|
|
} = { ...options }
|
|
|
|
return `% brief document
|
|
\\documentclass{scrlttr2}
|
|
\\LoadLetterOption{${letterOption}}
|
|
|
|
\\setkomavar{subject}{${subject}}
|
|
|
|
${yourRef ? `\\setkomavar{yourref}[${yourRefName}]{${yourRef}}` : ''}
|
|
${yourMail ? `\\setkomavar{yourmail}{${yourMail}}` : ''}
|
|
${myRef ? `\\setkomavar{myref}{${myRef}}` : ''}
|
|
${customer ? `\\setkomavar{customer}{${customer}}` : ''}
|
|
${invoice ? `\\setkomavar{invoice}{${invoice}}` : ''}
|
|
${signature ? `\\setkomavar{signature}{${signature}}` : ''}
|
|
${specialMail ? `\\setkomavar{specialmail}{${specialMail}}` : ''}
|
|
|
|
${date ? `\\setkomavar{date}{${date}}` : ''}
|
|
|
|
\\begin{document}
|
|
\\begin{letter}{${convertLineBreaks(address)}}
|
|
|
|
\\opening{${opening},}
|
|
|
|
${convertLineBreaks(body)}
|
|
|
|
\\closing{${closing}}
|
|
|
|
${ps ? `\\ps{${ps}}` : ''}
|
|
|
|
${enclosing ? `\\encl{${enclosing}}` : ''}
|
|
|
|
\\end{letter}
|
|
\\end{document}`
|
|
}
|