Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
gpt-engineer-app[bot]
2026-04-17 02:19:14 +00:00
co-authored by renee-png
parent 38b3680730
commit 05226cb82f
+14 -3
View File
@@ -115,19 +115,30 @@ function TemplateDetailPage() {
navigate({ to: "/documents/templates" });
};
const isLetter = tpl?.kind === "correspondence";
const fontFamily: string = tpl?.font_family || "Bookman Old Style";
const fontSizePt: number = tpl?.font_size_pt || 12;
const downloadOnly = async () => {
await downloadGeneric({ title: docName, body: merged }, docName || "Document");
await downloadGeneric(
{ title: isLetter ? undefined : docName, body: merged, fontFamily, fontSizePt },
docName || "Document",
);
};
const generateAndSave = async () => {
setGenerating(true);
try {
const { Document, Paragraph, TextRun, AlignmentType } = await import("docx");
const font = "Bookman Old Style", size = 24;
const font = fontFamily;
const size = fontSizePt * 2;
const mkP = (text: string, bold = false, center = false) =>
new Paragraph({ alignment: center ? AlignmentType.CENTER : undefined, children: [new TextRun({ text, bold, font, size })] });
const children: any[] = [];
if (docName) { children.push(mkP(docName, true, true)); children.push(new Paragraph({ children: [new TextRun({ text: "", font, size })] })); }
if (docName && !isLetter) {
children.push(mkP(docName, true, true));
children.push(new Paragraph({ children: [new TextRun({ text: "", font, size })] }));
}
merged.split("\n").forEach((line) => children.push(mkP(line)));
const doc = new Document({
styles: { default: { document: { run: { font, size } } } },