워터마크 기능 추가

This commit is contained in:
dohyeons
2025-12-22 15:40:31 +09:00
parent 002c71f9e8
commit d90e68905e
6 changed files with 929 additions and 2 deletions

View File

@@ -27,7 +27,11 @@ import {
BorderStyle,
PageOrientation,
convertMillimetersToTwip,
Header,
Footer,
HeadingLevel,
} from "docx";
import { WatermarkConfig } from "../types/report";
import bwipjs from "bwip-js";
export class ReportController {
@@ -3063,6 +3067,36 @@ export class ReportController {
children.push(new Paragraph({ children: [] }));
}
// 워터마크 헤더 생성 (워터마크가 활성화된 경우)
const watermark: WatermarkConfig | undefined = page.watermark;
let headers: { default?: Header } | undefined;
if (watermark?.enabled && watermark.type === "text" && watermark.text) {
// 워터마크 색상을 hex로 변환 (alpha 적용)
const opacity = watermark.opacity ?? 0.3;
const fontColor = watermark.fontColor || "#CCCCCC";
// hex 색상에서 # 제거
const cleanColor = fontColor.replace("#", "");
headers = {
default: new Header({
children: [
new Paragraph({
alignment: AlignmentType.CENTER,
children: [
new TextRun({
text: watermark.text,
size: (watermark.fontSize || 48) * 2, // Word는 half-point 사용
color: cleanColor,
bold: true,
}),
],
}),
],
}),
};
}
return {
properties: {
page: {
@@ -3082,6 +3116,7 @@ export class ReportController {
},
},
},
headers,
children,
};
});