기술 문서

HotPDF Delphi 구성 요소로 PDF 주석 마스터하기

· PDF 프로그래밍

HotPDF 컴포넌트를 사용한 PDF 주석 마스터하기

PDF 주석은 대화형 및 협업 문서를 만드는 데 가장 강력한 기능 중 하나입니다. 이를 통해 사용자는 원본 문서 구조를 변경하지 않고도 PDF 파일에 직접 댓글, 강조 표시, 스탬프 및 멀티미디어 콘텐츠를 추가할 수 있습니다. 이 종합 가이드에서는 다양한 유형의 PDF 주석 구현 방법을 살펴봅니다. HotPDF Component, 기본 텍스트 주석부터 고급 멀티미디어 첨부 파일까지 모든 것을 다룹니다.

PDF 주석 이해: 단순히 댓글 이상의 기능

PDF 주석은 PDF 페이지에 추가하여 추가 정보, 상호 작용 또는 시각적 향상을 제공할 수 있는 객체입니다. 일반 페이지 콘텐츠와 달리 주석은 별도의 객체로 저장되며, 기본 문서 구조에 영향을 주지 않고 표시하거나 숨기거나, 편집하거나, 제거할 수 있습니다. 따라서 다음과 같은 용도로 이상적입니다.

  • 문서 검토: 댓글, 메모 및 피드백 추가
  • 양식 개선: 대화형 요소 및 도움말 텍스트 생성.
  • 멀티미디어 통합: 오디오, 비디오 및 파일 첨부 파일 임베딩.
  • 시각적 강조: 스탬프 및 도형을 사용하여 중요한 섹션 강조.
  • 협업 워크플로우: 여러 사용자가 충돌 없이 기여할 수 있도록 지원.
HotPDF Component PDF Annotations Delphi Sample
HotPDF 컴포넌트에서 생성된 PDF 문서, Delphi 샘플 프로젝트의 PDF 주석.

빠른 시작: 간단한 텍스트 주석 예제

PDF 주석의 핵심 개념을 이해하기 위해 기본적인 텍스트 주석 예제를 시작해 보겠습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
program SimpleAnnotation;
{$I ..\..\..\Lib\HotPDF.inc}
{$APPTYPE CONSOLE}
 
uses
  {$IFDEF XE2+}
  System.Classes,
  System.SysUtils,
  Vcl.Graphics,
  {$ELSE}
  Classes,
  SysUtils,
  Graphics,
  {$ENDIF}
  HPDFDoc;
 
var
  HotPDF: THotPDF;
begin
  HotPDF := THotPDF.Create(nil);
  try
    // Configure PDF basic properties
    HotPDF.FileName := 'SimpleAnnotation.pdf';
    HotPDF.Title := 'Simple Annotation Demo';
    HotPDF.Author := 'HotPDF Component';
    
    // Set font embedding for consistent display
    HotPDF.FontEmbedding := True;
    
    HotPDF.BeginDoc;
    
    // Set font
    HotPDF.CurrentPage.SetFont('Arial', [], 12, 0, False);
    
    // Add page content
    HotPDF.CurrentPage.TextOut(120, 65, 0, 'Click the annotation icon:');
    
    // Add multilingual text annotations
    HotPDF.CurrentPage.AddTextAnnotation(
      'This is a text annotation.' + #13#10 +
      'Dies ist eine Textanmerkung.' + #13#10 +
      'Ceci est une annotation textuelle.' + #13#10 +
      'This is a text annotation.',
      Rect(120, 80, 140, 100), True, taComment, clBlue
    );
    
    HotPDF.EndDoc;
  finally
    HotPDF.Free;
  end;
end.

이 간단한 예제는 PDF 주석의 여러 핵심 개념을 보여줍니다.

  • 위치 지정: The Rect(120, 80, 140, 100) parameter는 주석의 클릭 가능한 영역을 정의합니다.
  • 다국어 지원: 콘텐츠에는 영어, 독일어, 프랑스어 및 중국어 텍스트가 포함됩니다.
  • 가시성 제어: The True parameter는 초기 상태를 열린 상태로 설정합니다.
  • 어노테이션 유형: taComment 표준 주석 어노테이션을 생성합니다.
  • 시각적 사용자 정의: clBlue 어노테이션의 색상을 설정합니다.
  • 글꼴 임베딩: FontEmbedding := True 다양한 뷰어에서 일관된 표시를 보장합니다.

전체 어노테이션 유형 참조.

HotPDF 컴포넌트는 다양한 어노테이션 유형을 지원하며, 각 유형은 특정 사용 사례에 최적화되어 있습니다.

1. 텍스트 어노테이션

텍스트 어노테이션은 가장 일반적으로 사용되는 유형이며, 다양한 표시 스타일을 제공합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Available text annotation type enumeration
THPDFTextAnnotationType = (
  taComment,        // Standard comment bubble
  taKey,           // Key symbol for important notes
  taNote,          // Note icon for general information
  taHelp,          // Help icon for help text
  taNewParagraph,  // New paragraph marker
  taParagraph,     // Paragraph marker
  taInsert         // Content insertion marker
);
 
// Usage examples for different types
procedure AddTextAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding text annotations...');
 
  // Section header text
  PDF.CurrentPage.TextOut(50, 80, 0, 'Text Annotations - Different Types and Colors:');
 
  // Critical annotation with multilingual content
  PDF.CurrentPage.AddTextAnnotation(
    'CRITICAL: This is a critical comment annotation requiring immediate attention.' + #13#10 +
    'KRITISCH: Dies ist eine kritische Textanmerkung.' + #13#10 +
    'CRITIQUE: Ceci est une annotation critique.',
    Rect(50, 95, 70, 115), True, taComment, clRed
  );
 
  // Key point annotation
  PDF.CurrentPage.AddTextAnnotation(
    'KEY POINT: Important information marker' + #13#10 +
    'This annotation uses the key icon for emphasis.',
    Rect(80, 100, 100, 120), False, taKey, $0080FF // Orange
  );
 
  // Help annotation
  PDF.CurrentPage.AddTextAnnotation(
    'HELP: Click for additional assistance' + #13#10 +
    'This help annotation provides user guidance.',
    Rect(110, 100, 130, 120), False, taHelp, clBlue
  );
 
  // General note annotation
  PDF.CurrentPage.AddTextAnnotation(
    'NOTE: General information annotation' + #13#10 +
    'Standard note for supplementary information.',
    Rect(140, 100, 160, 120), False, taNote, clGreen
  );
 
  // Insert marker annotation
  PDF.CurrentPage.AddTextAnnotation(
    'INSERT: Content insertion marker' + #13#10 +
    'Indicates where new content should be added.',
    Rect(170, 100, 190, 120), False, taInsert, $800080 // Purple
  );
end;

2. 자유 텍스트 어노테이션

자유 텍스트 어노테이션은 사용자 상호 작용 없이 텍스트를 페이지에 직접 표시합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Free text alignment options enumeration
THPDFFreeTextAnnotationJust = (
  ftLeftJust,   // Left-aligned text
  ftCenter,     // Center-aligned text
  ftRightJust   // Right-aligned text
);
 
// Example: Create free text annotations with different alignments
procedure AddFreeTextAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding free text annotations...');
 
  // Section header
  PDF.CurrentPage.TextOut(50, 160, 0, 'Free Text Annotations - Different Alignments:');
 
  // Left-justified free text
  PDF.CurrentPage.AddFreeTextAnnotation(
    'LEFT TEXT ANNOTATION',
    Rect(50, 180, 200, 200),
    ftLeftJust,
    $008000 // Green
  );
 
  // Center-justified free text
  PDF.CurrentPage.AddFreeTextAnnotation(
    'CENTERED Text',
    Rect(220, 180, 370, 200),
    ftCenter,
    $0080FF // Orange
  );
 
  // Right-justified free text
  PDF.CurrentPage.AddFreeTextAnnotation(
    'RIGHT ANNOTATION',
    Rect(390, 180, 540, 200),
    ftRightJust,
    clFuchsia // Fuchsia
  );
 
  // Document status annotation
  PDF.CurrentPage.AddFreeTextAnnotation(
    'CONFIDENTIAL DOCUMENT',
    Rect(200, 210, 400, 230),
    ftCenter,
    clRed
  );
end;

3. 기하학적 어노테이션

선 및 도형 어노테이션은 시각적 강조 및 마킹 기능을 제공합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Line and shape annotation examples
procedure AddGeometricAnnotationExamples(PDF: THotPDF);
var
  StartPoint, EndPoint: THPDFCurrPoint;
begin
  WriteLn('Adding geometric annotations...');
 
  // Section header
  PDF.CurrentPage.TextOut(50, 250, 0, 'Geometric Annotations - Lines and Shapes:');
 
  // Line annotation - diagonal
  StartPoint.X := 50;
  StartPoint.Y := 270;
  EndPoint.X := 150;
  EndPoint.Y := 290;
  
  PDF.CurrentPage.AddLineAnnotation(
    'Diagonal line pointing to important content',
    StartPoint,
    EndPoint,
    $0080FF // Orange
  );
  
  // Line annotation - horizontal
  StartPoint.X := 170;
  StartPoint.Y := 280;
  EndPoint.X := 270;
  EndPoint.Y := 280;
  
  PDF.CurrentPage.AddLineAnnotation(
    'Horizontal line for emphasis',
    StartPoint,
    EndPoint,
    clBlue
  );
 
  // Circle annotation
  PDF.CurrentPage.AddCircleSquareAnnotation(
    'Circle highlighting important area',
    Rect(50, 300, 120, 320),
    csCircle,
    clGreen
  );
 
  // Square annotation
  PDF.CurrentPage.AddCircleSquareAnnotation(
    'Square frame for emphasis',
    Rect(140, 300, 210, 320),
    csSquare,
    $800080 // Purple
  );
end;
 
// Circle and square annotation types
THPDFCSAnnotationType = (csCircle, csSquare);

4. 스탬프 어노테이션

스탬프 주석은 문서 상태 및 워크플로우에 대한 미리 정의된 시각적 마커를 제공합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Available stamp type enumeration
THPDFStampAnnotationType = (
  satApproved,              // Green "Approved" stamp
  satExperimental,          // "Experimental" marker
  satNotApproved,           // Red "Not Approved" stamp
  satAsIs,                  // "As Is" status
  satExpired,               // "Expired" warning
  satNotForPublicRelease,   // Confidential marker
  satConfidential,          // "Confidential" stamp
  satFinal,                 // "Final" marker
  satSold,                  // "Sold" status
  satDepartmental,          // Department-specific marker
  satForComment,            // "For Comment" review stamp
  satTopSecret              // "Top Secret" classification
);
 
// Example: Add various stamp annotations
procedure AddStampAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding stamp annotations...');
 
  // Section header
  PDF.CurrentPage.TextOut(50, 340, 0, 'Stamp Annotations - Document Status Markers:');
 
  // Approval stamps
  PDF.CurrentPage.AddStampAnnotation(
    'Document approved for release',
    Rect(50, 360, 150, 390),
    satApproved,
    clGreen
  );
 
  PDF.CurrentPage.AddStampAnnotation(
    'Document rejected - requires revision',
    Rect(170, 360, 270, 390),
    satNotApproved,
    clRed
  );
 
  // Security stamps
  PDF.CurrentPage.AddStampAnnotation(
    'Confidential information marker',
    Rect(290, 360, 390, 390),
    satConfidential,
    clRed
  );
 
  PDF.CurrentPage.AddStampAnnotation(
    'Final version stamp',
    Rect(410, 360, 510, 390),
    satFinal,
    clBlue
  );
 
  // Workflow stamps
  PDF.CurrentPage.AddStampAnnotation(
    'For comment and review',
    Rect(50, 400, 150, 430),
    satForComment,
    $800080 // Purple
  );
 
  PDF.CurrentPage.AddStampAnnotation(
    'Experimental version',
    Rect(170, 400, 270, 430),
    satExperimental,
    $0080FF // Orange
  );
end;

멀티미디어 주석: 텍스트 상호 작용을 넘어

최신 PDF 워크플로우는 종종 멀티미디어 통합을 필요로 합니다. HotPDF 구성 요소는 멀티미디어 주석을 지원합니다.

5. 파일 첨부 주석

파일 첨부 주석을 사용하면 외부 파일을 PDF 문서에 포함할 수 있습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// File attachment annotation example
procedure AddMultimediaAnnotationExamples(PDF: THotPDF);
var
  DemoTextFile, DemoAudioFile: string;
  DemoContent: TStringList;
begin
  WriteLn('Adding multimedia annotations...');
 
  // Section header
  PDF.CurrentPage.TextOut(50, 450, 0, 'Multimedia Annotations - Files, Audio, and Video:');
 
  // Create demo text file if it doesn't exist
  DemoTextFile := 'DemoAttachment.txt';
  if not FileExists(DemoTextFile) then
  begin
    DemoContent := TStringList.Create;
    try
      DemoContent.Add('HotPDF Component Demo Attachment');
      DemoContent.Add('================================');
      DemoContent.Add('This is a sample text file attached to the PDF document.');
      DemoContent.Add('It demonstrates the file attachment annotation capability.');
      DemoContent.Add('Created: ' + DateTimeToStr(Now));
      DemoContent.SaveToFile(DemoTextFile);
    finally
      DemoContent.Free;
    end;
  end;
 
  // File attachment annotation
  PDF.CurrentPage.AddFileAttachmentAnnotation(
    'Demo text file attachment',
    DemoTextFile,
    Rect(50, 470, 90, 490),
    clBlue
  );
 
  // Multiple file attachment examples
  PDF.CurrentPage.AddFileAttachmentAnnotation(
    'Legal agreement document',
    'Contract.docx',
    Rect(100, 470, 140, 490),
    clPurple
  );
 
  PDF.CurrentPage.AddFileAttachmentAnnotation(
    'Reference image for comparison',
    'Reference.png',
    Rect(150, 470, 190, 490),
    clGreen
  );
end;

6. 오디오 주석

오디오 주석을 사용하면 음성 메모 또는 설명을 위해 오디오 파일을 포함할 수 있습니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Sound annotation example
procedure AddSoundAnnotationExample(PDF: THotPDF);
var
  DemoAudioFile: string;
begin
  // Check for existing multimedia files and add annotations
  DemoAudioFile := 'Music.wav';
  if FileExists(DemoAudioFile) then
  begin
    PDF.CurrentPage.AddSoundAnnotation(
      'Demo audio file - Click to play',
      DemoAudioFile,
      Rect(110, 470, 150, 490),
      clGreen
    );
  end
  else
  begin
    PDF.CurrentPage.AddTextAnnotation(
      'Audio file not found: ' + DemoAudioFile,
      Rect(110, 470, 130, 490),
      False,
      taNote,
      $0080FF // Orange
    );
  end;
 
  // Multi-language sound annotation example
  PDF.CurrentPage.AddSoundAnnotation(
    'English narration',
    'Narration_EN.mp3',
    Rect(60, 350, 100, 390),
    clBlue
  );
 
  PDF.CurrentPage.AddSoundAnnotation(
    'Chinese narration',
    'Narration_CN.mp3',
    Rect(110, 350, 150, 390),
    clGreen
  );
end;

완전한 주석 예제: 향상된 데모 프로젝트

다음은 모든 주석 유형을 단일 포괄적인 프로젝트에서 보여주는 완전하고 업데이트된 예제입니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
{***********************************************************}
// HotPDF PDF Component - Enhanced Annotations Demo Delphi
// Copyright(c)2007-2025, https://www.loslab.com
// This demo showcases comprehensive annotation functionality
{***********************************************************}
 
program Annotations;
{$I ..\..\..\Lib\HotPDF.inc}
{$APPTYPE CONSOLE}
 
uses
  {$IFDEF XE2+}
  System.Classes,
  System.SysUtils,
  Vcl.Graphics,
  {$ELSE}
  Classes,
  SysUtils,
  Graphics,
  {$ENDIF}
  HPDFDoc;
 
var
  HotPDF: THotPDF;
 
// ... existing code ...
 
procedure AddDocumentationAndFooter(PDF: THotPDF);
begin
  WriteLn('Adding documentation and footer...');
 
  // Documentation section
  PDF.CurrentPage.TextOut(50, 510, 0, 'Annotation Usage Guidelines:');
  PDF.CurrentPage.TextOut(50, 530, 0, '• Red annotations indicate critical issues requiring immediate attention');
  PDF.CurrentPage.TextOut(50, 545, 0, '• Orange annotations show warnings and cautions');
  PDF.CurrentPage.TextOut(50, 560, 0, '• Blue annotations provide general information');
  PDF.CurrentPage.TextOut(50, 575, 0, '• Green annotations mark completed or approved items');
  PDF.CurrentPage.TextOut(50, 590, 0, '• Purple annotations indicate items requiring review');
 
  // Technical information
  PDF.CurrentPage.TextOut(50, 620, 0, 'Technical Details:');
  PDF.CurrentPage.TextOut(50, 635, 0, '• All annotations are interactive and can be opened/closed by users');
  PDF.CurrentPage.TextOut(50, 650, 0, '• Multimedia annotations require compatible PDF viewers');
  PDF.CurrentPage.TextOut(50, 665, 0, '• File attachments are embedded within the PDF document');
 
  // Footer
  PDF.CurrentPage.TextOut(50, 730, 0, 'HotPDF Component - Enhanced Annotations Demo (Delphi)');
  PDF.CurrentPage.TextOut(50, 745, 0, 'Generated: ' + DateTimeToStr(Now));
  PDF.CurrentPage.TextOut(50, 760, 0, 'Visit https://www.loslab.com for more information');
 
  // Add a final summary annotation
  PDF.CurrentPage.AddTextAnnotation(
    'SUMMARY: This document demonstrates all annotation types supported by HotPDF Component.' + #13#10 +
    'Each annotation type serves specific purposes in document workflow and user interaction.' + #13#10 +
    'For technical support and documentation, visit https://www.loslab.com',
    Rect(450, 740, 470, 760),
    False,
    taNote,
    clBlue
  );
end;
 
begin
  WriteLn('HotPDF Enhanced Annotations Demo (Delphi)');
  WriteLn('=========================================');
  WriteLn('Creating comprehensive PDF with all annotation types...');
  WriteLn('');
 
  HotPDF := THotPDF.Create(nil);
  try
    try
      // Configure PDF properties
      HotPDF.FileName := 'HotPDF-Annotations.pdf';
      HotPDF.Title := 'HotPDF Annotations Demo (Delphi)';
      HotPDF.Author := 'HotPDF Component';
      HotPDF.Subject := 'Comprehensive annotation examples';
      HotPDF.Keywords := 'PDF, Annotations, HotPDF, Demo, Interactive, Delphi';
 
      // Set font embedding for consistent display
      HotPDF.FontEmbedding := True;
 
      // Enable FlateDecode compression for smaller file sizes
      HotPDF.Compression := cmFlateDecode;
      
      // Set initial zoom to fit page height in window
      HotPDF.InitialZoom := izFitV;
 
      HotPDF.BeginDoc;
      
      // Use standard font
      HotPDF.CurrentPage.SetFont('Arial', [], 12, 0, False);
 
      // Add page title
      HotPDF.CurrentPage.TextOut(150, 40, 0, 'HotPDF Component - Annotations Showcase (Delphi)');
 
      // Add all annotation examples
      AddTextAnnotationExamples(HotPDF);
      AddFreeTextAnnotationExamples(HotPDF);
      AddGeometricAnnotationExamples(HotPDF);
      AddStampAnnotationExamples(HotPDF);
      AddMultimediaAnnotationExamples(HotPDF);
      AddDocumentationAndFooter(HotPDF);
 
      HotPDF.EndDoc;
 
      WriteLn('Annotations PDF created successfully!');
      WriteLn('');
      WriteLn('Output file: ' + HotPDF.FileName);
      WriteLn('');
      WriteLn('The PDF contains:');
      WriteLn('• Text annotations with different types and colors');
      WriteLn('• Free text annotations with various alignments');
      WriteLn('• Geometric annotations (lines, circles, squares)');
      WriteLn('• Stamp annotations for document workflow');
      WriteLn('• Multimedia annotations (file, audio, video)');
      WriteLn('• Comprehensive documentation and usage guidelines');
 
    except
      on E: Exception do
      begin
        WriteLn('Error creating PDF: ' + E.Message);
        ExitCode := 1;
      end;
    end;
 
  finally
    HotPDF.Free;
  end;
end.

PDF 주석에 대한 최적의 방법

1. 현대적인 코드 구조 및 호환성

업데이트된 HotPDF 구성 요소는 최신 Delphi 코딩 방식을 사용합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Modern unit structure with conditional compilation
uses
  {$IFDEF XE2+}
  System.Classes,
  System.SysUtils,
  Vcl.Graphics,
  {$ELSE}
  Classes,
  SysUtils,
  Graphics,
  {$ENDIF}
  HPDFDoc;
 
// Enhanced PDF configuration
procedure ConfigureModernPDF(PDF: THotPDF);
begin
  // Font embedding for consistent display across viewers
  PDF.FontEmbedding := True;
  
  // FlateDecode compression for smaller file sizes
  PDF.Compression := cmFlateDecode;
  
  // Initial zoom setting for better user experience
  PDF.InitialZoom := izFitV; // Fit to page height
  
  // Complete metadata for better document management
  PDF.Title := 'Professional PDF with Annotations';
  PDF.Author := 'HotPDF Component';
  PDF.Subject := 'Comprehensive annotation examples';
  PDF.Keywords := 'PDF, Annotations, Interactive, Professional';
end;

2. 오류 처리 및 안정성

프로덕션 애플리케이션에 대한 적절한 오류 처리를 구현합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Robust file handling with error checking
procedure SafeAddFileAttachment(PDF: THotPDF; const FileName: string; const Description: string);
begin
  if FileExists(FileName) then
  begin
    PDF.CurrentPage.AddFileAttachmentAnnotation(
      Description,
      FileName,
      Rect(10, 10, 50, 50),
      clGreen
    );
  end
  else
  begin
    // Add error annotation instead
    PDF.CurrentPage.AddTextAnnotation(
      Format('File not found: %s', [ExtractFileName(FileName)]),
      Rect(10, 10, 30, 30),
      True,
      taKey,
      clRed
    );
  end;
end;
 
// Exception handling in main program
begin
  HotPDF := THotPDF.Create(nil);
  try
    try
      // PDF creation code here
      HotPDF.BeginDoc;
      // ... annotation code ...
      HotPDF.EndDoc;
      
      WriteLn('PDF created successfully!');
    except
      on E: Exception do
      begin
        WriteLn('Error creating PDF: ' + E.Message);
        ExitCode := 1;
      end;
    end;
  finally
    HotPDF.Free;
  end;
end;

3. 색상 일관성 및 시각적 디자인

더 나은 사용자 경험을 위해 일관된 색상 구성표를 사용합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Color constants for consistent annotation design
const
  ANNOTATION_COLOR_ERROR = clRed;
  ANNOTATION_COLOR_WARNING = $0080FF;    // Orange
  ANNOTATION_COLOR_INFO = clBlue;
  ANNOTATION_COLOR_SUCCESS = clGreen;
  ANNOTATION_COLOR_REVIEW = $800080;     // Purple
 
// Consistent color application
procedure AddColorCodedAnnotations(PDF: THotPDF);
begin
  // Error annotation
  PDF.CurrentPage.AddTextAnnotation(
    'ERROR: Critical issue requiring immediate attention',
    Rect(50, 100, 70, 120),
    True,
    taKey,
    ANNOTATION_COLOR_ERROR
  );
 
  // Warning annotation
  PDF.CurrentPage.AddTextAnnotation(
    'WARNING: Caution required',
    Rect(80, 100, 100, 120),
    False,
    taComment,
    ANNOTATION_COLOR_WARNING
  );
 
  // Information annotation
  PDF.CurrentPage.AddTextAnnotation(
    'INFO: Additional information available',
    Rect(110, 100, 130, 120),
    False,
    taNote,
    ANNOTATION_COLOR_INFO
  );
end;

대용량 문서의 성능 최적화

1. 절차를 통한 체계적인 접근 방식

업데이트된 예제는 더 나은 유지 관성을 위해 모듈화된 접근 방식을 사용합니다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
// Modular annotation management
procedure AddTextAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding text annotations...');
  // Text annotation code here
end;
 
procedure AddFreeTextAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding free text annotations...');
  // Free text annotation code here
end;
 
procedure AddGeometricAnnotationExamples(PDF: THotPDF);
begin
  WriteLn('Adding geometric annotations...');
  // Geometric annotation code here
end;
 
// Main execution with clear structure
begin
  HotPDF := THotPDF.Create(nil);
  try
    // Configure PDF
    HotPDF.FileName := 'HotPDF-Annotations.pdf';
    HotPDF.FontEmbedding := True;
    HotPDF.Compression := cmFlateDecode;
    HotPDF.InitialZoom := izFitV;
    
    HotPDF.BeginDoc;
    HotPDF.CurrentPage.SetFont('Arial', [], 12, 0, False);
    
    // Add all annotation examples in organized manner
    AddTextAnnotationExamples(HotPDF);
    AddFreeTextAnnotationExamples(HotPDF);
    AddGeometricAnnotationExamples(HotPDF);
    AddStampAnnotationExamples(HotPDF);
    AddMultimediaAnnotationExamples(HotPDF);
    AddDocumentationAndFooter(HotPDF);
    
    HotPDF.EndDoc;
  finally
    HotPDF.Free;
  end;
end;

2. 메모리 관리 및 리소스 정리

안정적인 운영을 위한 적절한 리소스 관리:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Proper resource management
procedure CreateAnnotatedPDF;
var
  HotPDF: THotPDF;
  TempFiles: TStringList;
begin
  HotPDF := THotPDF.Create(nil);
  TempFiles := TStringList.Create;
  try
    try
      // Create temporary files for demonstration
      CreateDemoFiles(TempFiles);
      
      // Configure and create PDF
      ConfigurePDF(HotPDF);
      HotPDF.BeginDoc;
      
      // Add annotations
      AddAllAnnotations(HotPDF, TempFiles);
      
      HotPDF.EndDoc;
      WriteLn('PDF created successfully!');
      
    except
      on E: Exception do
      begin
        WriteLn('Error: ' + E.Message);
        raise; // Re-raise for proper error handling
      end;
    end;
  finally
    // Clean up resources
    TempFiles.Free;
    HotPDF.Free;
    
    // Clean up temporary files
    CleanupTempFiles;
  end;
end;

고급 기능 및 최신 개선 사항

1. 압축 및 최적화

업데이트된 구성 요소에는 향상된 압축 옵션이 포함되어 있습니다.

1
2
3
4
// Modern compression settings
HotPDF.Compression := cmFlateDecode;  // Best compression ratio
HotPDF.FontEmbedding := True;         // Consistent font display
HotPDF.InitialZoom := izFitV;         // Optimal viewing experience

2. 향상된 메타데이터 지원

전문 문서에 대한 완전한 문서 메타데이터 제공:

1
2
3
4
5
6
7
8
9
10
// Complete metadata configuration
procedure ConfigureDocumentMetadata(PDF: THotPDF);
begin
  PDF.Title := 'Professional PDF with Annotations';
  PDF.Author := 'HotPDF Component';
  PDF.Subject := 'Comprehensive annotation examples';
  PDF.Keywords := 'PDF, Annotations, HotPDF, Demo, Interactive, Delphi';
  PDF.Creator := 'HotPDF Component Demo';
  PDF.Producer := 'HotPDF Component v2.x';
end;

결론

업데이트된 HotPDF 컴포넌트는 최신 Delphi 코딩 방식을 사용하여 PDF 주석에 대한 포괄적인 지원을 제공합니다. 향상된 데모 프로젝트는 개선된 코드 구조, 오류 처리 및 리소스 관리 기능을 갖춘 모든 주석 유형을 보여줍니다.

업데이트된 버전의 주요 개선 사항:

  • 현대적인 코드 구조: XE2 이상 버전과의 호환성을 위해 조건부 컴파일 사용
  • 향상된 오류 처리: 강력한 예외 처리 및 리소스 정리
  • 성능 향상: FlateDecode 압축 및 글꼴 임베딩
  • 향상된 구성: 다양한 주석 유형에 대한 모듈식 절차
  • 전문가용 기능: 완벽한 메타데이터 지원 및 최적화 설정
  • 포괄적인 예제: 모든 주석 유형에 대한 실용적인 사용 사례

문서 검토 시스템, 대화형 폼 또는 멀티미디어 콘텐츠가 풍부한 프레젠테이션을 개발하든, 업데이트된 HotPDF Component는 전문적이고 기능이 풍부한 PDF 문서를 만들고 포괄적인 주석 기능을 지원하는 데 필요한 도구와 예제를 제공합니다.

전체 소스 코드는 Demo/Delphi/Annotations 디렉터리에 있으며, PDF 주석 프로젝트의 견고한 기반을 제공합니다.