From d4af641e8b7a144b2c61e7b9d68e7918bd46cc1e Mon Sep 17 00:00:00 2001
From: dujinkim <dujin.kim@dtsolution.co.kr>
Date: Fri, 24 Oct 2025 10:48:51 +0000
Subject: (임수민) 데이터룸 관련 요청사항 반영
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 components/file-manager/SecurePDFViewer.tsx | 101 +++++++++++++++-------------
 1 file changed, 54 insertions(+), 47 deletions(-)

(limited to 'components/file-manager/SecurePDFViewer.tsx')

diff --git a/components/file-manager/SecurePDFViewer.tsx b/components/file-manager/SecurePDFViewer.tsx
index bd28214b..a24e2e37 100644
--- a/components/file-manager/SecurePDFViewer.tsx
+++ b/components/file-manager/SecurePDFViewer.tsx
@@ -10,10 +10,11 @@ import { createCustomWatermark } from './creaetWaterMarks';
 interface SecurePDFViewerProps {
   documentUrl: string;
   fileName: string;
+  category?: string;
   onClose?: () => void;
 }
 
-export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFViewerProps) {
+export function SecurePDFViewer({ documentUrl, fileName, category, onClose }: SecurePDFViewerProps) {
   const viewerRef = useRef<HTMLDivElement>(null);
   const instanceRef = useRef<WebViewerInstance | null>(null);
   const initialized = useRef(false);
@@ -91,6 +92,10 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
                   'toggleNotesButton'
                 ]);
 
+                const { Core } = instance;
+                Core.Tools.Tool.disableAutoSwitch();
+                Core.Tools.Tool.disableTextSelection();
+                
                 // CSS 적용으로 추가 보안
                 const iframeWindow = instance.UI.iframeWindow;
                 if (iframeWindow && iframeWindow.document) {
@@ -187,55 +192,57 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
 
       const { documentViewer, annotationManager } = instance.Core;
 
-      // 문서 로드 완료 이벤트
-      documentViewer.addEventListener('documentLoaded', async () => {
-        setIsLoading(false);
-
-        // 워터마크 추가
-        const watermarkText = `SHI DATAROOM\n${session?.user?.email || 'CONFIDENTIAL'}\n${new Date().toLocaleString()}`;
-
-        // 대각선 워터마크
-        documentViewer.setWatermark({
-          custom: createCustomWatermark({
-            text: watermarkText,
-            fontSize: 14,
-            fontFamily: 'Arial',
-            color: 'rgba(128, 128, 128, 0.3)', // 연한 회색
-            opacity: 30, // 15% 투명도
-            rotation: -45,
-          })
-        });
+      if (category !== 'public') {
+        // 문서 로드 완료 이벤트
+        documentViewer.addEventListener('documentLoaded', async () => {
+          setIsLoading(false);
+
+          // 워터마크 추가
+          const watermarkText = `SHI DATAROOM\n${session?.user?.email || 'CONFIDENTIAL'}\n${new Date().toLocaleString()}`;
+
+          // 대각선 워터마크
+          documentViewer.setWatermark({
+            custom: createCustomWatermark({
+              text: watermarkText,
+              fontSize: 14,
+              fontFamily: 'Arial',
+              color: 'rgba(128, 128, 128, 0.5)', // 연한 회색
+              opacity: 30, // 15% 투명도
+              rotation: -45,
+            })
+          });
 
-        // 각 페이지에 커스텀 워터마크 추가
-        const pageCount = documentViewer.getPageCount();
-        for (let i = 1; i <= pageCount; i++) {
-          const pageInfo = documentViewer.getDocument().getPageInfo(i);
-          const { width, height } = pageInfo;
-
-          // FreeTextAnnotation 생성
-          const watermarkAnnot = new instance.Core.Annotations.FreeTextAnnotation();
-          watermarkAnnot.PageNumber = i;
-          watermarkAnnot.X = width / 4;
-          watermarkAnnot.Y = height / 2;
-          watermarkAnnot.Width = width / 2;
-          watermarkAnnot.Height = 100;
-          watermarkAnnot.setContents(
-            `${session?.user?.email}\n${docFileName}\n${new Date().toLocaleDateString()}`
-          );
-          watermarkAnnot.FillColor = new instance.Core.Annotations.Color(255, 0, 0, 0.3);
-          watermarkAnnot.TextColor = new instance.Core.Annotations.Color(255, 0, 0, 0.4);
-          watermarkAnnot.FontSize = '24pt';
-          watermarkAnnot.TextAlign = 'center';
-          watermarkAnnot.Rotation = -45;
-          watermarkAnnot.ReadOnly = true;
-          watermarkAnnot.Locked = true;
-          watermarkAnnot.Printable = true;
-
-          annotationManager.addAnnotation(watermarkAnnot);
+          // 각 페이지에 커스텀 워터마크 추가
+          const pageCount = documentViewer.getPageCount();
+          for (let i = 1; i <= pageCount; i++) {
+            const pageInfo = documentViewer.getDocument().getPageInfo(i);
+            const { width, height } = pageInfo;
+
+            // FreeTextAnnotation 생성
+            const watermarkAnnot = new instance.Core.Annotations.FreeTextAnnotation();
+            watermarkAnnot.PageNumber = i;
+            watermarkAnnot.X = width / 4;
+            watermarkAnnot.Y = height / 2;
+            watermarkAnnot.Width = width / 2;
+            watermarkAnnot.Height = 100;
+            watermarkAnnot.setContents(
+              `${session?.user?.email}\n${docFileName}\n${new Date().toLocaleDateString()}`
+            );
+            watermarkAnnot.FillColor = new instance.Core.Annotations.Color(255, 0, 0, 0.3);
+            watermarkAnnot.TextColor = new instance.Core.Annotations.Color(255, 0, 0, 0.4);
+            watermarkAnnot.FontSize = '24pt';
+            watermarkAnnot.TextAlign = 'center';
+            watermarkAnnot.Rotation = -45;
+            watermarkAnnot.ReadOnly = true;
+            watermarkAnnot.Locked = true;
+            watermarkAnnot.Printable = true;
+
+            annotationManager.addAnnotation(watermarkAnnot);
+          }
+
+          annotationManager.drawAnnotations(documentViewer.getCurrentPage());
         }
 
-        annotationManager.drawAnnotations(documentViewer.getCurrentPage());
-
         // Pan 모드로 설정 (텍스트 선택 불가)
         documentViewer.setToolMode(documentViewer.getTool('Pan'));
 
-- 
cgit v1.2.3

