annot.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. #ifndef MUPDF_PDF_ANNOT_H
  2. #define MUPDF_PDF_ANNOT_H
  3. typedef enum
  4. {
  5. PDF_ANNOT_TEXT,
  6. PDF_ANNOT_LINK,
  7. PDF_ANNOT_FREE_TEXT,
  8. PDF_ANNOT_LINE,
  9. PDF_ANNOT_SQUARE,
  10. PDF_ANNOT_CIRCLE,
  11. PDF_ANNOT_POLYGON,
  12. PDF_ANNOT_POLY_LINE,
  13. PDF_ANNOT_HIGHLIGHT,
  14. PDF_ANNOT_UNDERLINE,
  15. PDF_ANNOT_SQUIGGLY,
  16. PDF_ANNOT_STRIKE_OUT,
  17. PDF_ANNOT_STAMP,
  18. PDF_ANNOT_CARET,
  19. PDF_ANNOT_INK,
  20. PDF_ANNOT_POPUP,
  21. PDF_ANNOT_FILE_ATTACHMENT,
  22. PDF_ANNOT_SOUND,
  23. PDF_ANNOT_MOVIE,
  24. PDF_ANNOT_WIDGET,
  25. PDF_ANNOT_SCREEN,
  26. PDF_ANNOT_PRINTER_MARK,
  27. PDF_ANNOT_TRAP_NET,
  28. PDF_ANNOT_WATERMARK,
  29. PDF_ANNOT_3D,
  30. PDF_ANNOT_UNKNOWN = -1
  31. } fz_annot_type;
  32. const char *pdf_string_from_annot_type(fz_annot_type type);
  33. int pdf_annot_type_from_string(const char *subtype);
  34. enum
  35. {
  36. PDF_ANNOT_IS_INVISIBLE = 1 << (1-1),
  37. PDF_ANNOT_IS_HIDDEN = 1 << (2-1),
  38. PDF_ANNOT_IS_PRINT = 1 << (3-1),
  39. PDF_ANNOT_IS_NO_ZOOM = 1 << (4-1),
  40. PDF_ANNOT_IS_NO_ROTATE = 1 << (5-1),
  41. PDF_ANNOT_IS_NO_VIEW = 1 << (6-1),
  42. PDF_ANNOT_IS_READ_ONLY = 1 << (7-1),
  43. PDF_ANNOT_IS_LOCKED = 1 << (8-1),
  44. PDF_ANNOT_IS_TOGGLE_NO_VIEW = 1 << (9-1),
  45. PDF_ANNOT_IS_LOCKED_CONTENTS = 1 << (10-1)
  46. };
  47. /*
  48. pdf_first_annot: Return the first annotation on a page.
  49. Does not throw exceptions.
  50. */
  51. pdf_annot *pdf_first_annot(fz_context *ctx, pdf_page *page);
  52. /*
  53. pdf_next_annot: Return the next annotation on a page.
  54. Does not throw exceptions.
  55. */
  56. pdf_annot *pdf_next_annot(fz_context *ctx, pdf_annot *annot);
  57. /*
  58. pdf_bound_annot: Return the rectangle for an annotation on a page.
  59. Does not throw exceptions.
  60. */
  61. fz_rect *pdf_bound_annot(fz_context *ctx, pdf_annot *annot, fz_rect *rect);
  62. /*
  63. pdf_annot_type: Return the type of an annotation
  64. */
  65. int pdf_annot_type(fz_context *ctx, pdf_annot *annot);
  66. /*
  67. pdf_run_annot: Interpret an annotation and render it on a device.
  68. page: A page loaded by pdf_load_page.
  69. annot: an annotation.
  70. dev: Device used for rendering, obtained from fz_new_*_device.
  71. ctm: A transformation matrix applied to the objects on the page,
  72. e.g. to scale or rotate the page contents as desired.
  73. */
  74. void pdf_run_annot(fz_context *ctx, pdf_annot *annot, fz_device *dev, const fz_matrix *ctm, fz_cookie *cookie);
  75. struct pdf_annot_s
  76. {
  77. fz_annot super;
  78. pdf_page *page;
  79. pdf_obj *obj;
  80. pdf_xobject *ap;
  81. int ap_iteration;
  82. int changed;
  83. pdf_annot *next;
  84. };
  85. char *pdf_parse_file_spec(fz_context *ctx, pdf_document *doc, pdf_obj *file_spec, pdf_obj *dest);
  86. char *pdf_parse_link_dest(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
  87. char *pdf_parse_link_action(fz_context *ctx, pdf_document *doc, pdf_obj *obj);
  88. pdf_obj *pdf_lookup_dest(fz_context *ctx, pdf_document *doc, pdf_obj *needle);
  89. pdf_obj *pdf_lookup_name(fz_context *ctx, pdf_document *doc, pdf_obj *which, pdf_obj *needle);
  90. pdf_obj *pdf_load_name_tree(fz_context *ctx, pdf_document *doc, pdf_obj *which);
  91. int pdf_resolve_link(fz_context *ctx, pdf_document *doc, const char *uri, float *xp, float *yp);
  92. fz_link *pdf_load_link_annots(fz_context *ctx, pdf_document *, pdf_obj *annots, const fz_matrix *page_ctm);
  93. void pdf_annot_transform(fz_context *ctx, pdf_annot *annot, fz_matrix *annot_ctm);
  94. void pdf_load_annots(fz_context *ctx, pdf_page *page, pdf_obj *annots);
  95. void pdf_update_annot(fz_context *ctx, pdf_annot *annot);
  96. void pdf_drop_annots(fz_context *ctx, pdf_annot *annot_list);
  97. /*
  98. pdf_create_annot: create a new annotation of the specified type on the
  99. specified page. The returned pdf_annot structure is owned by the page
  100. and does not need to be freed.
  101. */
  102. pdf_annot *pdf_create_annot(fz_context *ctx, pdf_page *page, fz_annot_type type);
  103. /*
  104. pdf_delete_annot: delete an annotation
  105. */
  106. void pdf_delete_annot(fz_context *ctx, pdf_page *page, pdf_annot *annot);
  107. int pdf_annot_flags(fz_context *ctx, pdf_annot *annot);
  108. void pdf_annot_rect(fz_context *ctx, pdf_annot *annot, fz_rect *rect);
  109. float pdf_annot_border(fz_context *ctx, pdf_annot *annot);
  110. void pdf_annot_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4]);
  111. void pdf_annot_interior_color(fz_context *ctx, pdf_annot *annot, int *n, float color[4]);
  112. int pdf_annot_quad_point_count(fz_context *ctx, pdf_annot *annot);
  113. void pdf_annot_quad_point(fz_context *ctx, pdf_annot *annot, int i, float qp[8]);
  114. int pdf_annot_ink_list_count(fz_context *ctx, pdf_annot *annot);
  115. int pdf_annot_ink_list_stroke_count(fz_context *ctx, pdf_annot *annot, int i);
  116. void pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k, float v[2]);
  117. void pdf_set_annot_flags(fz_context *ctx, pdf_annot *annot, int flags);
  118. void pdf_set_annot_rect(fz_context *ctx, pdf_annot *annot, const fz_rect *rect);
  119. void pdf_set_annot_border(fz_context *ctx, pdf_annot *annot, float width);
  120. void pdf_set_annot_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]);
  121. void pdf_set_annot_interior_color(fz_context *ctx, pdf_annot *annot, int n, const float color[4]);
  122. void pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const float *v);
  123. void pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const float *v);
  124. void pdf_set_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int start_style, int end_style);
  125. void pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v);
  126. void pdf_set_annot_icon_name(fz_context *ctx, pdf_annot *annot, const char *name);
  127. void pdf_set_annot_is_open(fz_context *ctx, pdf_annot *annot, int is_open);
  128. void pdf_annot_line_ending_styles(fz_context *ctx, pdf_annot *annot, int *start_style, int *end_style);
  129. const char *pdf_annot_icon_name(fz_context *ctx, pdf_annot *annot);
  130. int pdf_annot_is_open(fz_context *ctx, pdf_annot *annot);
  131. int pdf_annot_vertex_count(fz_context *ctx, pdf_annot *annot);
  132. void pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i, float v[2]);
  133. /*
  134. pdf_set_text_annot_position: set the position on page for a text (sticky note) annotation.
  135. */
  136. void pdf_set_text_annot_position(fz_context *ctx, pdf_annot *annot, fz_point pt);
  137. /*
  138. pdf_set_annot_contents: set the contents of an annotation.
  139. */
  140. void pdf_set_annot_contents(fz_context *ctx, pdf_annot *annot, const char *text);
  141. /*
  142. pdf_annot_contents: return the contents of an annotation.
  143. */
  144. const char *pdf_annot_contents(fz_context *ctx, pdf_annot *annot);
  145. /*
  146. pdf_annot_author: return the author of an annotation.
  147. */
  148. const char *pdf_annot_author(fz_context *ctx, pdf_annot *annot);
  149. /*
  150. pdf_annot_author: return the date of an annotation.
  151. */
  152. // TODO: creation date
  153. // TODO: modification date
  154. const char *pdf_annot_date(fz_context *ctx, pdf_annot *annot);
  155. /*
  156. pdf_annot_irt: return the indirect reference that this annotation is in reply to.
  157. */
  158. pdf_obj *pdf_annot_irt(fz_context *ctx, pdf_annot *annot);
  159. /*
  160. pdf_set_free_text_details: set the position, text, font and color for a free text annotation.
  161. Only base 14 fonts are supported and are specified by name.
  162. */
  163. void pdf_set_free_text_details(fz_context *ctx, pdf_annot *annot, fz_point *pos, char *text, char *font_name, float font_size, float color[3]);
  164. /*
  165. pdf_new_annot: Internal function for creating a new pdf annotation.
  166. */
  167. pdf_annot *pdf_new_annot(fz_context *ctx, pdf_page *page);
  168. #endif