index.js 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  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 AnnotationTypeString = {
  113. 1: 'text',
  114. 2: 'link',
  115. 3: 'freetext',
  116. 4: 'line',
  117. 5: 'square',
  118. 6: 'circle',
  119. 7: 'polygon',
  120. 8: 'polyline',
  121. 9: 'highlight',
  122. 10: 'underline',
  123. 11: 'squiggly',
  124. 12: 'strikeout',
  125. 13: 'stamp',
  126. 14: 'caret',
  127. 15: 'ink',
  128. 16: 'popup',
  129. 17: 'fileattachment',
  130. 18: 'sound',
  131. 19: 'movie',
  132. 20: 'widget',
  133. 21: 'screen',
  134. 22: 'printermark',
  135. 23: 'trapnet',
  136. 24: 'watermark',
  137. 25: 'threed',
  138. 26: 'redact',
  139. };
  140. const LineType = {
  141. UNKNOWN: -1,
  142. NONE: 0,
  143. OPENARROW: 1,
  144. CLOSEDARROW: 2,
  145. SQUARE: 3,
  146. CIRCLE: 4,
  147. DIAMOND: 5,
  148. BUTT: 6,
  149. ROPENARROW: 7,
  150. RCLOSEDARROW: 8,
  151. SLASH: 9,
  152. }
  153. const LineTypeString = {
  154. '-1': 'Unknown',
  155. 0: 'None',
  156. 1: 'OpenArrow',
  157. 2: 'closedarrow',
  158. 3: 'square',
  159. 4: 'circle',
  160. 5: 'diamond',
  161. 6: 'butt',
  162. 7: 'ropenarrow',
  163. 8: 'rclosedarrow',
  164. 9: 'slash',
  165. }
  166. const AnnotationStateModelType = {
  167. MARKED: "Marked",
  168. REVIEW: "Review",
  169. };
  170. const AnnotationMarkedState = {
  171. MARKED: "Marked",
  172. UNMARKED: "Unmarked",
  173. };
  174. const AnnotationReviewState = {
  175. ACCEPTED: "Accepted",
  176. REJECTED: "Rejected",
  177. CANCELLED: "Cancelled",
  178. COMPLETED: "Completed",
  179. NONE: "None",
  180. };
  181. const AnnotationReplyType = {
  182. GROUP: "Group",
  183. REPLY: "R",
  184. };
  185. const AnnotationFlag = {
  186. INVISIBLE: 0x01,
  187. HIDDEN: 0x02,
  188. PRINT: 0x04,
  189. NOZOOM: 0x08,
  190. NOROTATE: 0x10,
  191. NOVIEW: 0x20,
  192. READONLY: 0x40,
  193. LOCKED: 0x80,
  194. TOGGLENOVIEW: 0x100,
  195. LOCKEDCONTENTS: 0x200,
  196. };
  197. const AnnotationFieldFlag = {
  198. READONLY: 0x0000001,
  199. REQUIRED: 0x0000002,
  200. NOEXPORT: 0x0000004,
  201. MULTILINE: 0x0001000,
  202. PASSWORD: 0x0002000,
  203. NOTOGGLETOOFF: 0x0004000,
  204. RADIO: 0x0008000,
  205. PUSHBUTTON: 0x0010000,
  206. COMBO: 0x0020000,
  207. EDIT: 0x0040000,
  208. SORT: 0x0080000,
  209. FILESELECT: 0x0100000,
  210. MULTISELECT: 0x0200000,
  211. DONOTSPELLCHECK: 0x0400000,
  212. DONOTSCROLL: 0x0800000,
  213. COMB: 0x1000000,
  214. RICHTEXT: 0x2000000,
  215. RADIOSINUNISON: 0x2000000,
  216. COMMITONSELCHANGE: 0x4000000,
  217. };
  218. const AnnotationBorderStyleType = {
  219. SOLID: 1,
  220. DASHED: 2,
  221. BEVELED: 3,
  222. INSET: 4,
  223. UNDERLINE: 5,
  224. };
  225. const AnnotationActionEventType = {
  226. E: "Mouse Enter",
  227. X: "Mouse Exit",
  228. D: "Mouse Down",
  229. U: "Mouse Up",
  230. Fo: "Focus",
  231. Bl: "Blur",
  232. PO: "PageOpen",
  233. PC: "PageClose",
  234. PV: "PageVisible",
  235. PI: "PageInvisible",
  236. K: "Keystroke",
  237. F: "Format",
  238. V: "Validate",
  239. C: "Calculate",
  240. };
  241. const DocumentActionEventType = {
  242. WC: "WillClose",
  243. WS: "WillSave",
  244. DS: "DidSave",
  245. WP: "WillPrint",
  246. DP: "DidPrint",
  247. };
  248. const PageActionEventType = {
  249. O: "PageOpen",
  250. C: "PageClose",
  251. };
  252. const StreamType = {
  253. UNKNOWN: "UNKNOWN",
  254. FLATE: "FLATE",
  255. LZW: "LZW",
  256. DCT: "DCT",
  257. JPX: "JPX",
  258. JBIG: "JBIG",
  259. A85: "A85",
  260. AHX: "AHX",
  261. CCF: "CCF",
  262. RLX: "RLX", // PDF short name is 'RL', but telemetry requires three chars.
  263. };
  264. const FontType = {
  265. UNKNOWN: "UNKNOWN",
  266. TYPE1: "TYPE1",
  267. TYPE1STANDARD: "TYPE1STANDARD",
  268. TYPE1C: "TYPE1C",
  269. CIDFONTTYPE0: "CIDFONTTYPE0",
  270. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  271. TRUETYPE: "TRUETYPE",
  272. CIDFONTTYPE2: "CIDFONTTYPE2",
  273. TYPE3: "TYPE3",
  274. OPENTYPE: "OPENTYPE",
  275. TYPE0: "TYPE0",
  276. MMTYPE1: "MMTYPE1",
  277. };
  278. const VerbosityLevel = {
  279. ERRORS: 0,
  280. WARNINGS: 1,
  281. INFOS: 5,
  282. };
  283. const CMapCompressionType = {
  284. NONE: 0,
  285. BINARY: 1,
  286. };
  287. // All the possible operations for an operator list.
  288. const OPS = {
  289. // Intentionally start from 1 so it is easy to spot bad operators that will be
  290. // 0's.
  291. // PLEASE NOTE: We purposely keep any removed operators commented out, since
  292. // re-numbering the list would risk breaking third-party users.
  293. dependency: 1,
  294. setLineWidth: 2,
  295. setLineCap: 3,
  296. setLineJoin: 4,
  297. setMiterLimit: 5,
  298. setDash: 6,
  299. setRenderingIntent: 7,
  300. setFlatness: 8,
  301. setGState: 9,
  302. save: 10,
  303. restore: 11,
  304. transform: 12,
  305. moveTo: 13,
  306. lineTo: 14,
  307. curveTo: 15,
  308. curveTo2: 16,
  309. curveTo3: 17,
  310. closePath: 18,
  311. rectangle: 19,
  312. stroke: 20,
  313. closeStroke: 21,
  314. fill: 22,
  315. eoFill: 23,
  316. fillStroke: 24,
  317. eoFillStroke: 25,
  318. closeFillStroke: 26,
  319. closeEOFillStroke: 27,
  320. endPath: 28,
  321. clip: 29,
  322. eoClip: 30,
  323. beginText: 31,
  324. endText: 32,
  325. setCharSpacing: 33,
  326. setWordSpacing: 34,
  327. setHScale: 35,
  328. setLeading: 36,
  329. setFont: 37,
  330. setTextRenderingMode: 38,
  331. setTextRise: 39,
  332. moveText: 40,
  333. setLeadingMoveText: 41,
  334. setTextMatrix: 42,
  335. nextLine: 43,
  336. showText: 44,
  337. showSpacedText: 45,
  338. nextLineShowText: 46,
  339. nextLineSetSpacingShowText: 47,
  340. setCharWidth: 48,
  341. setCharWidthAndBounds: 49,
  342. setStrokeColorSpace: 50,
  343. setFillColorSpace: 51,
  344. setStrokeColor: 52,
  345. setStrokeColorN: 53,
  346. setFillColor: 54,
  347. setFillColorN: 55,
  348. setStrokeGray: 56,
  349. setFillGray: 57,
  350. setStrokeRGBColor: 58,
  351. setFillRGBColor: 59,
  352. setStrokeCMYKColor: 60,
  353. setFillCMYKColor: 61,
  354. shadingFill: 62,
  355. beginInlineImage: 63,
  356. beginImageData: 64,
  357. endInlineImage: 65,
  358. paintXObject: 66,
  359. markPoint: 67,
  360. markPointProps: 68,
  361. beginMarkedContent: 69,
  362. beginMarkedContentProps: 70,
  363. endMarkedContent: 71,
  364. beginCompat: 72,
  365. endCompat: 73,
  366. paintFormXObjectBegin: 74,
  367. paintFormXObjectEnd: 75,
  368. beginGroup: 76,
  369. endGroup: 77,
  370. // beginAnnotations: 78,
  371. // endAnnotations: 79,
  372. beginAnnotation: 80,
  373. endAnnotation: 81,
  374. // paintJpegXObject: 82,
  375. paintImageMaskXObject: 83,
  376. paintImageMaskXObjectGroup: 84,
  377. paintImageXObject: 85,
  378. paintInlineImageXObject: 86,
  379. paintInlineImageXObjectGroup: 87,
  380. paintImageXObjectRepeat: 88,
  381. paintImageMaskXObjectRepeat: 89,
  382. paintSolidColorImageMask: 90,
  383. constructPath: 91,
  384. };
  385. const UNSUPPORTED_FEATURES = {
  386. forms: "forms",
  387. javaScript: "javaScript",
  388. signatures: "signatures",
  389. smask: "smask",
  390. shadingPattern: "shadingPattern",
  391. errorTilingPattern: "errorTilingPattern",
  392. errorExtGState: "errorExtGState",
  393. errorXObject: "errorXObject",
  394. errorFontLoadType3: "errorFontLoadType3",
  395. errorFontState: "errorFontState",
  396. errorFontMissing: "errorFontMissing",
  397. errorFontTranslate: "errorFontTranslate",
  398. errorColorSpace: "errorColorSpace",
  399. errorOperatorList: "errorOperatorList",
  400. errorFontToUnicode: "errorFontToUnicode",
  401. errorFontLoadNative: "errorFontLoadNative",
  402. errorFontBuildPath: "errorFontBuildPath",
  403. errorFontGetPath: "errorFontGetPath",
  404. errorMarkedContent: "errorMarkedContent",
  405. errorContentSubStream: "errorContentSubStream",
  406. };
  407. const PasswordResponses = {
  408. NEED_PASSWORD: 1,
  409. INCORRECT_PASSWORD: 2,
  410. };
  411. class PixelsPerInch {
  412. static CSS = 96.0;
  413. static PDF = 72.0;
  414. static PDF_TO_CSS_UNITS = 1;
  415. }
  416. const ANNOTATION_TYPE = {
  417. ink: 'Ink',
  418. freetext: 'freetext',
  419. text: 'Text',
  420. square: 'Square',
  421. circle: 'Circle',
  422. line: 'Line',
  423. arrow: 'Line',
  424. image: 'Image',
  425. };
  426. export {
  427. RenderingStates,
  428. MARGIN_DISTANCE,
  429. IDENTITY_MATRIX,
  430. FONT_IDENTITY_MATRIX,
  431. LINE_FACTOR,
  432. MARKUP,
  433. LINE_DESCENT_FACTOR,
  434. RenderingIntentFlag,
  435. AnnotationEditorPrefix,
  436. AnnotationEditorType,
  437. AnnotationEditorParamsType,
  438. PermissionFlag,
  439. TextRenderingMode,
  440. ImageKind,
  441. AnnotationType,
  442. AnnotationTypeString,
  443. LineType,
  444. LineTypeString,
  445. AnnotationStateModelType,
  446. AnnotationMarkedState,
  447. AnnotationReviewState,
  448. AnnotationReplyType,
  449. AnnotationFlag,
  450. AnnotationFieldFlag,
  451. AnnotationBorderStyleType,
  452. AnnotationActionEventType,
  453. DocumentActionEventType,
  454. PageActionEventType,
  455. StreamType,
  456. FontType,
  457. VerbosityLevel,
  458. CMapCompressionType,
  459. OPS,
  460. PixelsPerInch,
  461. UNSUPPORTED_FEATURES,
  462. PasswordResponses,
  463. ANNOTATION_TYPE,
  464. ALIGN
  465. }