index.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683
  1. const RenderingStates = {
  2. INITIAL: 0,
  3. RUNNING: 1,
  4. PAUSED: 2,
  5. FINISHED: 3
  6. }
  7. const ALIGN = {
  8. 0: 'left',
  9. 1: 'center',
  10. 2: '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 WidgetType = {
  141. PushButton: 0,
  142. CheckBox: 1,
  143. RadioButton: 2,
  144. TextField: 3,
  145. ComboBox: 4,
  146. ListBox: 5,
  147. SignatureFields: 6,
  148. Unknown: 0xff
  149. }
  150. const WidgetTypeString = {
  151. 0: 'pushbutton',
  152. 1: 'checkbox',
  153. 2: 'radiobutton',
  154. 3: 'textfield',
  155. 4: 'combobox',
  156. 5: 'listbox',
  157. 6: 'signaturefields',
  158. 0xff: 'unknown',
  159. }
  160. const TextFiledSpecial = {
  161. normal: 0,
  162. date: 1
  163. }
  164. const TextFiledSpecialString = {
  165. 0: 'normal',
  166. 1: 'date'
  167. }
  168. const LineType = {
  169. UNKNOWN: -1,
  170. NONE: 0,
  171. OPENARROW: 1,
  172. CLOSEDARROW: 2,
  173. SQUARE: 3,
  174. CIRCLE: 4,
  175. DIAMOND: 5,
  176. BUTT: 6,
  177. ROPENARROW: 7,
  178. RCLOSEDARROW: 8,
  179. SLASH: 9,
  180. }
  181. const LineTypeString = {
  182. '-1': 'Unknown',
  183. 0: 'None',
  184. 1: 'OpenArrow',
  185. 2: 'closedarrow',
  186. 3: 'square',
  187. 4: 'circle',
  188. 5: 'diamond',
  189. 6: 'butt',
  190. 7: 'ropenarrow',
  191. 8: 'rclosedarrow',
  192. 9: 'slash',
  193. }
  194. const CheckStyle = {
  195. none: -1,
  196. check: 0,
  197. circle: 1,
  198. cross: 2,
  199. diamond: 3,
  200. square: 4,
  201. star: 5,
  202. }
  203. const CheckStyleString = {
  204. 1: 'none',
  205. 0: 'check',
  206. 1: 'circle',
  207. 2: 'cross',
  208. 3: 'diamond',
  209. 4: 'square',
  210. 5: 'star',
  211. }
  212. const StampType = {
  213. UNKNOWN: 0,
  214. STANDARD: 1,
  215. IMAGE: 2,
  216. TEXT: 3,
  217. DIGITAL: 4,
  218. }
  219. const StampTypeString = {
  220. 0: 'unknown',
  221. 1: 'standard',
  222. 2: 'image',
  223. 3: 'text',
  224. 4: 'digital',
  225. }
  226. const TextStampColor = {
  227. white: 0,
  228. red: 1,
  229. green: 2,
  230. blu: 3,
  231. }
  232. const TextStampColorString = {
  233. 0: 'white',
  234. 1: 'red',
  235. 2: 'green',
  236. 3: 'blu',
  237. }
  238. const ActionType = {
  239. Unknown: 0,
  240. GoTo: 1,
  241. GoToR: 2,
  242. GoToE: 3,
  243. Launch: 4,
  244. Thread: 5,
  245. URI: 6,
  246. Sound: 7,
  247. Movie: 8,
  248. Hide: 9,
  249. Named: 10,
  250. SubmitForm: 11,
  251. ResetForm: 12,
  252. ImportData: 13,
  253. JavaScript: 14,
  254. SetOCGState: 15,
  255. Rendition: 16,
  256. Trans: 17,
  257. GoTo3DView: 18,
  258. UOP: 19, //unlock uop
  259. Error: 0xff
  260. }
  261. const ActionTypeString = {
  262. 0: 'unknown',
  263. 1: 'goto',
  264. 2: 'gotor',
  265. 3: 'gotoe',
  266. 4: 'launch',
  267. 5: 'thread',
  268. 6: 'uri',
  269. 7: 'sound',
  270. 8: 'movie',
  271. 9: 'hide',
  272. 10: 'named',
  273. 11: 'submitform',
  274. 12: 'resetform',
  275. 13: 'importdata',
  276. 14: 'javascript',
  277. 15: 'setocgstate',
  278. 16: 'rendition',
  279. 17: 'trans',
  280. 18: 'goto3dview',
  281. 19: 'uop',
  282. 0xff: 'error',
  283. }
  284. const BorderStyle = {
  285. solid: 0,
  286. dashded: 1,
  287. beveled: 2,
  288. inset: 3,
  289. underline: 4,
  290. }
  291. const BorderStyleString = {
  292. 0: 'solid',
  293. 1: 'dashded',
  294. 2: 'beveled',
  295. 3: 'inset',
  296. 4: 'underline',
  297. }
  298. const TextStampShape = {
  299. rect: 0,
  300. leftTriangle: 1,
  301. rightTriangle: 2,
  302. none: 3,
  303. }
  304. const TextStampShapeString = {
  305. 0: 'rect',
  306. 1: 'leftTriangle',
  307. 2: 'rightTriangle',
  308. 3: 'none',
  309. }
  310. const AnnotationStateModelType = {
  311. MARKED: "Marked",
  312. REVIEW: "Review",
  313. };
  314. const AnnotationMarkedState = {
  315. MARKED: "Marked",
  316. UNMARKED: "Unmarked",
  317. };
  318. const AnnotationReviewState = {
  319. ACCEPTED: "Accepted",
  320. REJECTED: "Rejected",
  321. CANCELLED: "Cancelled",
  322. COMPLETED: "Completed",
  323. NONE: "None",
  324. };
  325. const AnnotationReplyType = {
  326. GROUP: "Group",
  327. REPLY: "R",
  328. };
  329. const AnnotationFlag = {
  330. INVISIBLE: 0x01,
  331. HIDDEN: 0x02,
  332. PRINT: 0x04,
  333. NOZOOM: 0x08,
  334. NOROTATE: 0x10,
  335. NOVIEW: 0x20,
  336. READONLY: 0x40,
  337. LOCKED: 0x80,
  338. TOGGLENOVIEW: 0x100,
  339. LOCKEDCONTENTS: 0x200,
  340. };
  341. const AnnotationFieldFlag = {
  342. READONLY: 0x0000001,
  343. REQUIRED: 0x0000002,
  344. NOEXPORT: 0x0000004,
  345. MULTILINE: 0x0001000,
  346. PASSWORD: 0x0002000,
  347. NOTOGGLETOOFF: 0x0004000,
  348. RADIO: 0x0008000,
  349. PUSHBUTTON: 0x0010000,
  350. COMBO: 0x0020000,
  351. EDIT: 0x0040000,
  352. SORT: 0x0080000,
  353. FILESELECT: 0x0100000,
  354. MULTISELECT: 0x0200000,
  355. DONOTSPELLCHECK: 0x0400000,
  356. DONOTSCROLL: 0x0800000,
  357. COMB: 0x1000000,
  358. RICHTEXT: 0x2000000,
  359. RADIOSINUNISON: 0x2000000,
  360. COMMITONSELCHANGE: 0x4000000,
  361. };
  362. const AnnotationBorderStyleType = {
  363. SOLID: 1,
  364. DASHED: 2,
  365. BEVELED: 3,
  366. INSET: 4,
  367. UNDERLINE: 5,
  368. };
  369. const AnnotationActionEventType = {
  370. E: "Mouse Enter",
  371. X: "Mouse Exit",
  372. D: "Mouse Down",
  373. U: "Mouse Up",
  374. Fo: "Focus",
  375. Bl: "Blur",
  376. PO: "PageOpen",
  377. PC: "PageClose",
  378. PV: "PageVisible",
  379. PI: "PageInvisible",
  380. K: "Keystroke",
  381. F: "Format",
  382. V: "Validate",
  383. C: "Calculate",
  384. };
  385. const DocumentActionEventType = {
  386. WC: "WillClose",
  387. WS: "WillSave",
  388. DS: "DidSave",
  389. WP: "WillPrint",
  390. DP: "DidPrint",
  391. };
  392. const PageActionEventType = {
  393. O: "PageOpen",
  394. C: "PageClose",
  395. };
  396. const StreamType = {
  397. UNKNOWN: "UNKNOWN",
  398. FLATE: "FLATE",
  399. LZW: "LZW",
  400. DCT: "DCT",
  401. JPX: "JPX",
  402. JBIG: "JBIG",
  403. A85: "A85",
  404. AHX: "AHX",
  405. CCF: "CCF",
  406. RLX: "RLX", // PDF short name is 'RL', but telemetry requires three chars.
  407. };
  408. const FontType = {
  409. UNKNOWN: "UNKNOWN",
  410. TYPE1: "TYPE1",
  411. TYPE1STANDARD: "TYPE1STANDARD",
  412. TYPE1C: "TYPE1C",
  413. CIDFONTTYPE0: "CIDFONTTYPE0",
  414. CIDFONTTYPE0C: "CIDFONTTYPE0C",
  415. TRUETYPE: "TRUETYPE",
  416. CIDFONTTYPE2: "CIDFONTTYPE2",
  417. TYPE3: "TYPE3",
  418. OPENTYPE: "OPENTYPE",
  419. TYPE0: "TYPE0",
  420. MMTYPE1: "MMTYPE1",
  421. };
  422. const VerbosityLevel = {
  423. ERRORS: 0,
  424. WARNINGS: 1,
  425. INFOS: 5,
  426. };
  427. const CMapCompressionType = {
  428. NONE: 0,
  429. BINARY: 1,
  430. };
  431. // All the possible operations for an operator list.
  432. const OPS = {
  433. // Intentionally start from 1 so it is easy to spot bad operators that will be
  434. // 0's.
  435. // PLEASE NOTE: We purposely keep any removed operators commented out, since
  436. // re-numbering the list would risk breaking third-party users.
  437. dependency: 1,
  438. setLineWidth: 2,
  439. setLineCap: 3,
  440. setLineJoin: 4,
  441. setMiterLimit: 5,
  442. setDash: 6,
  443. setRenderingIntent: 7,
  444. setFlatness: 8,
  445. setGState: 9,
  446. save: 10,
  447. restore: 11,
  448. transform: 12,
  449. moveTo: 13,
  450. lineTo: 14,
  451. curveTo: 15,
  452. curveTo2: 16,
  453. curveTo3: 17,
  454. closePath: 18,
  455. rectangle: 19,
  456. stroke: 20,
  457. closeStroke: 21,
  458. fill: 22,
  459. eoFill: 23,
  460. fillStroke: 24,
  461. eoFillStroke: 25,
  462. closeFillStroke: 26,
  463. closeEOFillStroke: 27,
  464. endPath: 28,
  465. clip: 29,
  466. eoClip: 30,
  467. beginText: 31,
  468. endText: 32,
  469. setCharSpacing: 33,
  470. setWordSpacing: 34,
  471. setHScale: 35,
  472. setLeading: 36,
  473. setFont: 37,
  474. setTextRenderingMode: 38,
  475. setTextRise: 39,
  476. moveText: 40,
  477. setLeadingMoveText: 41,
  478. setTextMatrix: 42,
  479. nextLine: 43,
  480. showText: 44,
  481. showSpacedText: 45,
  482. nextLineShowText: 46,
  483. nextLineSetSpacingShowText: 47,
  484. setCharWidth: 48,
  485. setCharWidthAndBounds: 49,
  486. setStrokeColorSpace: 50,
  487. setFillColorSpace: 51,
  488. setStrokeColor: 52,
  489. setStrokeColorN: 53,
  490. setFillColor: 54,
  491. setFillColorN: 55,
  492. setStrokeGray: 56,
  493. setFillGray: 57,
  494. setStrokeRGBColor: 58,
  495. setFillRGBColor: 59,
  496. setStrokeCMYKColor: 60,
  497. setFillCMYKColor: 61,
  498. shadingFill: 62,
  499. beginInlineImage: 63,
  500. beginImageData: 64,
  501. endInlineImage: 65,
  502. paintXObject: 66,
  503. markPoint: 67,
  504. markPointProps: 68,
  505. beginMarkedContent: 69,
  506. beginMarkedContentProps: 70,
  507. endMarkedContent: 71,
  508. beginCompat: 72,
  509. endCompat: 73,
  510. paintFormXObjectBegin: 74,
  511. paintFormXObjectEnd: 75,
  512. beginGroup: 76,
  513. endGroup: 77,
  514. // beginAnnotations: 78,
  515. // endAnnotations: 79,
  516. beginAnnotation: 80,
  517. endAnnotation: 81,
  518. // paintJpegXObject: 82,
  519. paintImageMaskXObject: 83,
  520. paintImageMaskXObjectGroup: 84,
  521. paintImageXObject: 85,
  522. paintInlineImageXObject: 86,
  523. paintInlineImageXObjectGroup: 87,
  524. paintImageXObjectRepeat: 88,
  525. paintImageMaskXObjectRepeat: 89,
  526. paintSolidColorImageMask: 90,
  527. constructPath: 91,
  528. };
  529. const UNSUPPORTED_FEATURES = {
  530. forms: "forms",
  531. javaScript: "javaScript",
  532. signatures: "signatures",
  533. smask: "smask",
  534. shadingPattern: "shadingPattern",
  535. errorTilingPattern: "errorTilingPattern",
  536. errorExtGState: "errorExtGState",
  537. errorXObject: "errorXObject",
  538. errorFontLoadType3: "errorFontLoadType3",
  539. errorFontState: "errorFontState",
  540. errorFontMissing: "errorFontMissing",
  541. errorFontTranslate: "errorFontTranslate",
  542. errorColorSpace: "errorColorSpace",
  543. errorOperatorList: "errorOperatorList",
  544. errorFontToUnicode: "errorFontToUnicode",
  545. errorFontLoadNative: "errorFontLoadNative",
  546. errorFontBuildPath: "errorFontBuildPath",
  547. errorFontGetPath: "errorFontGetPath",
  548. errorMarkedContent: "errorMarkedContent",
  549. errorContentSubStream: "errorContentSubStream",
  550. };
  551. const PasswordResponses = {
  552. NEED_PASSWORD: 1,
  553. INCORRECT_PASSWORD: 2,
  554. };
  555. class PixelsPerInch {
  556. static CSS = 96.0;
  557. static PDF = 72.0;
  558. static PDF_TO_CSS_UNITS = 1;
  559. }
  560. const ANNOTATION_TYPE = {
  561. ink: 'Ink',
  562. freetext: 'freetext',
  563. text: 'Text',
  564. square: 'Square',
  565. circle: 'Circle',
  566. line: 'Line',
  567. arrow: 'Line',
  568. image: 'Image',
  569. };
  570. export {
  571. RenderingStates,
  572. MARGIN_DISTANCE,
  573. IDENTITY_MATRIX,
  574. FONT_IDENTITY_MATRIX,
  575. LINE_FACTOR,
  576. MARKUP,
  577. LINE_DESCENT_FACTOR,
  578. RenderingIntentFlag,
  579. AnnotationEditorPrefix,
  580. AnnotationEditorType,
  581. AnnotationEditorParamsType,
  582. PermissionFlag,
  583. TextRenderingMode,
  584. ImageKind,
  585. AnnotationType,
  586. AnnotationTypeString,
  587. WidgetType,
  588. WidgetTypeString,
  589. TextFiledSpecial,
  590. TextFiledSpecialString,
  591. LineType,
  592. LineTypeString,
  593. CheckStyle,
  594. CheckStyleString,
  595. StampType,
  596. StampTypeString,
  597. TextStampColor,
  598. TextStampColorString,
  599. ActionType,
  600. ActionTypeString,
  601. BorderStyle,
  602. BorderStyleString,
  603. TextStampShape,
  604. TextStampShapeString,
  605. AnnotationStateModelType,
  606. AnnotationMarkedState,
  607. AnnotationReviewState,
  608. AnnotationReplyType,
  609. AnnotationFlag,
  610. AnnotationFieldFlag,
  611. AnnotationBorderStyleType,
  612. AnnotationActionEventType,
  613. DocumentActionEventType,
  614. PageActionEventType,
  615. StreamType,
  616. FontType,
  617. VerbosityLevel,
  618. CMapCompressionType,
  619. OPS,
  620. PixelsPerInch,
  621. UNSUPPORTED_FEATURES,
  622. PasswordResponses,
  623. ANNOTATION_TYPE,
  624. ALIGN
  625. }