diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-15 12:52:11 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-10-15 12:52:11 +0000 |
| commit | b54f6f03150dd78d86db62201b6386bf14b72394 (patch) | |
| tree | b3092bb34805fdc65eee5282e86a9fb90ba20d6e /components/file-manager/creaetWaterMarks.tsx | |
| parent | c1bd1a2f499ee2f0742170021b37dab410983ab7 (diff) | |
(대표님) 커버, 데이터룸, 파일매니저, 담당자할당 등
Diffstat (limited to 'components/file-manager/creaetWaterMarks.tsx')
| -rw-r--r-- | components/file-manager/creaetWaterMarks.tsx | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/components/file-manager/creaetWaterMarks.tsx b/components/file-manager/creaetWaterMarks.tsx new file mode 100644 index 00000000..524b18ee --- /dev/null +++ b/components/file-manager/creaetWaterMarks.tsx @@ -0,0 +1,71 @@ +export const createCustomWatermark: CreateCustomWatermark = ({ + text, + fontSize, + color, + opacity, + rotation = -45, + fontFamily = "Helvetica", + }) => { + return (ctx, pageNumber, pageWidth, pageHeight) => { + if (!text) return; + + const lines = text.split("\n"); // 줄바꿈 기준 멀치 처리 + + ctx.save(); + ctx.translate(pageWidth / 2, pageHeight / 2); + ctx.rotate((rotation * Math.PI) / 180); + ctx.fillStyle = color; + ctx.textAlign = "center"; + ctx.textBaseline = "middle"; + + const lineHeights = lines.map((s) => { + return fontSize; + }); + + const totalHeight = + lineHeights.reduce((sum, h) => sum + h, 0) - lineHeights[0]; // 첫 줄은 기준선 0 + + let yOffset = -totalHeight / 2; + + lines.forEach((line, i) => { + ctx.font = `900 ${fontSize}px ${fontFamily}`; + ctx.fillText(line, 0, yOffset); + yOffset += lineHeights[i]; + }); + + ctx.restore(); + }; + }; + + + import { Core, WebViewerInstance } from "@pdftron/webviewer"; + +export interface WaterMarkOption { + fontSize: number; + color: string; + opacity: number; + rotation: number; + fontFamily: string; + split: boolean; + shipNameCheck: boolean; + shipName: string; + ownerNameCheck: boolean; + ownerName: string; + classNameCheck: boolean; + className: string; + classList: string[]; + customCheck: boolean; + text: string; +} + +type CreateCustomWatermark = ({ + text, + fontSize, + color, + opacity, + rotation, + fontFamily, +}: Pick< + WaterMarkOption, + "text" | "fontSize" | "color" | "opacity" | "rotation" | "fontFamily" +>) => Core.DocumentViewer.CustomWatermarkCallback;
\ No newline at end of file |
