index.js 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. const RenderingStates = {
  2. INITIAL: 0,
  3. RUNNING: 1,
  4. PAUSED: 2,
  5. FINISHED: 3
  6. }
  7. const ALIGN = {
  8. left: 'left',
  9. centered: 'center',
  10. right: 'right'
  11. }
  12. const MARGIN_DISTANCE = 10
  13. const IDENTITY_MATRIX = [1, 0, 0, 1, 0, 0];
  14. const FONT_IDENTITY_MATRIX = [0.001, 0, 0, 0.001, 0, 0];
  15. // Represent the percentage of the height of a single-line field over
  16. // the font size. Acrobat seems to use this value.
  17. const LINE_FACTOR = 1.35;
  18. const LINE_DESCENT_FACTOR = 0.35;
  19. const MARKUP = ['highlight', 'underline', 'squiggly', 'strikeout']
  20. /**
  21. * Refer to the `WorkerTransport.getRenderingIntent`-method in the API, to see
  22. * how these flags are being used:
  23. * - ANY, DISPLAY, and PRINT are the normal rendering intents, note the
  24. * `PDFPageProxy.{render, getOperatorList, getAnnotations}`-methods.
  25. * - ANNOTATIONS_FORMS, ANNOTATIONS_STORAGE, ANNOTATIONS_DISABLE control which
  26. * annotations are rendered onto the canvas (i.e. by being included in the
  27. * operatorList), note the `PDFPageProxy.{render, getOperatorList}`-methods
  28. * and their `annotationMode`-option.
  29. * - OPLIST is used with the `PDFPageProxy.getOperatorList`-method, note the
  30. * `OperatorList`-constructor (on the worker-thread).
  31. */
  32. const RenderingIntentFlag = {
  33. ANY: 0x01,
  34. DISPLAY: 0x02,
  35. PRINT: 0x04,
  36. ANNOTATIONS_FORMS: 0x10,
  37. ANNOTATIONS_STORAGE: 0x20,
  38. ANNOTATIONS_DISABLE: 0x40,
  39. OPLIST: 0x100,
  40. };
  41. const AnnotationEditorPrefix = "pdfjs_internal_editor_";
  42. const AnnotationEditorType = {
  43. DISABLE: -1,
  44. NONE: 0,
  45. FREETEXT: 3,
  46. INK: 15,
  47. };
  48. const AnnotationEditorParamsType = {
  49. FREETEXT_SIZE: 1,
  50. FREETEXT_COLOR: 2,
  51. FREETEXT_OPACITY: 3,
  52. INK_COLOR: 11,
  53. INK_THICKNESS: 12,
  54. INK_OPACITY: 13,
  55. };
  56. // Permission flags from Table 22, Section 7.6.3.2 of the PDF specification.
  57. const PermissionFlag = {
  58. PRINT: 0x04,
  59. MODIFY_CONTENTS: 0x08,
  60. COPY: 0x10,
  61. MODIFY_ANNOTATIONS: 0x20,
  62. FILL_INTERACTIVE_FORMS: 0x100,
  63. COPY_FOR_ACCESSIBILITY: 0x200,
  64. ASSEMBLE: 0x400,
  65. PRINT_HIGH_QUALITY: 0x800,
  66. };
  67. const TextRenderingMode = {
  68. FILL: 0,
  69. STROKE: 1,
  70. FILL_STROKE: 2,
  71. INVISIBLE: 3,
  72. FILL_ADD_TO_PATH: 4,
  73. STROKE_ADD_TO_PATH: 5,
  74. FILL_STROKE_ADD_TO_PATH: 6,
  75. ADD_TO_PATH: 7,
  76. FILL_STROKE_MASK: 3,
  77. ADD_TO_PATH_FLAG: 4,
  78. };
  79. const ImageKind = {
  80. GRAYSCALE_1BPP: 1,
  81. RGB_24BPP: 2,
  82. RGBA_32BPP: 3,
  83. };
  84. const AnnotationType = {
  85. TEXT: 1,
  86. LINK: 2,
  87. FREETEXT: 3,
  88. LINE: 4,
  89. SQUARE: 5,
  90. CIRCLE: 6,
  91. POLYGON: 7,
  92. POLYLINE: 8,
  93. HIGHLIGHT: 9,
  94. UNDERLINE: 10,
  95. SQUIGGLY: 11,
  96. STRIKEOUT: 12,
  97. STAMP: 13,
  98. CARET: 14,
  99. INK: 15,
  100. POPUP: 16,
  101. FILEATTACHMENT: 17,
  102. SOUND: 18,
  103. MOVIE: 19,
  104. WIDGET: 20,
  105. SCREEN: 21,
  106. PRINTERMARK: 22,
  107. TRAPNET: 23,
  108. WATERMARK: 24,
  109. THREED: 25,
  110. REDACT: 26,
  111. };
  112. const AnnotationStateModelType = {
  113. MARKED: "Marked",
  114. REVIEW: "Review",
  115. };
  116. const AnnotationMarkedState = {
  117. MARKED: "Marked",
  118. UNMARKED: "Unmarked",
  119. };
  120. const AnnotationReviewState = {
  121. ACCEPTED: "Accepted",
  122. REJECTED: "Rejected",
  123. CANCELLED: "Cancelled",
  124. COMPLETED: "Completed",
  125. NONE: "None",
  126. };
  127. const AnnotationReplyType = {
  128. GROUP: "Group",
  129. REPLY: "R",
  130. };
  131. const AnnotationFlag = {
  132. INVISIBLE: 0x01,
  133. HIDDEN: 0x02,
  134. PRINT: 0x04,
  135. NOZOOM: 0x08,
  136. NOROTATE: 0x10,
  137. NOVIEW: 0x20,
  138. READONLY: 0x40,
  139. LOCKED: 0x80,
  140. TOGGLENOVIEW: 0x100,
  141. LOCKEDCONTENTS: 0x200,
  142. };
  143. const AnnotationFieldFlag = {
  144. READONLY: 0x0000001,
  145. REQUIRED: 0x0000002,
  146. NOEXPORT: 0x0000004,
  147. MULTILINE: 0x0001000,
  148. PASSWORD: 0x0002000,
  149. NOTOGGLETOOFF: 0x0004000,
  150. RADIO: 0x0008000,
  151. PUSHBUTTON: 0x0010000,
  152. COMBO: 0x0020000,
  153. EDIT: 0x0040000,
  154. SORT: 0x0080000,
  155. FILESELECT: 0x0100000,
  156. MULTISELECT: 0x0200000,
  157. DONOTSPELLCHECK: 0x0400000,
  158. DONOTSCROLL: 0x0800000,
  159. COMB: 0x1000000,
  160. RICHTEXT: 0x2000000,
  161. RADIOSINUNISON: 0x2000000,
  162. COMMITONSELCHANGE: 0x4000000,
  163. };
  164. const AnnotationBorderStyleType = {
  165. SOLID: 1,
  166. DASHED: 2,
  167. BEVELED: 3,
  168. INSET: 4,
  169. UNDERLINE: 5,
  170. };
  171. const AnnotationActionEventType = {
  172. E: "Mouse Enter",
  173. X: "Mouse Exit",
  174. D: "Mouse Down",
  175. U: "Mouse Up",
  176. Fo: "Focus",
  177. Bl: "Blur",
  178. PO: "PageOpen",
  179. PC: "PageClose",
  180. PV: "PageVisible",
  181. PI: "PageInvisible",
  182. K: "Keystroke",
  183. F: "Format",
  184. V: "Validate",
  185. C: "Calculate",
  186. };
  187. const DocumentActionEventType = {
  188. WC: "WillClose",
  189. WS: "WillSave",
  190. DS: "DidSave",
  191. WP: "WillPrint",
  192. DP: "DidPrint",
  193. };
  194. const PageActionEventType = {
  195. O: "PageOpen",
  196. C: "PageClose",
  197. };
  198. const StreamType = {
  199. UNKNOWN: "UNKNOWN",
  200. FLATE: "FLATE",
  201. LZW: "LZW",
  202. DCT: "DCT",
  203. JPX: "JPX",
  204. JBIG: "JBIG",
  205. A85: "A85",
  206. AHX: "AHX",
  207. CCF: "CCF",
  208. RLX: "RLX", // PDF short name is 'RL', but telemetry requires three chars.
  209. };
  210. const FontType = {
  211. UNKNOWN: "UNKNOWN",
  212. TYPE1: "TYPE1",
  213. TYPE1STANDARD: "TYPE1STANDARD",
  214. TYPE1C: "TYPE1C",
  215. CIDFONTTYPE0: "CIDFONTTYPE0",
  216. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  217. TRUETYPE: "TRUETYPE",
  218. CIDFONTTYPE2: "CIDFONTTYPE2",
  219. TYPE3: "TYPE3",
  220. OPENTYPE: "OPENTYPE",
  221. TYPE0: "TYPE0",
  222. MMTYPE1: "MMTYPE1",
  223. };
  224. const VerbosityLevel = {
  225. ERRORS: 0,
  226. WARNINGS: 1,
  227. INFOS: 5,
  228. };
  229. const CMapCompressionType = {
  230. NONE: 0,
  231. BINARY: 1,
  232. };
  233. // All the possible operations for an operator list.
  234. const OPS = {
  235. // Intentionally start from 1 so it is easy to spot bad operators that will be
  236. // 0's.
  237. // PLEASE NOTE: We purposely keep any removed operators commented out, since
  238. // re-numbering the list would risk breaking third-party users.
  239. dependency: 1,
  240. setLineWidth: 2,
  241. setLineCap: 3,
  242. setLineJoin: 4,
  243. setMiterLimit: 5,
  244. setDash: 6,
  245. setRenderingIntent: 7,
  246. setFlatness: 8,
  247. setGState: 9,
  248. save: 10,
  249. restore: 11,
  250. transform: 12,
  251. moveTo: 13,
  252. lineTo: 14,
  253. curveTo: 15,
  254. curveTo2: 16,
  255. curveTo3: 17,
  256. closePath: 18,
  257. rectangle: 19,
  258. stroke: 20,
  259. closeStroke: 21,
  260. fill: 22,
  261. eoFill: 23,
  262. fillStroke: 24,
  263. eoFillStroke: 25,
  264. closeFillStroke: 26,
  265. closeEOFillStroke: 27,
  266. endPath: 28,
  267. clip: 29,
  268. eoClip: 30,
  269. beginText: 31,
  270. endText: 32,
  271. setCharSpacing: 33,
  272. setWordSpacing: 34,
  273. setHScale: 35,
  274. setLeading: 36,
  275. setFont: 37,
  276. setTextRenderingMode: 38,
  277. setTextRise: 39,
  278. moveText: 40,
  279. setLeadingMoveText: 41,
  280. setTextMatrix: 42,
  281. nextLine: 43,
  282. showText: 44,
  283. showSpacedText: 45,
  284. nextLineShowText: 46,
  285. nextLineSetSpacingShowText: 47,
  286. setCharWidth: 48,
  287. setCharWidthAndBounds: 49,
  288. setStrokeColorSpace: 50,
  289. setFillColorSpace: 51,
  290. setStrokeColor: 52,
  291. setStrokeColorN: 53,
  292. setFillColor: 54,
  293. setFillColorN: 55,
  294. setStrokeGray: 56,
  295. setFillGray: 57,
  296. setStrokeRGBColor: 58,
  297. setFillRGBColor: 59,
  298. setStrokeCMYKColor: 60,
  299. setFillCMYKColor: 61,
  300. shadingFill: 62,
  301. beginInlineImage: 63,
  302. beginImageData: 64,
  303. endInlineImage: 65,
  304. paintXObject: 66,
  305. markPoint: 67,
  306. markPointProps: 68,
  307. beginMarkedContent: 69,
  308. beginMarkedContentProps: 70,
  309. endMarkedContent: 71,
  310. beginCompat: 72,
  311. endCompat: 73,
  312. paintFormXObjectBegin: 74,
  313. paintFormXObjectEnd: 75,
  314. beginGroup: 76,
  315. endGroup: 77,
  316. // beginAnnotations: 78,
  317. // endAnnotations: 79,
  318. beginAnnotation: 80,
  319. endAnnotation: 81,
  320. // paintJpegXObject: 82,
  321. paintImageMaskXObject: 83,
  322. paintImageMaskXObjectGroup: 84,
  323. paintImageXObject: 85,
  324. paintInlineImageXObject: 86,
  325. paintInlineImageXObjectGroup: 87,
  326. paintImageXObjectRepeat: 88,
  327. paintImageMaskXObjectRepeat: 89,
  328. paintSolidColorImageMask: 90,
  329. constructPath: 91,
  330. };
  331. const UNSUPPORTED_FEATURES = {
  332. forms: "forms",
  333. javaScript: "javaScript",
  334. signatures: "signatures",
  335. smask: "smask",
  336. shadingPattern: "shadingPattern",
  337. errorTilingPattern: "errorTilingPattern",
  338. errorExtGState: "errorExtGState",
  339. errorXObject: "errorXObject",
  340. errorFontLoadType3: "errorFontLoadType3",
  341. errorFontState: "errorFontState",
  342. errorFontMissing: "errorFontMissing",
  343. errorFontTranslate: "errorFontTranslate",
  344. errorColorSpace: "errorColorSpace",
  345. errorOperatorList: "errorOperatorList",
  346. errorFontToUnicode: "errorFontToUnicode",
  347. errorFontLoadNative: "errorFontLoadNative",
  348. errorFontBuildPath: "errorFontBuildPath",
  349. errorFontGetPath: "errorFontGetPath",
  350. errorMarkedContent: "errorMarkedContent",
  351. errorContentSubStream: "errorContentSubStream",
  352. };
  353. const PasswordResponses = {
  354. NEED_PASSWORD: 1,
  355. INCORRECT_PASSWORD: 2,
  356. };
  357. class PixelsPerInch {
  358. static CSS = 96.0;
  359. static PDF = 72.0;
  360. static PDF_TO_CSS_UNITS = 1;
  361. }
  362. const ANNOTATION_TYPE = {
  363. ink: 'Ink',
  364. freetext: 'freetext',
  365. text: 'Text',
  366. square: 'Square',
  367. circle: 'Circle',
  368. line: 'Line',
  369. arrow: 'Line',
  370. image: 'Image',
  371. };
  372. export {
  373. RenderingStates,
  374. MARGIN_DISTANCE,
  375. IDENTITY_MATRIX,
  376. FONT_IDENTITY_MATRIX,
  377. LINE_FACTOR,
  378. MARKUP,
  379. LINE_DESCENT_FACTOR,
  380. RenderingIntentFlag,
  381. AnnotationEditorPrefix,
  382. AnnotationEditorType,
  383. AnnotationEditorParamsType,
  384. PermissionFlag,
  385. TextRenderingMode,
  386. ImageKind,
  387. AnnotationType,
  388. AnnotationStateModelType,
  389. AnnotationMarkedState,
  390. AnnotationReviewState,
  391. AnnotationReplyType,
  392. AnnotationFlag,
  393. AnnotationFieldFlag,
  394. AnnotationBorderStyleType,
  395. AnnotationActionEventType,
  396. DocumentActionEventType,
  397. PageActionEventType,
  398. StreamType,
  399. FontType,
  400. VerbosityLevel,
  401. CMapCompressionType,
  402. OPS,
  403. PixelsPerInch,
  404. UNSUPPORTED_FEATURES,
  405. PasswordResponses,
  406. ANNOTATION_TYPE,
  407. ALIGN
  408. }