summaryrefslogtreecommitdiff
path: root/components/file-manager/SecurePDFViewer.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'components/file-manager/SecurePDFViewer.tsx')
-rw-r--r--components/file-manager/SecurePDFViewer.tsx70
1 files changed, 35 insertions, 35 deletions
diff --git a/components/file-manager/SecurePDFViewer.tsx b/components/file-manager/SecurePDFViewer.tsx
index 707d95dc..eeb59b83 100644
--- a/components/file-manager/SecurePDFViewer.tsx
+++ b/components/file-manager/SecurePDFViewer.tsx
@@ -55,10 +55,10 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
viewerElement
).then(async (instance: WebViewerInstance) => {
instanceRef.current = instance;
-
+
try {
const { disableElements } = instance.UI;
-
+
// 보안을 위해 모든 도구 비활성화
disableElements([
'toolsHeader',
@@ -137,10 +137,10 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
}
console.log('📝 WebViewer 초기화 완료');
-
+
// 문서 로드
await loadSecureDocument(instance, documentUrl, fileName);
-
+
} catch (uiError) {
console.warn('⚠️ UI 설정 중 오류:', uiError);
toast.error('뷰어 설정 중 오류가 발생했습니다.');
@@ -166,19 +166,19 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
// 문서 로드 함수
const loadSecureDocument = async (
- instance: WebViewerInstance,
- documentPath: string,
+ instance: WebViewerInstance,
+ documentPath: string,
docFileName: string
) => {
setIsLoading(true);
try {
// 절대 URL로 변환
- const fullPath = documentPath.startsWith('http')
- ? documentPath
+ const fullPath = documentPath.startsWith('http')
+ ? documentPath
: `${window.location.origin}${documentPath}`;
-
+
console.log('📄 보안 문서 로드 시작:', fullPath);
-
+
// 문서 로드
await instance.UI.loadDocument(fullPath, {
filename: docFileName,
@@ -190,28 +190,28 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
// 문서 로드 완료 이벤트
documentViewer.addEventListener('documentLoaded', async () => {
setIsLoading(false);
-
+
// 워터마크 추가
const watermarkText = `${session?.user?.email || 'CONFIDENTIAL'}\n${new Date().toLocaleString()}`;
-
+
// 대각선 워터마크
- documentViewer.setWatermark(
- {custom:createCustomWatermark({
- text: watermarkText,
- fontSize: 30,
- fontFamily: 'Arial',
- color: 'rgba(255, 0, 0, 0.3)',
- opacity: 30,
- // diagonal: true,
- })}
- );
+ documentViewer.setWatermark({
+ custom: createCustomWatermark({
+ text: watermarkText,
+ fontSize: 14,
+ fontFamily: 'Arial',
+ color: 'rgba(128, 128, 128, 0.15)', // 연한 회색
+ opacity: 15, // 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;
@@ -230,21 +230,21 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
watermarkAnnot.ReadOnly = true;
watermarkAnnot.Locked = true;
watermarkAnnot.Printable = true;
-
+
annotationManager.addAnnotation(watermarkAnnot);
}
-
+
annotationManager.drawAnnotations(documentViewer.getCurrentPage());
-
+
// Pan 모드로 설정 (텍스트 선택 불가)
documentViewer.setToolMode(documentViewer.getTool('Pan'));
-
+
// 페이지 이동 로깅
documentViewer.addEventListener('pageNumberUpdated', (pageNumber: number) => {
console.log(`Page ${pageNumber} viewed at ${new Date().toISOString()}`);
// 서버로 감사 로그 전송 가능
});
-
+
console.log('✅ 보안 문서 로드 완료');
toast.success('문서가 안전하게 로드되었습니다.');
});
@@ -255,7 +255,7 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
setIsLoading(false);
toast.error('문서 로드 중 오류가 발생했습니다.');
});
-
+
} catch (err) {
console.error('❌ 문서 로딩 중 오류:', err);
toast.error(`문서 로드 실패: ${err instanceof Error ? err.message : '알 수 없는 오류'}`);
@@ -294,7 +294,7 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
document.addEventListener('keydown', preventShortcuts);
document.addEventListener('contextmenu', preventContextMenu);
document.addEventListener('dragstart', preventDrag);
-
+
return () => {
document.removeEventListener('keydown', preventShortcuts);
document.removeEventListener('contextmenu', preventContextMenu);
@@ -304,8 +304,8 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
return (
<div className="relative w-full h-full overflow-hidden">
- <div
- ref={viewerRef}
+ <div
+ ref={viewerRef}
className="w-full h-full"
style={{
position: 'relative',
@@ -336,11 +336,11 @@ export function SecurePDFViewer({ documentUrl, fileName, onClose }: SecurePDFVie
</div>
)}
</div>
-
+
{/* 보안 오버레이 */}
- <div
+ <div
className="absolute inset-0 z-10 pointer-events-none"
- style={{
+ style={{
background: 'transparent',
userSelect: 'none',
WebkitUserSelect: 'none',