1 | /* |
2 | * << Haru Free PDF Library >> -- hpdf_annotation.c |
3 | * |
4 | * URL: http://libharu.org |
5 | * |
6 | * Copyright (c) 1999-2006 Takeshi Kanno <takeshi_kanno@est.hi-ho.ne.jp> |
7 | * Copyright (c) 2007-2009 Antony Dovgal <tony@daylessday.org> |
8 | * |
9 | * Permission to use, copy, modify, distribute and sell this software |
10 | * and its documentation for any purpose is hereby granted without fee, |
11 | * provided that the above copyright notice appear in all copies and |
12 | * that both that copyright notice and this permission notice appear |
13 | * in supporting documentation. |
14 | * It is provided "as is" without express or implied warranty. |
15 | * |
16 | */ |
17 | |
18 | #include "hpdf_conf.h" |
19 | #include "hpdf_utils.h" |
20 | #include "hpdf_info.h" |
21 | #include "hpdf_annotation.h" |
22 | #include "hpdf.h" |
23 | |
24 | static const char * const HPDF_ANNOT_TYPE_NAMES[] = { |
25 | "Text" , |
26 | "Link" , |
27 | "Sound" , |
28 | "FreeText" , |
29 | "Stamp" , |
30 | "Square" , |
31 | "Circle" , |
32 | "StrikeOut" , |
33 | "Highlight" , |
34 | "Underline" , |
35 | "Ink" , |
36 | "FileAttachment" , |
37 | "Popup" , |
38 | "3D" , |
39 | "Squiggly" , |
40 | "Line" , |
41 | "Projection" |
42 | }; |
43 | |
44 | static const char * const HPDF_ANNOT_ICON_NAMES_NAMES[] = { |
45 | "Comment" , |
46 | "Key" , |
47 | "Note" , |
48 | "Help" , |
49 | "NewParagraph" , |
50 | "Paragraph" , |
51 | "Insert" |
52 | }; |
53 | |
54 | static const char * const HPDF_ANNOT_INTENT_NAMES[] = { |
55 | "FreeTextCallout" , |
56 | "FreeTextTypeWriter" , |
57 | "LineArrow" , |
58 | "LineDimension" , |
59 | "PolygonCloud" , |
60 | "PolyLineDimension" , |
61 | "PolygonDimension" |
62 | }; |
63 | |
64 | static const char * const HPDF_LINE_ANNOT_ENDING_STYLE_NAMES[] = { |
65 | "None" , |
66 | "Square" , |
67 | "Circle" , |
68 | "Diamond" , |
69 | "OpenArrow" , |
70 | "ClosedArrow" , |
71 | "Butt" , |
72 | "ROpenArrow" , |
73 | "RClosedArrow" , |
74 | "Slash" |
75 | }; |
76 | |
77 | static const char * const HPDF_LINE_ANNOT_CAP_POSITION_NAMES[] = { |
78 | "Inline" , |
79 | "Top" |
80 | }; |
81 | |
82 | static const char * const HPDF_STAMP_ANNOT_NAME_NAMES[] = { |
83 | "Approved" , |
84 | "Experimental" , |
85 | "NotApproved" , |
86 | "AsIs" , |
87 | "Expired" , |
88 | "NotForPublicRelease" , |
89 | "Confidential" , |
90 | "Final" , |
91 | "Sold" , |
92 | "Departmental" , |
93 | "ForComment" , |
94 | "TopSecret" , |
95 | "Draft" , |
96 | "ForPublicRelease" |
97 | }; |
98 | |
99 | static HPDF_BOOL |
100 | CheckSubType (HPDF_Annotation annot, |
101 | HPDF_AnnotType type); |
102 | |
103 | |
104 | /*----------------------------------------------------------------------------*/ |
105 | /*------ HPDF_Annotation -----------------------------------------------------*/ |
106 | |
107 | |
108 | HPDF_Annotation |
109 | HPDF_Annotation_New (HPDF_MMgr mmgr, |
110 | HPDF_Xref xref, |
111 | HPDF_AnnotType type, |
112 | HPDF_Rect rect) |
113 | { |
114 | HPDF_Annotation annot; |
115 | HPDF_Array array; |
116 | HPDF_STATUS ret = HPDF_OK; |
117 | HPDF_REAL tmp; |
118 | |
119 | HPDF_PTRACE((" HPDF_Annotation_New\n" )); |
120 | |
121 | annot = HPDF_Dict_New (mmgr); |
122 | if (!annot) |
123 | return NULL; |
124 | |
125 | if (HPDF_Xref_Add (xref, annot) != HPDF_OK) |
126 | return NULL; |
127 | |
128 | array = HPDF_Array_New (mmgr); |
129 | if (!array) |
130 | return NULL; |
131 | |
132 | if (HPDF_Dict_Add (annot, "Rect" , array) != HPDF_OK) |
133 | return NULL; |
134 | |
135 | if (rect.top < rect.bottom) { |
136 | tmp = rect.top; |
137 | rect.top = rect.bottom; |
138 | rect.bottom = tmp; |
139 | } |
140 | |
141 | ret += HPDF_Array_AddReal (array, rect.left); |
142 | ret += HPDF_Array_AddReal (array, rect.bottom); |
143 | ret += HPDF_Array_AddReal (array, rect.right); |
144 | ret += HPDF_Array_AddReal (array, rect.top); |
145 | |
146 | ret += HPDF_Dict_AddName (annot, "Type" , "Annot" ); |
147 | ret += HPDF_Dict_AddName (annot, "Subtype" , |
148 | HPDF_ANNOT_TYPE_NAMES[(HPDF_INT)type]); |
149 | |
150 | if (ret != HPDF_OK) |
151 | return NULL; |
152 | |
153 | annot->header.obj_class |= HPDF_OSUBCLASS_ANNOTATION; |
154 | |
155 | return annot; |
156 | } |
157 | |
158 | |
159 | HPDF_EXPORT(HPDF_STATUS) |
160 | HPDF_Annotation_SetBorderStyle (HPDF_Annotation annot, |
161 | HPDF_BSSubtype subtype, |
162 | HPDF_REAL width, |
163 | HPDF_UINT16 dash_on, |
164 | HPDF_UINT16 dash_off, |
165 | HPDF_UINT16 dash_phase) |
166 | { |
167 | HPDF_Dict bs; |
168 | HPDF_Array dash; |
169 | HPDF_STATUS ret; |
170 | |
171 | HPDF_PTRACE((" HPDF_Annotation_SetBoderStyle\n" )); |
172 | |
173 | bs = HPDF_Dict_New (annot->mmgr); |
174 | if (!bs) |
175 | return HPDF_Error_GetCode (annot->error); |
176 | |
177 | if ((ret = HPDF_Dict_Add (annot, "BS" , bs)) != HPDF_OK) |
178 | return ret; |
179 | |
180 | if (subtype == HPDF_BS_DASHED) { |
181 | dash = HPDF_Array_New (annot->mmgr); |
182 | if (!dash) |
183 | return HPDF_Error_GetCode (annot->error); |
184 | |
185 | if ((ret = HPDF_Dict_Add (bs, "D" , dash)) != HPDF_OK) |
186 | return ret; |
187 | |
188 | ret += HPDF_Dict_AddName (bs, "Type" , "Border" ); |
189 | ret += HPDF_Array_AddReal (dash, dash_on); |
190 | ret += HPDF_Array_AddReal (dash, dash_off); |
191 | |
192 | if (dash_phase != 0) |
193 | ret += HPDF_Array_AddReal (dash, dash_off); |
194 | } |
195 | |
196 | switch (subtype) { |
197 | case HPDF_BS_SOLID: |
198 | ret += HPDF_Dict_AddName (bs, "S" , "S" ); |
199 | break; |
200 | case HPDF_BS_DASHED: |
201 | ret += HPDF_Dict_AddName (bs, "S" , "D" ); |
202 | break; |
203 | case HPDF_BS_BEVELED: |
204 | ret += HPDF_Dict_AddName (bs, "S" , "B" ); |
205 | break; |
206 | case HPDF_BS_INSET: |
207 | ret += HPDF_Dict_AddName (bs, "S" , "I" ); |
208 | break; |
209 | case HPDF_BS_UNDERLINED: |
210 | ret += HPDF_Dict_AddName (bs, "S" , "U" ); |
211 | break; |
212 | default: |
213 | return HPDF_SetError (annot->error, HPDF_ANNOT_INVALID_BORDER_STYLE, 0); |
214 | } |
215 | |
216 | if (width != HPDF_BS_DEF_WIDTH) |
217 | ret += HPDF_Dict_AddReal (bs, "W" , width); |
218 | |
219 | if (ret != HPDF_OK) |
220 | return HPDF_Error_GetCode (annot->error); |
221 | |
222 | return HPDF_OK; |
223 | } |
224 | |
225 | |
226 | HPDF_Annotation |
227 | HPDF_LinkAnnot_New (HPDF_MMgr mmgr, |
228 | HPDF_Xref xref, |
229 | HPDF_Rect rect, |
230 | HPDF_Destination dst) |
231 | { |
232 | HPDF_Annotation annot; |
233 | |
234 | HPDF_PTRACE((" HPDF_LinkAnnot_New\n" )); |
235 | |
236 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_LINK, rect); |
237 | if (!annot) |
238 | return NULL; |
239 | |
240 | if (HPDF_Dict_Add (annot, "Dest" , dst) != HPDF_OK) |
241 | return NULL; |
242 | |
243 | return annot; |
244 | } |
245 | |
246 | |
247 | HPDF_Annotation |
248 | HPDF_URILinkAnnot_New (HPDF_MMgr mmgr, |
249 | HPDF_Xref xref, |
250 | HPDF_Rect rect, |
251 | const char *uri) |
252 | { |
253 | HPDF_Annotation annot; |
254 | HPDF_Dict action; |
255 | HPDF_STATUS ret; |
256 | |
257 | HPDF_PTRACE((" HPDF_URILinkAnnot_New\n" )); |
258 | |
259 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_LINK, rect); |
260 | if (!annot) |
261 | return NULL; |
262 | |
263 | /* create action dictionary */ |
264 | action = HPDF_Dict_New (mmgr); |
265 | if (!action) |
266 | return NULL; |
267 | |
268 | ret = HPDF_Dict_Add (annot, "A" , action); |
269 | if (ret != HPDF_OK) |
270 | return NULL; |
271 | |
272 | ret += HPDF_Dict_AddName (action, "Type" , "Action" ); |
273 | ret += HPDF_Dict_AddName (action, "S" , "URI" ); |
274 | ret += HPDF_Dict_Add (action, "URI" , HPDF_String_New (mmgr, uri, NULL)); |
275 | |
276 | if (ret != HPDF_OK) |
277 | return NULL; |
278 | |
279 | return annot; |
280 | } |
281 | |
282 | HPDF_EXPORT(HPDF_STATUS) |
283 | HPDF_LinkAnnot_SetBorderStyle (HPDF_Annotation annot, |
284 | HPDF_REAL width, |
285 | HPDF_UINT16 dash_on, |
286 | HPDF_UINT16 dash_off) |
287 | { |
288 | HPDF_Array array; |
289 | HPDF_STATUS ret; |
290 | |
291 | HPDF_PTRACE((" HPDF_LinkAnnot_SetBorderStyle\n" )); |
292 | |
293 | if (!CheckSubType (annot, HPDF_ANNOT_LINK)) |
294 | return HPDF_INVALID_ANNOTATION; |
295 | |
296 | if (width < 0) |
297 | return HPDF_RaiseError (annot->error, HPDF_INVALID_PARAMETER, 0); |
298 | |
299 | array = HPDF_Array_New (annot->mmgr); |
300 | if (!array) |
301 | return HPDF_CheckError (annot->error); |
302 | |
303 | if ((ret = HPDF_Dict_Add (annot, "Border" , array)) != HPDF_OK) |
304 | return HPDF_CheckError (annot->error); |
305 | |
306 | ret += HPDF_Array_AddNumber (array, 0); |
307 | ret += HPDF_Array_AddNumber (array, 0); |
308 | ret += HPDF_Array_AddReal (array, width); |
309 | |
310 | if (ret != HPDF_OK) |
311 | return HPDF_CheckError (annot->error); |
312 | |
313 | if (dash_on && dash_off) { |
314 | HPDF_Array dash = HPDF_Array_New (annot->mmgr); |
315 | if (!dash) |
316 | return HPDF_CheckError (annot->error); |
317 | |
318 | if ((ret = HPDF_Array_Add (array, dash)) != HPDF_OK) |
319 | return HPDF_CheckError (annot->error); |
320 | |
321 | ret += HPDF_Array_AddNumber (dash, dash_on); |
322 | ret += HPDF_Array_AddNumber (dash, dash_off); |
323 | |
324 | if (ret != HPDF_OK) |
325 | return HPDF_CheckError (annot->error); |
326 | } |
327 | |
328 | return HPDF_OK; |
329 | } |
330 | |
331 | HPDF_EXPORT(HPDF_STATUS) |
332 | HPDF_LinkAnnot_SetHighlightMode (HPDF_Annotation annot, |
333 | HPDF_AnnotHighlightMode mode) |
334 | { |
335 | HPDF_STATUS ret; |
336 | |
337 | HPDF_PTRACE((" HPDF_LinkAnnot_SetHighlightMode\n" )); |
338 | |
339 | if (!CheckSubType (annot, HPDF_ANNOT_LINK)) |
340 | return HPDF_INVALID_ANNOTATION; |
341 | |
342 | switch (mode) { |
343 | case HPDF_ANNOT_NO_HIGHTLIGHT: |
344 | ret = HPDF_Dict_AddName (annot, "H" , "N" ); |
345 | break; |
346 | case HPDF_ANNOT_INVERT_BORDER: |
347 | ret = HPDF_Dict_AddName (annot, "H" , "O" ); |
348 | break; |
349 | case HPDF_ANNOT_DOWN_APPEARANCE: |
350 | ret = HPDF_Dict_AddName (annot, "H" , "P" ); |
351 | break; |
352 | default: /* HPDF_ANNOT_INVERT_BOX */ |
353 | /* default value */ |
354 | HPDF_Dict_RemoveElement (annot, "H" ); |
355 | ret = HPDF_OK; |
356 | } |
357 | |
358 | if (ret != HPDF_OK) |
359 | return HPDF_CheckError (annot->error); |
360 | |
361 | return ret; |
362 | } |
363 | |
364 | |
365 | HPDF_Annotation |
366 | HPDF_3DAnnot_New (HPDF_MMgr mmgr, |
367 | HPDF_Xref xref, |
368 | HPDF_Rect rect, |
369 | HPDF_U3D u3d) |
370 | { |
371 | HPDF_Annotation annot; |
372 | HPDF_Dict action, appearance, stream; |
373 | HPDF_STATUS ret; |
374 | |
375 | HPDF_PTRACE((" HPDF_3DAnnot_New\n" )); |
376 | |
377 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_3D, rect); |
378 | if (!annot) { |
379 | return NULL; |
380 | } |
381 | |
382 | HPDF_Dict_Add(annot, "Contents" , HPDF_String_New (mmgr, "3D Model" , NULL)); |
383 | |
384 | action = HPDF_Dict_New (mmgr); |
385 | if (!action) { |
386 | return NULL; |
387 | } |
388 | |
389 | ret = HPDF_Dict_Add (annot, "3DA" , action); |
390 | if (ret != HPDF_OK) { |
391 | return NULL; |
392 | } |
393 | |
394 | ret += HPDF_Dict_AddName (action, "A" , "PV" ); |
395 | |
396 | ret += HPDF_Dict_AddBoolean(action, "TB" , HPDF_FALSE); |
397 | |
398 | if (ret != HPDF_OK) { |
399 | return NULL; |
400 | } |
401 | |
402 | if (HPDF_Dict_Add (annot, "3DD" , u3d) != HPDF_OK) { |
403 | return NULL; |
404 | } |
405 | |
406 | appearance = HPDF_Dict_New (mmgr); |
407 | if (!appearance) { |
408 | return NULL; |
409 | } |
410 | |
411 | ret = HPDF_Dict_Add (annot, "AP" , appearance); |
412 | if (ret != HPDF_OK) { |
413 | return NULL; |
414 | } |
415 | |
416 | stream = HPDF_Dict_New (mmgr); |
417 | if (!stream) { |
418 | return NULL; |
419 | } |
420 | ret = HPDF_Dict_Add (appearance, "N" , stream); |
421 | if (ret != HPDF_OK) { |
422 | return NULL; |
423 | } |
424 | |
425 | return annot; |
426 | } |
427 | |
428 | HPDF_EXPORT(HPDF_STATUS) |
429 | HPDF_3DAnnot_Set3DView (HPDF_Annotation annot) |
430 | { |
431 | HPDF_Boolean b; |
432 | |
433 | HPDF_PTRACE((" HPDF_3DAnnot_Set3DView\n" )); |
434 | |
435 | if (!CheckSubType (annot, HPDF_ANNOT_3D)) |
436 | return HPDF_INVALID_ANNOTATION; |
437 | |
438 | b = HPDF_Boolean_New (annot->mmgr, 0); |
439 | if (!b) |
440 | return HPDF_CheckError (annot->error); |
441 | |
442 | return HPDF_Dict_Add (annot, "3DD" , b); |
443 | } |
444 | |
445 | HPDF_Annotation |
446 | HPDF_MarkupAnnot_New (HPDF_MMgr mmgr, |
447 | HPDF_Xref xref, |
448 | HPDF_Rect rect, |
449 | const char *text, |
450 | HPDF_Encoder encoder, |
451 | HPDF_AnnotType subtype) |
452 | { |
453 | HPDF_Annotation annot; |
454 | HPDF_String s; |
455 | |
456 | HPDF_PTRACE((" HPDF_MarkupAnnot_New\n" )); |
457 | |
458 | annot = HPDF_Annotation_New (mmgr, xref, subtype, rect); |
459 | if (!annot) |
460 | return NULL; |
461 | |
462 | s = HPDF_String_New (mmgr, text, encoder); |
463 | if (!s) |
464 | return NULL; |
465 | |
466 | if (HPDF_Dict_Add (annot, "Contents" , s) != HPDF_OK) |
467 | return NULL; |
468 | |
469 | return annot; |
470 | } |
471 | |
472 | HPDF_EXPORT(HPDF_STATUS) |
473 | HPDF_Annot_SetRGBColor (HPDF_Annotation annot, HPDF_RGBColor color) |
474 | { |
475 | HPDF_Array cArray; |
476 | HPDF_STATUS ret = HPDF_OK; |
477 | |
478 | HPDF_PTRACE((" HPDF_Annot_SetRGBColor\n" )); |
479 | |
480 | cArray = HPDF_Array_New ( annot->mmgr); |
481 | if (!cArray) |
482 | return HPDF_Error_GetCode ( annot->error); |
483 | |
484 | ret += HPDF_Dict_Add (annot, "C" , cArray); |
485 | ret += HPDF_Array_AddReal (cArray, color.r); |
486 | ret += HPDF_Array_AddReal (cArray, color.g); |
487 | ret += HPDF_Array_AddReal (cArray, color.b); |
488 | |
489 | if (ret != HPDF_OK) |
490 | return HPDF_Error_GetCode (annot->error); |
491 | |
492 | return HPDF_OK; |
493 | } |
494 | |
495 | HPDF_EXPORT(HPDF_STATUS) |
496 | HPDF_Annot_SetCMYKColor (HPDF_Annotation annot, HPDF_CMYKColor color) |
497 | { |
498 | HPDF_Array cArray; |
499 | HPDF_STATUS ret = HPDF_OK; |
500 | |
501 | HPDF_PTRACE((" HPDF_Annot_SetCMYKColor\n" )); |
502 | |
503 | cArray = HPDF_Array_New (annot->mmgr); |
504 | if (!cArray) |
505 | return HPDF_Error_GetCode (annot->error); |
506 | |
507 | ret += HPDF_Dict_Add (annot, "C" , cArray); |
508 | ret += HPDF_Array_AddReal (cArray, color.c); |
509 | ret += HPDF_Array_AddReal (cArray, color.m); |
510 | ret += HPDF_Array_AddReal (cArray, color.y); |
511 | ret += HPDF_Array_AddReal (cArray, color.k); |
512 | |
513 | if (ret != HPDF_OK) |
514 | return HPDF_Error_GetCode (annot->error); |
515 | |
516 | return HPDF_OK; |
517 | } |
518 | |
519 | HPDF_EXPORT(HPDF_STATUS) |
520 | HPDF_Annot_SetGrayColor (HPDF_Annotation annot, HPDF_REAL color) |
521 | { |
522 | HPDF_Array cArray; |
523 | HPDF_STATUS ret = HPDF_OK; |
524 | |
525 | HPDF_PTRACE((" HPDF_Annot_SetGrayColor\n" )); |
526 | |
527 | cArray = HPDF_Array_New (annot->mmgr); |
528 | if (!cArray) |
529 | return HPDF_Error_GetCode ( annot->error); |
530 | |
531 | ret += HPDF_Dict_Add (annot, "C" , cArray); |
532 | ret += HPDF_Array_AddReal ( cArray, color); |
533 | |
534 | if (ret != HPDF_OK) |
535 | return HPDF_Error_GetCode ( annot->error); |
536 | |
537 | return HPDF_OK; |
538 | } |
539 | |
540 | HPDF_EXPORT(HPDF_STATUS) |
541 | HPDF_Annot_SetNoColor (HPDF_Annotation annot) |
542 | { |
543 | HPDF_Array cArray; |
544 | HPDF_STATUS ret = HPDF_OK; |
545 | |
546 | HPDF_PTRACE((" HPDF_Annot_SetNoColor\n" )); |
547 | |
548 | cArray = HPDF_Array_New (annot->mmgr); |
549 | if (!cArray) |
550 | return HPDF_Error_GetCode ( annot->error); |
551 | |
552 | ret = HPDF_Dict_Add (annot, "C" , cArray); |
553 | |
554 | return ret; |
555 | } |
556 | |
557 | HPDF_EXPORT(HPDF_STATUS) |
558 | HPDF_TextAnnot_SetIcon (HPDF_Annotation annot, |
559 | HPDF_AnnotIcon icon) |
560 | { |
561 | HPDF_PTRACE((" HPDF_TextAnnot_SetIcon\n" )); |
562 | |
563 | if (!CheckSubType (annot, HPDF_ANNOT_TEXT_NOTES)) |
564 | return HPDF_INVALID_ANNOTATION; |
565 | |
566 | if (icon >= HPDF_ANNOT_ICON_EOF) |
567 | return HPDF_RaiseError (annot->error, HPDF_ANNOT_INVALID_ICON, |
568 | (HPDF_STATUS)icon); |
569 | |
570 | if (HPDF_Dict_AddName (annot, "Name" , |
571 | HPDF_ANNOT_ICON_NAMES_NAMES[(HPDF_INT)icon]) != HPDF_OK) |
572 | return HPDF_CheckError (annot->error); |
573 | |
574 | return HPDF_OK; |
575 | } |
576 | |
577 | |
578 | HPDF_EXPORT(HPDF_STATUS) |
579 | HPDF_TextAnnot_SetOpened (HPDF_Annotation annot, |
580 | HPDF_BOOL opened) |
581 | { |
582 | HPDF_Boolean b; |
583 | |
584 | HPDF_PTRACE((" HPDF_TextAnnot_SetOpend\n" )); |
585 | |
586 | if (!CheckSubType (annot, HPDF_ANNOT_TEXT_NOTES)) |
587 | return HPDF_INVALID_ANNOTATION; |
588 | |
589 | b = HPDF_Boolean_New (annot->mmgr, opened); |
590 | if (!b) |
591 | return HPDF_CheckError (annot->error); |
592 | |
593 | return HPDF_Dict_Add (annot, "Open" , b); |
594 | } |
595 | |
596 | HPDF_EXPORT(HPDF_STATUS) |
597 | (HPDF_Annotation annot, |
598 | HPDF_BOOL opened) |
599 | { |
600 | HPDF_Boolean b; |
601 | |
602 | HPDF_PTRACE((" HPDF_TextAnnot_SetOpend\n" )); |
603 | |
604 | if (!CheckSubType (annot, HPDF_ANNOT_POPUP)) |
605 | return HPDF_INVALID_ANNOTATION; |
606 | |
607 | b = HPDF_Boolean_New (annot->mmgr, opened); |
608 | if (!b) |
609 | return HPDF_CheckError (annot->error); |
610 | |
611 | return HPDF_Dict_Add (annot, "Open" , b); |
612 | } |
613 | |
614 | HPDF_EXPORT(HPDF_STATUS) |
615 | HPDF_MarkupAnnot_SetTitle (HPDF_Annotation annot, const char* name) |
616 | { |
617 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetTitle\n" )); |
618 | |
619 | return HPDF_Dict_Add( annot, "T" , HPDF_String_New( annot->mmgr, name, NULL)); |
620 | } |
621 | |
622 | HPDF_EXPORT(HPDF_STATUS) |
623 | HPDF_MarkupAnnot_SetSubject (HPDF_Annotation annot, const char* name) |
624 | { |
625 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetSubject\n" )); |
626 | |
627 | return HPDF_Dict_Add( annot, "Subj" , HPDF_String_New( annot->mmgr, name, NULL)); |
628 | } |
629 | |
630 | HPDF_EXPORT(HPDF_STATUS) |
631 | HPDF_MarkupAnnot_SetCreationDate (HPDF_Annotation annot, HPDF_Date value) |
632 | { |
633 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetCreationDate\n" )); |
634 | |
635 | return HPDF_Info_SetInfoDateAttr( annot, HPDF_INFO_CREATION_DATE, value); |
636 | } |
637 | |
638 | HPDF_EXPORT(HPDF_STATUS) |
639 | HPDF_MarkupAnnot_SetTransparency (HPDF_Annotation annot, HPDF_REAL value) |
640 | { |
641 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetTransparency\n" )); |
642 | |
643 | return HPDF_Dict_AddReal( annot, "CA" , value); |
644 | } |
645 | |
646 | HPDF_EXPORT(HPDF_STATUS) |
647 | HPDF_MarkupAnnot_SetIntent (HPDF_Annotation annot, |
648 | HPDF_AnnotIntent intent) |
649 | { |
650 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetIntent\n" )); |
651 | |
652 | if (HPDF_Dict_AddName (annot, "IT" , |
653 | HPDF_ANNOT_INTENT_NAMES[(HPDF_INT)intent]) != HPDF_OK) |
654 | return HPDF_CheckError (annot->error); |
655 | |
656 | return HPDF_OK; |
657 | } |
658 | |
659 | HPDF_EXPORT(HPDF_STATUS) |
660 | (HPDF_Annotation annot, |
661 | HPDF_Annotation ) |
662 | { |
663 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetPopup\n" )); |
664 | |
665 | return HPDF_Dict_Add( annot, "Popup" , popup); |
666 | } |
667 | |
668 | HPDF_EXPORT(HPDF_STATUS) |
669 | HPDF_MarkupAnnot_SetInteriorRGBColor (HPDF_Annotation annot, HPDF_RGBColor color)/* IC with RGB entry */ |
670 | { |
671 | HPDF_Array cArray; |
672 | HPDF_STATUS ret = HPDF_OK; |
673 | |
674 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetInteriorRGBColor\n" )); |
675 | |
676 | cArray = HPDF_Array_New ( annot->mmgr); |
677 | if (!cArray) |
678 | return HPDF_Error_GetCode ( annot->error); |
679 | |
680 | ret += HPDF_Dict_Add (annot, "IC" , cArray); |
681 | ret += HPDF_Array_AddReal (cArray, color.r); |
682 | ret += HPDF_Array_AddReal (cArray, color.g); |
683 | ret += HPDF_Array_AddReal (cArray, color.b); |
684 | |
685 | if (ret != HPDF_OK) |
686 | return HPDF_Error_GetCode (annot->error); |
687 | |
688 | return HPDF_OK; |
689 | } |
690 | |
691 | HPDF_EXPORT(HPDF_STATUS) |
692 | HPDF_MarkupAnnot_SetInteriorCMYKColor (HPDF_Annotation annot, HPDF_CMYKColor color)/* IC with CMYK entry */ |
693 | { |
694 | HPDF_Array cArray; |
695 | HPDF_STATUS ret = HPDF_OK; |
696 | |
697 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetInteriorCMYKColor\n" )); |
698 | |
699 | cArray = HPDF_Array_New ( annot->mmgr); |
700 | if (!cArray) |
701 | return HPDF_Error_GetCode ( annot->error); |
702 | |
703 | ret += HPDF_Dict_Add (annot, "IC" , cArray); |
704 | ret += HPDF_Array_AddReal (cArray, color.c); |
705 | ret += HPDF_Array_AddReal (cArray, color.m); |
706 | ret += HPDF_Array_AddReal (cArray, color.y); |
707 | ret += HPDF_Array_AddReal (cArray, color.k); |
708 | |
709 | if (ret != HPDF_OK) |
710 | return HPDF_Error_GetCode (annot->error); |
711 | |
712 | return HPDF_OK; |
713 | } |
714 | |
715 | HPDF_EXPORT(HPDF_STATUS) |
716 | HPDF_MarkupAnnot_SetInteriorGrayColor (HPDF_Annotation annot, HPDF_REAL color)/* IC with Gray entry */ |
717 | { |
718 | HPDF_Array cArray; |
719 | HPDF_STATUS ret = HPDF_OK; |
720 | |
721 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetInteriorGrayColor\n" )); |
722 | |
723 | cArray = HPDF_Array_New ( annot->mmgr); |
724 | if (!cArray) |
725 | return HPDF_Error_GetCode ( annot->error); |
726 | |
727 | ret += HPDF_Dict_Add (annot, "IC" , cArray); |
728 | ret += HPDF_Array_AddReal (cArray, color); |
729 | |
730 | if (ret != HPDF_OK) |
731 | return HPDF_Error_GetCode ( annot->error); |
732 | |
733 | return HPDF_OK; |
734 | } |
735 | |
736 | HPDF_EXPORT(HPDF_STATUS) |
737 | HPDF_MarkupAnnot_SetInteriorTransparent (HPDF_Annotation annot) /* IC with No Color entry */ |
738 | { |
739 | HPDF_Array cArray; |
740 | HPDF_STATUS ret = HPDF_OK; |
741 | |
742 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetInteriorTransparent\n" )); |
743 | |
744 | cArray = HPDF_Array_New ( annot->mmgr); |
745 | if (!cArray) |
746 | return HPDF_Error_GetCode ( annot->error); |
747 | |
748 | ret = HPDF_Dict_Add (annot, "IC" , cArray); |
749 | |
750 | return ret; |
751 | } |
752 | |
753 | HPDF_BOOL |
754 | HPDF_Annotation_Validate (HPDF_Annotation annot) |
755 | { |
756 | HPDF_PTRACE((" HPDF_Annotation_Validate\n" )); |
757 | |
758 | if (!annot) |
759 | return HPDF_FALSE; |
760 | |
761 | if (annot->header.obj_class != |
762 | (HPDF_OSUBCLASS_ANNOTATION | HPDF_OCLASS_DICT)) |
763 | return HPDF_FALSE; |
764 | |
765 | return HPDF_TRUE; |
766 | } |
767 | |
768 | static HPDF_BOOL |
769 | CheckSubType (HPDF_Annotation annot, |
770 | HPDF_AnnotType type) |
771 | { |
772 | HPDF_Name subtype; |
773 | |
774 | HPDF_PTRACE((" HPDF_Annotation_CheckSubType\n" )); |
775 | |
776 | if (!HPDF_Annotation_Validate (annot)) |
777 | return HPDF_FALSE; |
778 | |
779 | subtype = HPDF_Dict_GetItem (annot, "Subtype" , HPDF_OCLASS_NAME); |
780 | |
781 | if (!subtype || HPDF_StrCmp (subtype->value, |
782 | HPDF_ANNOT_TYPE_NAMES[(HPDF_INT)type]) != 0) { |
783 | HPDF_RaiseError (annot->error, HPDF_INVALID_ANNOTATION, 0); |
784 | return HPDF_FALSE; |
785 | } |
786 | |
787 | return HPDF_TRUE; |
788 | } |
789 | |
790 | HPDF_EXPORT(HPDF_STATUS) |
791 | HPDF_Annot_Set3DView ( HPDF_MMgr mmgr, |
792 | HPDF_Annotation annot, |
793 | HPDF_Annotation annot3d, |
794 | HPDF_Dict view3d) |
795 | { |
796 | HPDF_Proxy proxyView3d; |
797 | HPDF_Dict exData = HPDF_Dict_New( mmgr); |
798 | HPDF_STATUS retS = HPDF_OK; |
799 | |
800 | retS += HPDF_Dict_AddName( exData, "Type" , "ExData" ); |
801 | retS += HPDF_Dict_AddName( exData, "Subtype" , "Markup3D" ); |
802 | retS += HPDF_Dict_Add( exData, "3DA" , annot3d); |
803 | |
804 | proxyView3d = HPDF_Proxy_New( mmgr, view3d); |
805 | |
806 | retS += HPDF_Dict_Add( exData, "3DV" , proxyView3d); |
807 | retS += HPDF_Dict_Add( annot, "ExData" , exData); |
808 | return retS; |
809 | } |
810 | |
811 | |
812 | HPDF_Annotation |
813 | (HPDF_MMgr mmgr, |
814 | HPDF_Xref xref, |
815 | HPDF_Rect rect, |
816 | HPDF_Annotation parent) |
817 | { |
818 | HPDF_Annotation annot; |
819 | |
820 | HPDF_PTRACE((" HPDF_PopupAnnot_New\n" )); |
821 | |
822 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_POPUP, rect); |
823 | if (!annot) |
824 | return NULL; |
825 | |
826 | if (HPDF_Dict_Add (annot, "Parent" , parent) != HPDF_OK) |
827 | return NULL; |
828 | |
829 | return annot; |
830 | } |
831 | |
832 | HPDF_Annotation |
833 | HPDF_StampAnnot_New (HPDF_MMgr mmgr, |
834 | HPDF_Xref xref, |
835 | HPDF_Rect rect, |
836 | HPDF_StampAnnotName name, |
837 | const char* text, |
838 | HPDF_Encoder encoder) |
839 | { |
840 | HPDF_Annotation annot; |
841 | HPDF_String s; |
842 | HPDF_PTRACE((" HPDF_StampAnnot_New\n" )); |
843 | |
844 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_STAMP, rect); |
845 | if (!annot) |
846 | return NULL; |
847 | |
848 | if (HPDF_Dict_AddName ( annot, "Name" , HPDF_STAMP_ANNOT_NAME_NAMES[name]) != HPDF_OK) |
849 | return NULL; |
850 | |
851 | s = HPDF_String_New (mmgr, text, encoder); |
852 | if (!s) |
853 | return NULL; |
854 | |
855 | if (HPDF_Dict_Add (annot, "Contents" , s) != HPDF_OK) |
856 | return NULL; |
857 | |
858 | return annot; |
859 | } |
860 | |
861 | HPDF_Annotation |
862 | HPDF_ProjectionAnnot_New(HPDF_MMgr mmgr, |
863 | HPDF_Xref xref, |
864 | HPDF_Rect rect, |
865 | const char* text, |
866 | HPDF_Encoder encoder) |
867 | { |
868 | HPDF_Annotation annot; |
869 | HPDF_String s; |
870 | HPDF_PTRACE((" HPDF_StampAnnot_New\n" )); |
871 | |
872 | annot = HPDF_Annotation_New (mmgr, xref, HPDF_ANNOT_PROJECTION, rect); |
873 | if (!annot) |
874 | return NULL; |
875 | |
876 | s = HPDF_String_New (mmgr, text, encoder); |
877 | if (!s) |
878 | return NULL; |
879 | |
880 | if (HPDF_Dict_Add (annot, "Contents" , s) != HPDF_OK) |
881 | return NULL; |
882 | |
883 | return annot; |
884 | } |
885 | |
886 | |
887 | HPDF_EXPORT(HPDF_STATUS) |
888 | HPDF_TextMarkupAnnot_SetQuadPoints ( HPDF_Annotation annot, HPDF_Point lb, HPDF_Point rb, HPDF_Point lt, HPDF_Point rt) /* l-left, r-right, b-bottom, t-top positions */ |
889 | { |
890 | HPDF_Array quadPoints; |
891 | HPDF_STATUS ret = HPDF_OK; |
892 | |
893 | HPDF_PTRACE((" HPDF_TextMarkupAnnot_SetQuadPoints\n" )); |
894 | |
895 | quadPoints = HPDF_Array_New ( annot->mmgr); |
896 | if ( !quadPoints) |
897 | return HPDF_Error_GetCode ( annot->error); |
898 | |
899 | if ((ret = HPDF_Dict_Add ( annot, "QuadPoints" , quadPoints)) != HPDF_OK) |
900 | return ret; |
901 | |
902 | ret += HPDF_Array_AddReal (quadPoints, lb.x); |
903 | ret += HPDF_Array_AddReal (quadPoints, lb.y); |
904 | ret += HPDF_Array_AddReal (quadPoints, rb.x); |
905 | ret += HPDF_Array_AddReal (quadPoints, rb.y); |
906 | ret += HPDF_Array_AddReal (quadPoints, lt.x); |
907 | ret += HPDF_Array_AddReal (quadPoints, lt.y); |
908 | ret += HPDF_Array_AddReal (quadPoints, rt.x); |
909 | ret += HPDF_Array_AddReal (quadPoints, rt.y); |
910 | |
911 | if (ret != HPDF_OK) |
912 | return HPDF_Error_GetCode (quadPoints->error); |
913 | |
914 | return HPDF_OK; |
915 | } |
916 | |
917 | HPDF_EXPORT(HPDF_STATUS) |
918 | HPDF_FreeTextAnnot_SetLineEndingStyle (HPDF_Annotation annot, HPDF_LineAnnotEndingStyle startStyle, HPDF_LineAnnotEndingStyle endStyle) |
919 | { |
920 | HPDF_Array lineEndStyles; |
921 | HPDF_STATUS ret = HPDF_OK; |
922 | |
923 | HPDF_PTRACE((" HPDF_FreeTextAnnot_SetLineEndingStyle\n" )); |
924 | |
925 | lineEndStyles = HPDF_Array_New ( annot->mmgr); |
926 | if ( !lineEndStyles) |
927 | return HPDF_Error_GetCode ( annot->error); |
928 | |
929 | if ((ret = HPDF_Dict_Add ( annot, "LE" , lineEndStyles)) != HPDF_OK) |
930 | return ret; |
931 | |
932 | ret += HPDF_Array_AddName (lineEndStyles, HPDF_LINE_ANNOT_ENDING_STYLE_NAMES[(HPDF_INT)startStyle]); |
933 | ret += HPDF_Array_AddName (lineEndStyles, HPDF_LINE_ANNOT_ENDING_STYLE_NAMES[(HPDF_INT)endStyle]); |
934 | |
935 | if (ret != HPDF_OK) |
936 | return HPDF_Error_GetCode (lineEndStyles->error); |
937 | |
938 | return HPDF_OK; |
939 | } |
940 | |
941 | HPDF_EXPORT(HPDF_STATUS) |
942 | HPDF_MarkupAnnot_SetRectDiff (HPDF_Annotation annot, HPDF_Rect rect) /* RD entry : this is the difference between Rect and the text annotation rectangle */ |
943 | { |
944 | HPDF_Array array; |
945 | HPDF_STATUS ret = HPDF_OK; |
946 | HPDF_REAL tmp; |
947 | |
948 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetRectDiff\n" )); |
949 | |
950 | array = HPDF_Array_New ( annot->mmgr); |
951 | if ( !array) |
952 | return HPDF_Error_GetCode ( annot->error); |
953 | |
954 | if ((ret = HPDF_Dict_Add ( annot, "RD" , array)) != HPDF_OK) |
955 | return ret; |
956 | |
957 | if (rect.top < rect.bottom) { |
958 | tmp = rect.top; |
959 | rect.top = rect.bottom; |
960 | rect.bottom = tmp; |
961 | } |
962 | |
963 | ret += HPDF_Array_AddReal (array, rect.left); |
964 | ret += HPDF_Array_AddReal (array, rect.bottom); |
965 | ret += HPDF_Array_AddReal (array, rect.right); |
966 | ret += HPDF_Array_AddReal (array, rect.top); |
967 | |
968 | if (ret != HPDF_OK) |
969 | return HPDF_Error_GetCode (array->error); |
970 | |
971 | return HPDF_OK; |
972 | } |
973 | |
974 | HPDF_EXPORT(HPDF_STATUS) |
975 | HPDF_FreeTextAnnot_SetDefaultStyle (HPDF_Annotation annot, |
976 | const char* style) |
977 | { |
978 | HPDF_String s; |
979 | HPDF_STATUS ret = HPDF_OK; |
980 | |
981 | HPDF_PTRACE((" HPDF_FreeTextAnnot_SetDefaultStyle\n" )); |
982 | |
983 | s = HPDF_String_New ( annot->mmgr, style, NULL); |
984 | if ( !s) |
985 | return HPDF_Error_GetCode ( annot->error); |
986 | |
987 | ret = HPDF_Dict_Add ( annot, "DS" , s); |
988 | |
989 | return ret; |
990 | } |
991 | |
992 | HPDF_EXPORT(HPDF_STATUS) |
993 | HPDF_FreeTextAnnot_Set3PointCalloutLine ( HPDF_Annotation annot, HPDF_Point startPoint, HPDF_Point kneePoint, HPDF_Point endPoint) /* Callout line will be in default user space */ |
994 | { |
995 | HPDF_Array clPoints; |
996 | HPDF_STATUS ret = HPDF_OK; |
997 | |
998 | HPDF_PTRACE((" HPDF_FreeTextAnnot_Set3PointCalloutLine\n" )); |
999 | |
1000 | clPoints = HPDF_Array_New ( annot->mmgr); |
1001 | if ( !clPoints) |
1002 | return HPDF_Error_GetCode ( annot->error); |
1003 | |
1004 | if ((ret = HPDF_Dict_Add ( annot, "CL" , clPoints)) != HPDF_OK) |
1005 | return ret; |
1006 | |
1007 | ret += HPDF_Array_AddReal (clPoints, startPoint.x); |
1008 | ret += HPDF_Array_AddReal (clPoints, startPoint.y); |
1009 | ret += HPDF_Array_AddReal (clPoints, kneePoint.x); |
1010 | ret += HPDF_Array_AddReal (clPoints, kneePoint.y); |
1011 | ret += HPDF_Array_AddReal (clPoints, endPoint.x); |
1012 | ret += HPDF_Array_AddReal (clPoints, endPoint.y); |
1013 | |
1014 | if (ret != HPDF_OK) |
1015 | return HPDF_Error_GetCode (clPoints->error); |
1016 | |
1017 | return HPDF_OK; |
1018 | } |
1019 | |
1020 | HPDF_EXPORT(HPDF_STATUS) |
1021 | HPDF_FreeTextAnnot_Set2PointCalloutLine ( HPDF_Annotation annot, HPDF_Point startPoint, HPDF_Point endPoint) /* Callout line will be in default user space */ |
1022 | { |
1023 | HPDF_Array clPoints; |
1024 | HPDF_STATUS ret = HPDF_OK; |
1025 | |
1026 | HPDF_PTRACE((" HPDF_FreeTextAnnot_Set3PointCalloutLine\n" )); |
1027 | |
1028 | clPoints = HPDF_Array_New ( annot->mmgr); |
1029 | if ( !clPoints) |
1030 | return HPDF_Error_GetCode ( annot->error); |
1031 | |
1032 | if ((ret = HPDF_Dict_Add ( annot, "CL" , clPoints)) != HPDF_OK) |
1033 | return ret; |
1034 | |
1035 | ret += HPDF_Array_AddReal (clPoints, startPoint.x); |
1036 | ret += HPDF_Array_AddReal (clPoints, startPoint.y); |
1037 | ret += HPDF_Array_AddReal (clPoints, endPoint.x); |
1038 | ret += HPDF_Array_AddReal (clPoints, endPoint.y); |
1039 | |
1040 | if (ret != HPDF_OK) |
1041 | return HPDF_Error_GetCode (clPoints->error); |
1042 | |
1043 | return HPDF_OK; |
1044 | } |
1045 | |
1046 | HPDF_EXPORT(HPDF_STATUS) |
1047 | HPDF_MarkupAnnot_SetCloudEffect (HPDF_Annotation annot, HPDF_INT cloudIntensity) /* BE entry */ |
1048 | { |
1049 | HPDF_Dict borderEffect; |
1050 | HPDF_STATUS ret = HPDF_OK; |
1051 | |
1052 | HPDF_PTRACE((" HPDF_MarkupAnnot_SetCloudEffect\n" )); |
1053 | |
1054 | borderEffect = HPDF_Dict_New ( annot->mmgr); |
1055 | if (!borderEffect) |
1056 | return HPDF_Error_GetCode ( annot->error); |
1057 | |
1058 | ret += HPDF_Dict_Add ( annot, "BE" , borderEffect); |
1059 | ret += HPDF_Dict_AddName ( borderEffect, "S" , "C" ); |
1060 | ret += HPDF_Dict_AddNumber ( borderEffect, "I" , cloudIntensity); |
1061 | |
1062 | if (ret != HPDF_OK) |
1063 | return HPDF_Error_GetCode (annot->error); |
1064 | |
1065 | return HPDF_OK; |
1066 | } |
1067 | |
1068 | HPDF_EXPORT(HPDF_STATUS) |
1069 | HPDF_LineAnnot_SetPosition (HPDF_Annotation annot, |
1070 | HPDF_Point startPoint, HPDF_LineAnnotEndingStyle startStyle, |
1071 | HPDF_Point endPoint, HPDF_LineAnnotEndingStyle endStyle) |
1072 | { |
1073 | HPDF_Array lineEndPoints; |
1074 | HPDF_Array lineEndStyles; |
1075 | HPDF_STATUS ret = HPDF_OK; |
1076 | |
1077 | HPDF_PTRACE((" HPDF_LineAnnot_SetPosition\n" )); |
1078 | |
1079 | lineEndPoints = HPDF_Array_New ( annot->mmgr); |
1080 | if ( !lineEndPoints) |
1081 | return HPDF_Error_GetCode ( annot->error); |
1082 | |
1083 | if ((ret = HPDF_Dict_Add ( annot, "L" , lineEndPoints)) != HPDF_OK) |
1084 | return ret; |
1085 | |
1086 | ret += HPDF_Array_AddReal (lineEndPoints, startPoint.x); |
1087 | ret += HPDF_Array_AddReal (lineEndPoints, startPoint.y); |
1088 | ret += HPDF_Array_AddReal (lineEndPoints, endPoint.x); |
1089 | ret += HPDF_Array_AddReal (lineEndPoints, endPoint.y); |
1090 | |
1091 | if (ret != HPDF_OK) |
1092 | return HPDF_Error_GetCode ( lineEndPoints->error); |
1093 | |
1094 | lineEndStyles = HPDF_Array_New ( annot->mmgr); |
1095 | if ( !lineEndStyles) |
1096 | return HPDF_Error_GetCode ( annot->error); |
1097 | |
1098 | if ((ret = HPDF_Dict_Add ( annot, "LE" , lineEndStyles)) != HPDF_OK) |
1099 | return ret; |
1100 | |
1101 | ret += HPDF_Array_AddName (lineEndStyles, HPDF_LINE_ANNOT_ENDING_STYLE_NAMES[(HPDF_INT)startStyle]); |
1102 | ret += HPDF_Array_AddName (lineEndStyles, HPDF_LINE_ANNOT_ENDING_STYLE_NAMES[(HPDF_INT)endStyle]); |
1103 | |
1104 | if (ret != HPDF_OK) |
1105 | return HPDF_Error_GetCode ( lineEndStyles->error); |
1106 | |
1107 | return HPDF_OK; |
1108 | } |
1109 | |
1110 | HPDF_EXPORT(HPDF_STATUS) |
1111 | HPDF_LineAnnot_SetLeader (HPDF_Annotation annot, HPDF_INT leaderLen, HPDF_INT leaderExtLen, HPDF_INT leaderOffsetLen) |
1112 | { |
1113 | HPDF_STATUS ret = HPDF_OK; |
1114 | |
1115 | HPDF_PTRACE((" HPDF_LineAnnot_SetLeader\n" )); |
1116 | |
1117 | ret += HPDF_Dict_AddNumber ( annot, "LL" , leaderLen); |
1118 | ret += HPDF_Dict_AddNumber ( annot, "LLE" , leaderExtLen); |
1119 | ret += HPDF_Dict_AddNumber ( annot, "LLO" , leaderOffsetLen); |
1120 | |
1121 | if (ret != HPDF_OK) |
1122 | return HPDF_Error_GetCode ( annot->error); |
1123 | |
1124 | return HPDF_OK; |
1125 | } |
1126 | |
1127 | HPDF_EXPORT(HPDF_STATUS) |
1128 | HPDF_LineAnnot_SetCaption (HPDF_Annotation annot, HPDF_BOOL showCaption, HPDF_LineAnnotCapPosition position, HPDF_INT horzOffset, HPDF_INT vertOffset) |
1129 | { |
1130 | HPDF_STATUS ret = HPDF_OK; |
1131 | HPDF_Array capOffset; |
1132 | HPDF_PTRACE((" HPDF_LineAnnot_SetCaption\n" )); |
1133 | |
1134 | ret += HPDF_Dict_AddBoolean ( annot, "Cap" , showCaption); |
1135 | ret += HPDF_Dict_AddName( annot, "CP" , HPDF_LINE_ANNOT_CAP_POSITION_NAMES[(HPDF_INT)position]); |
1136 | |
1137 | if (ret != HPDF_OK) |
1138 | return HPDF_Error_GetCode ( annot->error); |
1139 | |
1140 | capOffset = HPDF_Array_New ( annot->mmgr); |
1141 | if ( !capOffset) |
1142 | return HPDF_Error_GetCode ( annot->error); |
1143 | |
1144 | if ((ret = HPDF_Dict_Add ( annot, "CO" , capOffset)) != HPDF_OK) |
1145 | return ret; |
1146 | |
1147 | ret += HPDF_Array_AddNumber (capOffset, horzOffset); |
1148 | ret += HPDF_Array_AddNumber (capOffset, vertOffset); |
1149 | |
1150 | if (ret != HPDF_OK) |
1151 | return HPDF_Error_GetCode (capOffset->error); |
1152 | |
1153 | return HPDF_OK; |
1154 | } |
1155 | |
1156 | |
1157 | |
1158 | HPDF_EXPORT(HPDF_STATUS) |
1159 | HPDF_ProjectionAnnot_SetExData(HPDF_Annotation annot, HPDF_ExData exdata) |
1160 | { |
1161 | HPDF_STATUS ret = HPDF_OK; |
1162 | |
1163 | ret = HPDF_Dict_Add(annot, "ExData" , exdata); |
1164 | |
1165 | return ret; |
1166 | } |
1167 | |