index.js 8.9 KB

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