-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathharupdf.annotation.pas
616 lines (543 loc) · 21.2 KB
/
harupdf.annotation.pas
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
unit harupdf.annotation;
{ MIT License
Copyright (c) 2017 THaruPDF, Damian Woroch, http://r1me.pl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE. }
{$IFDEF FPC}{$mode objfpc}{$H+}{$ENDIF}
interface
uses
{$IFNDEF FPC}
System.Classes,
System.Types,
System.Generics.Collections,
{$ELSE}
Classes,
Types,
fgl,
{$ENDIF}
hpdf,
hpdf_types,
harupdf.encoder,
harupdf.destination,
harupdf.image,
harupdf.view3d;
type
THaruAnnotation = class(TObject)
protected
FAnnotationHandle: HPDF_Annotation;
public
property AnnotationHandle: HPDF_Annotation read FAnnotationHandle;
//
procedure SetRGBColor(AColor: THPDF_RGBColor);
//
procedure SetCMYKColor(AColor: THPDF_CMYKColor);
//
procedure SetGrayColor(AColor: Single);
//
procedure SetNoColor;
// Defines the border appearance of a text annotation
procedure SetBorderStyle(ABorderStyle: THPDF_BSSubtype; AWidth: Single; ADashOn, ADashOff, ADashPhase: Word);
//
procedure Set3DView(AMmgr: HPDF_MMgr; A3DAnnotation: THaruAnnotation; AView: THaru3DView);
// Defines the appearance when a mouse clicks on a link annotation
procedure LinkAnnot_SetHighlightMode(AMode: THPDF_AnnotHighlightMode);
//
procedure LinkAnnot_SetJavaScript(AJavaScript: HPDF_JavaScript);
// Defines the style of the annotation's border
procedure LinkAnnot_SetBorderStyle(AWidth: Single; ADashOn: Word; ADashOff: Word);
// Defines the style of the annotation's icon
procedure TextAnnot_SetIcon(AIcon: THPDF_AnnotIcon);
// Defines whether the text-annotation is initially open
procedure TextAnnot_SetOpened(AOpened: Boolean);
//
procedure MarkupAnnot_SetTitle(ATitle: String; ATitlePtr: Pointer = nil);
//
procedure MarkupAnnot_SetSubject(ASubject: String; ASubjectPtr: Pointer = nil);
//
procedure MarkupAnnot_SetCreationDate(ADate: TDateTime);
//
procedure MarkupAnnot_SetTransparency(AValue: Single);
//
procedure MarkupAnnot_SetIntent(AIntent: THPDF_AnnotIntent);
//
procedure MarkupAnnot_SetPopup(APopup: THaruAnnotation);
//
procedure MarkupAnnot_SetRectDiff(ARect: TRectF);
//
procedure MarkupAnnot_SetCloudEffect(ACloudIntensity: Integer);
//
procedure MarkupAnnot_SetInteriorRGBColor(AColor: THPDF_RGBColor);
//
procedure MarkupAnnot_SetInteriorCMYKColor(AColor: THPDF_CMYKColor);
//
procedure MarkupAnnot_SetInteriorGrayColor(AColor: Single);
//
procedure MarkupAnnot_SetInteriorTransparent();
//
procedure TextMarkupAnnot_SetQuadPoints(Alb, Arb, Art, Alt: TPointF);
//
procedure PopupAnnot_SetOpened(AOpened: Boolean);
//
procedure FreeTextAnnot_SetLineEndingStyle(AStartStyle, AEndStyle: THPDF_LineAnnotEndingStyle);
//
procedure FreeTextAnnot_Set3PointCalloutLine(AStartPoint, AKneePoint, AEndPoint: TPointF);
//
procedure FreeTextAnnot_Set2PointCalloutLine(AStartPoint, AEndPoint: TPointF);
//
procedure FreeTextAnnot_SetDefaultStyle(AStyle: String);
//
procedure LineAnnot_SetPosition(AStartPoint, AEndPoint: TPointF; AStartStyle, AEndStyle: THPDF_LineAnnotEndingStyle);
//
procedure LineAnnot_SetLeader(ALeaderLen: Integer; ALeaderExtLen: Integer;
ALeaderOffsetLen: Integer);
//
procedure LineAnnot_SetCaption(AShowCaption: Boolean; APosition: THPDF_LineAnnotCapPosition;
AHorzOffset, AVertOffset: Integer);
//
procedure ProjectionAnnot_SetExData(AExData: HPDF_ExData);
class function GetAnnotationHandle(AAnnotation: THaruAnnotation): HPDF_Annotation;
constructor Create(AAnnotation: HPDF_Annotation);
end;
THaruAnnotationsList = {$IFNDEF FPC}TObjectList{$ELSE}specialize TFPGObjectList{$ENDIF}<THaruAnnotation>;
type
THaruAnnotations = class(TObject)
protected
FOwnerPage: TObject;
FOwnerDocument: TObject;
FAnnotations: THaruAnnotationsList;
public
property Items: THaruAnnotationsList read FAnnotations;
//
function Add3DAnnot(ARect: TRectF; AToolBar: Boolean; ANavigationPanel: Boolean;
AU3D: THaruU3D; AAppearanceImage: THaruImage): THaruAnnotation;
//
function AddTextAnnot(ARect: TRectF; AText: String; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddFreeTextAnnot(ARect: TRectF; AText: String; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddLineAnnot(AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil): THaruAnnotation;
//
function AddWidgetAnnot_WhiteOnlyWhilePrint(ARect: TRectF): THaruAnnotation;
//
function AddWidgetAnnot(ARect: TRectF): THaruAnnotation;
//
function AddLinkAnnot(ARect: TRectF; ADestination: THaruDestination): THaruAnnotation;
//
function AddURILinkAnnot(ARect: TRectF; AURI: string): THaruAnnotation;
//
function AddHighlightAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddUnderlineAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddSquigglyAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddStrikeOutAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddPopupAnnot(ARect: TRectF; AParent: THaruAnnotation): THaruAnnotation;
//
function AddStampAnnot(ARect: TRectF; AName: THPDF_StampAnnotName; AText: string; AEncoder:
THaruEncoder = nil; ATextPtr: Pointer = nil): THaruAnnotation;
//
function AddProjectionAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddSquareAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
//
function AddCircleAnnot(ARect: TRectF; AText: string; AEncoder: THaruEncoder = nil; ATextPtr: Pointer = nil):
THaruAnnotation;
constructor Create(AOwnerPage: TObject; ADocument: TObject);
destructor Destroy; override;
end;
implementation
uses
harupdf.document,
harupdf.page,
harupdf.utils;
{ THaruAnnotation }
constructor THaruAnnotation.Create(AAnnotation: HPDF_Annotation);
begin
FAnnotationHandle := AAnnotation;
end;
procedure THaruAnnotation.SetRGBColor(AColor: THPDF_RGBColor);
begin
HPDF_Annot_SetRGBColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.SetCMYKColor(AColor: THPDF_CMYKColor);
begin
HPDF_Annot_SetCMYKColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.SetGrayColor(AColor: Single);
begin
HPDF_Annot_SetGrayColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.SetNoColor;
begin
HPDF_Annot_SetNoColor(FAnnotationHandle);
end;
procedure THaruAnnotation.SetBorderStyle(ABorderStyle: THPDF_BSSubtype; AWidth: Single; ADashOn,
ADashOff, ADashPhase: Word);
begin
HPDF_Annotation_SetBorderStyle(FAnnotationHandle, ABorderStyle, AWidth, ADashOn, ADashOff,
ADashPhase);
end;
procedure THaruAnnotation.Set3DView(AMmgr: HPDF_MMgr; A3DAnnotation: THaruAnnotation; AView: THaru3DView);
begin
HPDF_Annot_Set3DView(AMmgr, FAnnotationHandle, A3DAnnotation.AnnotationHandle, AView);
end;
procedure THaruAnnotation.LinkAnnot_SetHighlightMode(AMode: THPDF_AnnotHighlightMode);
begin
HPDF_LinkAnnot_SetHighlightMode(FAnnotationHandle, AMode);
end;
procedure THaruAnnotation.LinkAnnot_SetJavaScript(AJavaScript: HPDF_JavaScript);
begin
HPDF_LinkAnnot_SetJavaScript(FAnnotationHandle, AJavaScript);
end;
procedure THaruAnnotation.LinkAnnot_SetBorderStyle(AWidth: Single; ADashOn: Word; ADashOff: Word);
begin
HPDF_LinkAnnot_SetBorderStyle(FAnnotationHandle, AWidth, ADashOn, ADashOff);
end;
procedure THaruAnnotation.TextAnnot_SetIcon(AIcon: THPDF_AnnotIcon);
begin
HPDF_TextAnnot_SetIcon(FAnnotationHandle, AIcon)
end;
procedure THaruAnnotation.TextAnnot_SetOpened(AOpened: Boolean);
begin
HPDF_TextAnnot_SetOpened(FAnnotationHandle, BooleanToHaruBool(AOpened));
end;
procedure THaruAnnotation.MarkupAnnot_SetTitle(ATitle: String; ATitlePtr: Pointer = nil);
var
pTitle: PUTF8Char;
begin
pTitle := StringToPUTF8Char(ATitle, ATitlePtr);
HPDF_MarkupAnnot_SetTitle(FAnnotationHandle, pTitle);
end;
procedure THaruAnnotation.MarkupAnnot_SetSubject(ASubject: String; ASubjectPtr: Pointer = nil);
var
pSubject: PUTF8Char;
begin
pSubject := StringToPUTF8Char(ASubject, ASubjectPtr);
HPDF_MarkupAnnot_SetSubject(FAnnotationHandle, pSubject);
end;
procedure THaruAnnotation.MarkupAnnot_SetCreationDate(ADate: TDateTime);
begin
HPDF_MarkupAnnot_SetCreationDate(FAnnotationHandle, DateTimeToHPDFDate(ADate));
end;
procedure THaruAnnotation.MarkupAnnot_SetTransparency(AValue: Single);
begin
HPDF_MarkupAnnot_SetTransparency(FAnnotationHandle, AValue);
end;
procedure THaruAnnotation.MarkupAnnot_SetIntent(AIntent: THPDF_AnnotIntent);
begin
HPDF_MarkupAnnot_SetIntent(FAnnotationHandle, AIntent);
end;
procedure THaruAnnotation.MarkupAnnot_SetPopup(APopup: THaruAnnotation);
begin
HPDF_MarkupAnnot_SetPopup(FAnnotationHandle, APopup.AnnotationHandle);
end;
procedure THaruAnnotation.MarkupAnnot_SetRectDiff(ARect: TRectF);
begin
HPDF_MarkupAnnot_SetRectDiff(FAnnotationHandle, RectFToHaruRect(ARect));
end;
procedure THaruAnnotation.MarkupAnnot_SetCloudEffect(ACloudIntensity: Integer);
begin
HPDF_MarkupAnnot_SetCloudEffect(FAnnotationHandle, ACloudIntensity);
end;
procedure THaruAnnotation.MarkupAnnot_SetInteriorRGBColor(AColor: THPDF_RGBColor);
begin
HPDF_MarkupAnnot_SetInteriorRGBColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.MarkupAnnot_SetInteriorCMYKColor(AColor: THPDF_CMYKColor);
begin
HPDF_MarkupAnnot_SetInteriorCMYKColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.MarkupAnnot_SetInteriorGrayColor(AColor: Single);
begin
HPDF_MarkupAnnot_SetInteriorGrayColor(FAnnotationHandle, AColor);
end;
procedure THaruAnnotation.MarkupAnnot_SetInteriorTransparent();
begin
HPDF_MarkupAnnot_SetInteriorTransparent(FAnnotationHandle);
end;
procedure THaruAnnotation.TextMarkupAnnot_SetQuadPoints(Alb, Arb, Art, Alt: TPointF);
begin
HPDF_TextMarkupAnnot_SetQuadPoints(FAnnotationHandle, PointFToHaruPoint(Alb),
PointFToHaruPoint(Arb), PointFToHaruPoint(Art), PointFToHaruPoint(Alt));
end;
procedure THaruAnnotation.PopupAnnot_SetOpened(AOpened: Boolean);
begin
HPDF_PopupAnnot_SetOpened(FAnnotationHandle, BooleanToHaruBool(AOpened));
end;
procedure THaruAnnotation.FreeTextAnnot_SetLineEndingStyle(AStartStyle, AEndStyle: THPDF_LineAnnotEndingStyle);
begin
HPDF_FreeTextAnnot_SetLineEndingStyle(FAnnotationHandle, AStartStyle, AEndStyle);
end;
procedure THaruAnnotation.FreeTextAnnot_Set3PointCalloutLine(AStartPoint, AKneePoint, AEndPoint: TPointF);
begin
HPDF_FreeTextAnnot_Set3PointCalloutLine(FAnnotationHandle, PointFToHaruPoint(AStartPoint),
PointFToHaruPoint(AKneePoint), PointFToHaruPoint(AEndPoint));
end;
procedure THaruAnnotation.FreeTextAnnot_Set2PointCalloutLine(AStartPoint, AEndPoint: TPointF);
begin
HPDF_FreeTextAnnot_Set2PointCalloutLine(FAnnotationHandle, PointFToHaruPoint(AStartPoint),
PointFToHaruPoint(AEndPoint));
end;
procedure THaruAnnotation.FreeTextAnnot_SetDefaultStyle(AStyle: String);
var
pStyle: PUTF8Char;
begin
pStyle := StringToPUTF8Char(AStyle);
HPDF_FreeTextAnnot_SetDefaultStyle(FAnnotationHandle, pStyle);
end;
procedure THaruAnnotation.LineAnnot_SetPosition(AStartPoint, AEndPoint: TPointF; AStartStyle, AEndStyle: THPDF_LineAnnotEndingStyle);
begin
HPDF_LineAnnot_SetPosition(FAnnotationHandle, PointFToHaruPoint(AStartPoint), AStartStyle,
PointFToHaruPoint(AEndPoint), AEndStyle);
end;
procedure THaruAnnotation.LineAnnot_SetLeader(ALeaderLen: Integer; ALeaderExtLen: Integer;
ALeaderOffsetLen: Integer);
begin
HPDF_LineAnnot_SetLeader(FAnnotationHandle, ALeaderLen, ALeaderExtLen, ALeaderOffsetLen);
end;
procedure THaruAnnotation.LineAnnot_SetCaption(AShowCaption: Boolean; APosition: THPDF_LineAnnotCapPosition;
AHorzOffset, AVertOffset: Integer);
begin
HPDF_LineAnnot_SetCaption(FAnnotationHandle, BooleanToHaruBool(AShowCaption), APosition,
AHorzOffset, AVertOffset);
end;
procedure THaruAnnotation.ProjectionAnnot_SetExData(AExData: HPDF_ExData);
begin
HPDF_ProjectionAnnot_SetExData(FAnnotationHandle, AExData);
end;
class function THaruAnnotation.GetAnnotationHandle(AAnnotation: THaruAnnotation):
HPDF_Annotation;
begin
if Assigned(AAnnotation) then
Result := AAnnotation.AnnotationHandle
else
Result := nil;
end;
{ THaruAnnotations }
constructor THaruAnnotations.Create(AOwnerPage: TObject; ADocument: TObject);
begin
FOwnerPage := AOwnerPage;
FOwnerDocument := ADocument;
FAnnotations := THaruAnnotationsList.Create;
end;
destructor THaruAnnotations.Destroy;
begin
FAnnotations.Free;
inherited;
end;
function THaruAnnotations.Add3DAnnot(ARect: TRectF; AToolBar: Boolean; ANavigationPanel: Boolean;
AU3D: THaruU3D; AAppearanceImage: THaruImage): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
begin
hAnnotation := HPDF_Page_Create3DAnnot(THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect),
BooleanToHaruBool(AToolBar), BooleanToHaruBool(ANavigationPanel), THaruU3D.GetU3DHandle(AU3D),
THaruImage.GetImageHandle(AAppearanceImage));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddTextAnnot(ARect: TRectF; AText: String; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateTextAnnot(THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect),
pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddFreeTextAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateFreeTextAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddLineAnnot(AText: string; AEncoder: THaruEncoder; ATextPtr: Pointer):
THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateLineAnnot(THaruPage(FOwnerPage).PageHandle,
pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddWidgetAnnot_WhiteOnlyWhilePrint(ARect: TRectF): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
begin
hAnnotation := HPDF_Page_CreateWidgetAnnot_WhiteOnlyWhilePrint(THaruDocument(FOwnerDocument).DocumentHandle,
THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddWidgetAnnot(ARect: TRectF): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
begin
hAnnotation := HPDF_Page_CreateWidgetAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddLinkAnnot(ARect: TRectF; ADestination: THaruDestination):
THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
begin
hAnnotation := HPDF_Page_CreateLinkAnnot(THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect),
ADestination.DestinationHandle);
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddURILinkAnnot(ARect: TRectF; AURI: string): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pURI: PUTF8Char;
begin
pURI := StringToPUTF8Char(AURI);
hAnnotation := HPDF_Page_CreateURILinkAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pURI);
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddHighlightAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateHighlightAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddUnderlineAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateUnderlineAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddSquigglyAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateSquigglyAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddStrikeOutAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateStrikeOutAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddPopupAnnot(ARect: TRectF; AParent: THaruAnnotation):
THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
begin
hAnnotation := HPDF_Page_CreatePopupAnnot(THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect),
THaruAnnotation.GetAnnotationHandle(AParent));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddStampAnnot(ARect: TRectF; AName: THPDF_StampAnnotName; AText:
string; AEncoder: THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateStampAnnot(THaruPage(FOwnerPage).PageHandle, RectFToHaruRect(ARect),
AName, pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddProjectionAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateProjectionAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddSquareAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateSquareAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
function THaruAnnotations.AddCircleAnnot(ARect: TRectF; AText: string; AEncoder:
THaruEncoder; ATextPtr: Pointer): THaruAnnotation;
var
hAnnotation: HPDF_Annotation;
pText: PUTF8Char;
begin
pText := StringToPUTF8Char(AText, ATextPtr);
hAnnotation := HPDF_Page_CreateCircleAnnot(THaruPage(FOwnerPage).PageHandle,
RectFToHaruRect(ARect), pText, THaruEncoder.GetEncoderHandle(AEncoder));
Result := THaruAnnotation.Create(hAnnotation);
FAnnotations.Add(Result);
end;
end.