index.js 13 KB

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