@syncfusion/ej2-pdf 1.0.23 → 23.1.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +260 -0
- package/.gitleaksignore +1 -0
- package/CHANGELOG.md +28 -0
- package/README.md +17 -0
- package/dist/ej2-pdf.umd.min.js +4 -14
- package/dist/ej2-pdf.umd.min.js.map +1 -11
- package/dist/es6/ej2-pdf.es2015.js +48372 -0
- package/dist/es6/ej2-pdf.es2015.js.map +1 -0
- package/dist/es6/ej2-pdf.es5.js +50250 -0
- package/dist/es6/ej2-pdf.es5.js.map +1 -0
- package/dist/global/ej2-pdf.min.js +11 -0
- package/dist/global/ej2-pdf.min.js.map +1 -0
- package/dist/global/index.d.ts +14 -0
- package/index.js +4 -8
- package/license +10 -3
- package/package.json +58 -16
- package/pdf.d.ts +4 -0
- package/pdf.js +4 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +45 -98
- package/src/index.js +45 -96
- package/src/pdf/core/annotations/annotation-collection.d.ts +289 -0
- package/src/pdf/core/annotations/annotation-collection.js +755 -0
- package/src/pdf/core/annotations/annotation.d.ts +5865 -0
- package/src/pdf/core/annotations/annotation.js +14195 -0
- package/src/pdf/core/annotations/index.d.ts +4 -0
- package/src/pdf/core/annotations/index.js +4 -0
- package/src/pdf/core/annotations/pdf-appearance.d.ts +102 -0
- package/src/pdf/core/annotations/pdf-appearance.js +124 -0
- package/src/pdf/core/annotations/pdf-paddings.d.ts +8 -0
- package/src/pdf/core/annotations/pdf-paddings.js +22 -0
- package/src/pdf/core/base-stream.d.ts +86 -0
- package/src/pdf/core/base-stream.js +332 -0
- package/src/pdf/core/content-parser.d.ts +38 -0
- package/src/pdf/core/content-parser.js +359 -0
- package/src/pdf/core/decode-stream.d.ts +21 -0
- package/src/pdf/core/decode-stream.js +120 -0
- package/src/pdf/core/decrypt-stream.d.ts +11 -0
- package/src/pdf/core/decrypt-stream.js +53 -0
- package/src/pdf/core/enumerator.d.ts +1668 -0
- package/src/pdf/core/enumerator.js +1717 -0
- package/src/pdf/core/flate-stream.d.ts +13 -0
- package/src/pdf/core/flate-stream.js +329 -0
- package/src/pdf/core/fonts/index.d.ts +7 -0
- package/{dist/es6/implementation/graphics → src/pdf/core}/fonts/index.js +3 -4
- package/src/pdf/core/fonts/pdf-font-metrics.d.ts +66 -0
- package/src/pdf/core/fonts/pdf-font-metrics.js +192 -0
- package/src/pdf/core/fonts/pdf-standard-font.d.ts +1023 -0
- package/src/pdf/core/fonts/pdf-standard-font.js +1682 -0
- package/src/pdf/core/fonts/pdf-string-format.d.ts +236 -0
- package/src/pdf/core/fonts/pdf-string-format.js +213 -0
- package/src/pdf/core/fonts/string-layouter.d.ts +68 -0
- package/src/pdf/core/fonts/string-layouter.js +437 -0
- package/src/pdf/core/fonts/ttf-reader.d.ts +167 -0
- package/src/pdf/core/fonts/ttf-reader.js +1150 -0
- package/src/pdf/core/fonts/ttf-table.d.ts +132 -0
- package/src/pdf/core/fonts/ttf-table.js +74 -0
- package/src/pdf/core/fonts/unicode-true-type-font.d.ts +50 -0
- package/src/pdf/core/fonts/unicode-true-type-font.js +289 -0
- package/src/pdf/core/form/field.d.ts +3011 -0
- package/src/pdf/core/form/field.js +6828 -0
- package/src/pdf/core/form/form.d.ts +279 -0
- package/src/pdf/core/form/form.js +782 -0
- package/src/pdf/core/form/index.d.ts +2 -0
- package/src/pdf/core/form/index.js +2 -0
- package/src/pdf/core/graphics/images/image-decoder.d.ts +38 -0
- package/src/pdf/core/graphics/images/image-decoder.js +227 -0
- package/src/{implementation → pdf/core}/graphics/images/index.d.ts +0 -5
- package/{dist/es6/implementation → src/pdf/core}/graphics/images/index.js +0 -1
- package/src/pdf/core/graphics/images/pdf-bitmap.d.ts +73 -0
- package/src/pdf/core/graphics/images/pdf-bitmap.js +68 -0
- package/src/pdf/core/graphics/images/pdf-image.d.ts +201 -0
- package/src/pdf/core/graphics/images/pdf-image.js +201 -0
- package/src/pdf/core/graphics/index.d.ts +10 -0
- package/src/pdf/core/graphics/index.js +10 -0
- package/src/pdf/core/graphics/pdf-graphics.d.ts +956 -0
- package/src/pdf/core/graphics/pdf-graphics.js +1860 -0
- package/src/pdf/core/graphics/pdf-path.d.ts +34 -0
- package/src/pdf/core/graphics/pdf-path.js +177 -0
- package/src/pdf/core/graphics/pdf-stream-writer.d.ts +56 -0
- package/src/pdf/core/graphics/pdf-stream-writer.js +231 -0
- package/src/pdf/core/graphics/pdf-template.d.ts +79 -0
- package/src/pdf/core/graphics/pdf-template.js +100 -0
- package/src/pdf/core/graphics/rightToLeft/bidirectional.d.ts +69 -0
- package/src/pdf/core/graphics/rightToLeft/bidirectional.js +831 -0
- package/src/pdf/core/graphics/rightToLeft/index.d.ts +3 -0
- package/src/pdf/core/graphics/rightToLeft/index.js +3 -0
- package/src/pdf/core/graphics/rightToLeft/text-renderer.d.ts +13 -0
- package/src/pdf/core/graphics/rightToLeft/text-renderer.js +116 -0
- package/src/pdf/core/graphics/rightToLeft/text-shape.d.ts +48 -0
- package/src/pdf/core/graphics/rightToLeft/text-shape.js +289 -0
- package/src/pdf/core/import-export/fdf-document.d.ts +37 -0
- package/src/pdf/core/import-export/fdf-document.js +667 -0
- package/src/pdf/core/import-export/index.d.ts +5 -0
- package/src/pdf/core/import-export/index.js +5 -0
- package/src/pdf/core/import-export/json-document.d.ts +47 -0
- package/src/pdf/core/import-export/json-document.js +1547 -0
- package/src/pdf/core/import-export/xfdf-document.d.ts +146 -0
- package/src/pdf/core/import-export/xfdf-document.js +2920 -0
- package/src/pdf/core/import-export/xml-document.d.ts +14 -0
- package/src/pdf/core/import-export/xml-document.js +166 -0
- package/src/pdf/core/import-export/xml-writer.d.ts +69 -0
- package/src/pdf/core/import-export/xml-writer.js +494 -0
- package/src/pdf/core/pdf-catalog.d.ts +18 -0
- package/src/pdf/core/pdf-catalog.js +166 -0
- package/src/pdf/core/pdf-cross-reference.d.ts +80 -0
- package/src/pdf/core/pdf-cross-reference.js +1049 -0
- package/src/pdf/core/pdf-document.d.ts +821 -0
- package/src/pdf/core/pdf-document.js +1022 -0
- package/src/pdf/core/pdf-file-structure.d.ts +54 -0
- package/src/pdf/core/pdf-file-structure.js +65 -0
- package/src/pdf/core/pdf-outline.d.ts +362 -0
- package/src/pdf/core/pdf-outline.js +860 -0
- package/src/pdf/core/pdf-page.d.ts +589 -0
- package/src/pdf/core/pdf-page.js +1049 -0
- package/src/pdf/core/pdf-parser.d.ts +62 -0
- package/src/pdf/core/pdf-parser.js +1035 -0
- package/src/pdf/core/pdf-primitives.d.ts +87 -0
- package/src/pdf/core/pdf-primitives.js +305 -0
- package/src/pdf/core/predictor-stream.d.ts +15 -0
- package/src/pdf/core/predictor-stream.js +214 -0
- package/src/pdf/core/security/encryptor.d.ts +140 -0
- package/src/pdf/core/security/encryptor.js +1616 -0
- package/src/pdf/core/security/index.d.ts +1 -0
- package/src/pdf/core/security/index.js +1 -0
- package/src/pdf/core/utils.d.ts +686 -0
- package/src/pdf/core/utils.js +3625 -0
- package/src/pdf/index.d.ts +44 -0
- package/src/pdf/index.js +44 -0
- package/tslint.json +111 -0
- package/ReadMe.md +0 -13
- package/dist/es6/implementation/actions/action.js +0 -44
- package/dist/es6/implementation/actions/index.js +0 -2
- package/dist/es6/implementation/actions/uri-action.js +0 -38
- package/dist/es6/implementation/annotations/action-link-annotation.js +0 -29
- package/dist/es6/implementation/annotations/annotation-collection.js +0 -93
- package/dist/es6/implementation/annotations/annotation.js +0 -156
- package/dist/es6/implementation/annotations/document-link-annotation.js +0 -48
- package/dist/es6/implementation/annotations/index.js +0 -7
- package/dist/es6/implementation/annotations/link-annotation.js +0 -31
- package/dist/es6/implementation/annotations/pdf-text-web-link.js +0 -178
- package/dist/es6/implementation/annotations/uri-annotation.js +0 -64
- package/dist/es6/implementation/collections/dictionary.js +0 -71
- package/dist/es6/implementation/collections/index.js +0 -3
- package/dist/es6/implementation/collections/object-object-pair/dictionary.js +0 -84
- package/dist/es6/implementation/collections/object-object-pair/index.js +0 -1
- package/dist/es6/implementation/collections/utils.js +0 -8
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -17
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info.js +0 -68
- package/dist/es6/implementation/document/automatic-fields/automatic-field.js +0 -145
- package/dist/es6/implementation/document/automatic-fields/composite-field.js +0 -61
- package/dist/es6/implementation/document/automatic-fields/index.js +0 -7
- package/dist/es6/implementation/document/automatic-fields/multiple-value-field.js +0 -36
- package/dist/es6/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/dist/es6/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -91
- package/dist/es6/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/dist/es6/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -34
- package/dist/es6/implementation/document/automatic-fields/single-value-field.js +0 -47
- package/dist/es6/implementation/document/index.js +0 -11
- package/dist/es6/implementation/document/pdf-catalog.js +0 -38
- package/dist/es6/implementation/document/pdf-document-base.js +0 -71
- package/dist/es6/implementation/document/pdf-document-template.js +0 -204
- package/dist/es6/implementation/document/pdf-document.js +0 -175
- package/dist/es6/implementation/drawing/index.js +0 -1
- package/dist/es6/implementation/drawing/pdf-drawing.js +0 -80
- package/dist/es6/implementation/general/enum.js +0 -6
- package/dist/es6/implementation/general/index.js +0 -3
- package/dist/es6/implementation/general/pdf-cache-collection.js +0 -24
- package/dist/es6/implementation/general/pdf-collection.js +0 -26
- package/dist/es6/implementation/general/pdf-destination.js +0 -107
- package/dist/es6/implementation/graphics/brushes/index.js +0 -2
- package/dist/es6/implementation/graphics/brushes/pdf-brush.js +0 -6
- package/dist/es6/implementation/graphics/brushes/pdf-solid-brush.js +0 -53
- package/dist/es6/implementation/graphics/constants.js +0 -11
- package/dist/es6/implementation/graphics/enum.js +0 -100
- package/dist/es6/implementation/graphics/figures/base/element-layouter.js +0 -154
- package/dist/es6/implementation/graphics/figures/base/graphics-element.js +0 -18
- package/dist/es6/implementation/graphics/figures/base/index.js +0 -3
- package/dist/es6/implementation/graphics/figures/base/pdf-shape-element.js +0 -32
- package/dist/es6/implementation/graphics/figures/base/shape-layouter.js +0 -55
- package/dist/es6/implementation/graphics/figures/base/text-layouter.js +0 -123
- package/dist/es6/implementation/graphics/figures/enum.js +0 -11
- package/dist/es6/implementation/graphics/figures/index.js +0 -5
- package/dist/es6/implementation/graphics/figures/layout-element.js +0 -41
- package/dist/es6/implementation/graphics/figures/pdf-template.js +0 -110
- package/dist/es6/implementation/graphics/figures/text-element.js +0 -298
- package/dist/es6/implementation/graphics/fonts/enum.js +0 -45
- package/dist/es6/implementation/graphics/fonts/pdf-font-metrics.js +0 -122
- package/dist/es6/implementation/graphics/fonts/pdf-font.js +0 -159
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -357
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font.js +0 -124
- package/dist/es6/implementation/graphics/fonts/pdf-string-format.js +0 -239
- package/dist/es6/implementation/graphics/fonts/string-layouter.js +0 -335
- package/dist/es6/implementation/graphics/fonts/string-tokenizer.js +0 -162
- package/dist/es6/implementation/graphics/images/byte-array.js +0 -82
- package/dist/es6/implementation/graphics/images/image-decoder.js +0 -167
- package/dist/es6/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/dist/es6/implementation/graphics/images/pdf-image.js +0 -68
- package/dist/es6/implementation/graphics/index.js +0 -20
- package/dist/es6/implementation/graphics/pdf-color.js +0 -205
- package/dist/es6/implementation/graphics/pdf-graphics.js +0 -1034
- package/dist/es6/implementation/graphics/pdf-margins.js +0 -75
- package/dist/es6/implementation/graphics/pdf-pen.js +0 -180
- package/dist/es6/implementation/graphics/pdf-resources.js +0 -223
- package/dist/es6/implementation/graphics/pdf-transformation-matrix.js +0 -134
- package/dist/es6/implementation/graphics/pdf-transparency.js +0 -22
- package/dist/es6/implementation/graphics/unit-convertor.js +0 -33
- package/dist/es6/implementation/index.js +0 -85
- package/dist/es6/implementation/input-output/cross-table.js +0 -6
- package/dist/es6/implementation/input-output/enum.js +0 -5
- package/dist/es6/implementation/input-output/index.js +0 -8
- package/dist/es6/implementation/input-output/pdf-cross-table.js +0 -346
- package/dist/es6/implementation/input-output/pdf-dictionary-properties.js +0 -60
- package/dist/es6/implementation/input-output/pdf-main-object-collection.js +0 -115
- package/dist/es6/implementation/input-output/pdf-operators.js +0 -75
- package/dist/es6/implementation/input-output/pdf-stream-writer.js +0 -364
- package/dist/es6/implementation/input-output/pdf-writer.js +0 -44
- package/dist/es6/implementation/pages/enum.js +0 -51
- package/dist/es6/implementation/pages/index.js +0 -13
- package/dist/es6/implementation/pages/page-added-event-arguments.js +0 -19
- package/dist/es6/implementation/pages/pdf-document-page-collection.js +0 -120
- package/dist/es6/implementation/pages/pdf-page-base.js +0 -104
- package/dist/es6/implementation/pages/pdf-page-layer-collection.js +0 -115
- package/dist/es6/implementation/pages/pdf-page-layer.js +0 -160
- package/dist/es6/implementation/pages/pdf-page-settings.js +0 -126
- package/dist/es6/implementation/pages/pdf-page-size.js +0 -36
- package/dist/es6/implementation/pages/pdf-page-template-element.js +0 -510
- package/dist/es6/implementation/pages/pdf-page.js +0 -130
- package/dist/es6/implementation/pages/pdf-section-collection.js +0 -95
- package/dist/es6/implementation/pages/pdf-section-page-collection.js +0 -30
- package/dist/es6/implementation/pages/pdf-section-templates.js +0 -71
- package/dist/es6/implementation/pages/pdf-section.js +0 -388
- package/dist/es6/implementation/primitives/index.js +0 -8
- package/dist/es6/implementation/primitives/pdf-array.js +0 -199
- package/dist/es6/implementation/primitives/pdf-boolean.js +0 -66
- package/dist/es6/implementation/primitives/pdf-dictionary.js +0 -220
- package/dist/es6/implementation/primitives/pdf-name.js +0 -102
- package/dist/es6/implementation/primitives/pdf-number.js +0 -94
- package/dist/es6/implementation/primitives/pdf-reference.js +0 -195
- package/dist/es6/implementation/primitives/pdf-stream.js +0 -149
- package/dist/es6/implementation/primitives/pdf-string.js +0 -143
- package/dist/es6/implementation/structured-elements/grid/index.js +0 -1
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-cell.js +0 -512
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-column.js +0 -125
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-row.js +0 -244
- package/dist/es6/implementation/structured-elements/grid/pdf-grid.js +0 -989
- package/dist/es6/implementation/structured-elements/grid/styles/index.js +0 -2
- package/dist/es6/implementation/structured-elements/grid/styles/pdf-borders.js +0 -145
- package/dist/es6/implementation/structured-elements/grid/styles/style.js +0 -267
- package/dist/es6/implementation/structured-elements/index.js +0 -1
- package/dist/es6/implementation/structured-elements/tables/light-tables/enum.js +0 -5
- package/dist/es6/index.js +0 -89
- package/dist/es6/interfaces/i-pdf-cache.js +0 -1
- package/dist/es6/interfaces/i-pdf-changable.js +0 -1
- package/dist/es6/interfaces/i-pdf-primitives.js +0 -1
- package/dist/es6/interfaces/i-pdf-wrapper.js +0 -1
- package/dist/es6/interfaces/i-pdf-writer.js +0 -1
- package/dist/es6/interfaces/index.js +0 -1
- package/dist/global/ej2-pdf-export.js +0 -15979
- package/implementation.d.ts +0 -4
- package/implementation.js +0 -8
- package/interfaces.d.ts +0 -4
- package/interfaces.js +0 -4
- package/src/implementation/actions/action.d.ts +0 -50
- package/src/implementation/actions/action.js +0 -44
- package/src/implementation/actions/index.d.ts +0 -6
- package/src/implementation/actions/index.js +0 -9
- package/src/implementation/actions/uri-action.d.ts +0 -33
- package/src/implementation/actions/uri-action.js +0 -39
- package/src/implementation/annotations/action-link-annotation.d.ts +0 -30
- package/src/implementation/annotations/action-link-annotation.js +0 -32
- package/src/implementation/annotations/annotation-collection.d.ts +0 -77
- package/src/implementation/annotations/annotation-collection.js +0 -91
- package/src/implementation/annotations/annotation.d.ts +0 -152
- package/src/implementation/annotations/annotation.js +0 -146
- package/src/implementation/annotations/document-link-annotation.d.ts +0 -89
- package/src/implementation/annotations/document-link-annotation.js +0 -51
- package/src/implementation/annotations/index.d.ts +0 -11
- package/src/implementation/annotations/index.js +0 -14
- package/src/implementation/annotations/link-annotation.d.ts +0 -23
- package/src/implementation/annotations/link-annotation.js +0 -33
- package/src/implementation/annotations/pdf-text-web-link.d.ts +0 -118
- package/src/implementation/annotations/pdf-text-web-link.js +0 -173
- package/src/implementation/annotations/uri-annotation.d.ts +0 -48
- package/src/implementation/annotations/uri-annotation.js +0 -65
- package/src/implementation/collections/dictionary.d.ts +0 -76
- package/src/implementation/collections/dictionary.js +0 -74
- package/src/implementation/collections/index.d.ts +0 -7
- package/src/implementation/collections/index.js +0 -10
- package/src/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
- package/src/implementation/collections/object-object-pair/dictionary.js +0 -88
- package/src/implementation/collections/object-object-pair/index.d.ts +0 -5
- package/src/implementation/collections/object-object-pair/index.js +0 -8
- package/src/implementation/collections/utils.d.ts +0 -27
- package/src/implementation/collections/utils.js +0 -13
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -21
- package/src/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
- package/src/implementation/document/automatic-fields/automatic-field-info.js +0 -70
- package/src/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
- package/src/implementation/document/automatic-fields/automatic-field.js +0 -143
- package/src/implementation/document/automatic-fields/composite-field.d.ts +0 -46
- package/src/implementation/document/automatic-fields/composite-field.js +0 -64
- package/src/implementation/document/automatic-fields/index.d.ts +0 -11
- package/src/implementation/document/automatic-fields/index.js +0 -14
- package/src/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
- package/src/implementation/document/automatic-fields/multiple-value-field.js +0 -35
- package/src/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
- package/src/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -94
- package/src/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
- package/src/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -38
- package/src/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
- package/src/implementation/document/automatic-fields/single-value-field.js +0 -46
- package/src/implementation/document/index.d.ts +0 -15
- package/src/implementation/document/index.js +0 -18
- package/src/implementation/document/pdf-catalog.d.ts +0 -32
- package/src/implementation/document/pdf-catalog.js +0 -38
- package/src/implementation/document/pdf-document-base.d.ts +0 -117
- package/src/implementation/document/pdf-document-base.js +0 -72
- package/src/implementation/document/pdf-document-template.d.ts +0 -166
- package/src/implementation/document/pdf-document-template.js +0 -207
- package/src/implementation/document/pdf-document.d.ts +0 -206
- package/src/implementation/document/pdf-document.js +0 -166
- package/src/implementation/drawing/index.d.ts +0 -5
- package/src/implementation/drawing/index.js +0 -8
- package/src/implementation/drawing/pdf-drawing.d.ts +0 -93
- package/src/implementation/drawing/pdf-drawing.js +0 -84
- package/src/implementation/general/enum.d.ts +0 -21
- package/src/implementation/general/enum.js +0 -10
- package/src/implementation/general/index.d.ts +0 -7
- package/src/implementation/general/index.js +0 -10
- package/src/implementation/general/pdf-cache-collection.d.ts +0 -33
- package/src/implementation/general/pdf-cache-collection.js +0 -27
- package/src/implementation/general/pdf-collection.d.ts +0 -26
- package/src/implementation/general/pdf-collection.js +0 -30
- package/src/implementation/general/pdf-destination.d.ts +0 -103
- package/src/implementation/general/pdf-destination.js +0 -103
- package/src/implementation/graphics/brushes/index.d.ts +0 -6
- package/src/implementation/graphics/brushes/index.js +0 -9
- package/src/implementation/graphics/brushes/pdf-brush.d.ts +0 -55
- package/src/implementation/graphics/brushes/pdf-brush.js +0 -10
- package/src/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
- package/src/implementation/graphics/brushes/pdf-solid-brush.js +0 -54
- package/src/implementation/graphics/constants.d.ts +0 -31
- package/src/implementation/graphics/constants.js +0 -15
- package/src/implementation/graphics/enum.d.ts +0 -392
- package/src/implementation/graphics/enum.js +0 -104
- package/src/implementation/graphics/figures/base/element-layouter.d.ts +0 -160
- package/src/implementation/graphics/figures/base/element-layouter.js +0 -156
- package/src/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
- package/src/implementation/graphics/figures/base/graphics-element.js +0 -22
- package/src/implementation/graphics/figures/base/index.d.ts +0 -7
- package/src/implementation/graphics/figures/base/index.js +0 -10
- package/src/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -28
- package/src/implementation/graphics/figures/base/pdf-shape-element.js +0 -34
- package/src/implementation/graphics/figures/base/shape-layouter.d.ts +0 -80
- package/src/implementation/graphics/figures/base/shape-layouter.js +0 -57
- package/src/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
- package/src/implementation/graphics/figures/base/text-layouter.js +0 -121
- package/src/implementation/graphics/figures/enum.d.ts +0 -37
- package/src/implementation/graphics/figures/enum.js +0 -15
- package/src/implementation/graphics/figures/index.d.ts +0 -9
- package/src/implementation/graphics/figures/index.js +0 -12
- package/src/implementation/graphics/figures/layout-element.d.ts +0 -57
- package/src/implementation/graphics/figures/layout-element.js +0 -43
- package/src/implementation/graphics/figures/pdf-template.d.ts +0 -113
- package/src/implementation/graphics/figures/pdf-template.js +0 -106
- package/src/implementation/graphics/figures/text-element.d.ts +0 -213
- package/src/implementation/graphics/figures/text-element.js +0 -289
- package/src/implementation/graphics/fonts/enum.d.ts +0 -179
- package/src/implementation/graphics/fonts/enum.js +0 -49
- package/src/implementation/graphics/fonts/index.d.ts +0 -12
- package/src/implementation/graphics/fonts/index.js +0 -15
- package/src/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -160
- package/src/implementation/graphics/fonts/pdf-font-metrics.js +0 -123
- package/src/implementation/graphics/fonts/pdf-font.d.ts +0 -187
- package/src/implementation/graphics/fonts/pdf-font.js +0 -158
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -359
- package/src/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
- package/src/implementation/graphics/fonts/pdf-standard-font.js +0 -121
- package/src/implementation/graphics/fonts/pdf-string-format.d.ts +0 -319
- package/src/implementation/graphics/fonts/pdf-string-format.js +0 -241
- package/src/implementation/graphics/fonts/string-layouter.d.ts +0 -255
- package/src/implementation/graphics/fonts/string-layouter.js +0 -336
- package/src/implementation/graphics/fonts/string-tokenizer.d.ts +0 -107
- package/src/implementation/graphics/fonts/string-tokenizer.js +0 -166
- package/src/implementation/graphics/images/byte-array.d.ts +0 -68
- package/src/implementation/graphics/images/byte-array.js +0 -86
- package/src/implementation/graphics/images/image-decoder.d.ts +0 -227
- package/src/implementation/graphics/images/image-decoder.js +0 -164
- package/src/implementation/graphics/images/index.js +0 -11
- package/src/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
- package/src/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/src/implementation/graphics/images/pdf-image.d.ts +0 -88
- package/src/implementation/graphics/images/pdf-image.js +0 -69
- package/src/implementation/graphics/index.d.ts +0 -24
- package/src/implementation/graphics/index.js +0 -27
- package/src/implementation/graphics/pdf-color.d.ts +0 -170
- package/src/implementation/graphics/pdf-color.js +0 -204
- package/src/implementation/graphics/pdf-graphics.d.ts +0 -1085
- package/src/implementation/graphics/pdf-graphics.js +0 -1017
- package/src/implementation/graphics/pdf-margins.d.ts +0 -82
- package/src/implementation/graphics/pdf-margins.js +0 -79
- package/src/implementation/graphics/pdf-pen.d.ts +0 -237
- package/src/implementation/graphics/pdf-pen.js +0 -181
- package/src/implementation/graphics/pdf-resources.d.ts +0 -147
- package/src/implementation/graphics/pdf-resources.js +0 -215
- package/src/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
- package/src/implementation/graphics/pdf-transformation-matrix.js +0 -136
- package/src/implementation/graphics/pdf-transparency.d.ts +0 -34
- package/src/implementation/graphics/pdf-transparency.js +0 -22
- package/src/implementation/graphics/unit-convertor.d.ts +0 -72
- package/src/implementation/graphics/unit-convertor.js +0 -37
- package/src/implementation/index.d.ts +0 -89
- package/src/implementation/index.js +0 -92
- package/src/implementation/input-output/cross-table.d.ts +0 -21
- package/src/implementation/input-output/cross-table.js +0 -10
- package/src/implementation/input-output/enum.d.ts +0 -16
- package/src/implementation/input-output/enum.js +0 -9
- package/src/implementation/input-output/index.d.ts +0 -12
- package/src/implementation/input-output/index.js +0 -15
- package/src/implementation/input-output/pdf-cross-table.d.ts +0 -249
- package/src/implementation/input-output/pdf-cross-table.js +0 -340
- package/src/implementation/input-output/pdf-dictionary-properties.d.ts +0 -283
- package/src/implementation/input-output/pdf-dictionary-properties.js +0 -64
- package/src/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
- package/src/implementation/input-output/pdf-main-object-collection.js +0 -117
- package/src/implementation/input-output/pdf-operators.d.ts +0 -352
- package/src/implementation/input-output/pdf-operators.js +0 -79
- package/src/implementation/input-output/pdf-stream-writer.d.ts +0 -314
- package/src/implementation/input-output/pdf-stream-writer.js +0 -363
- package/src/implementation/input-output/pdf-writer.d.ts +0 -68
- package/src/implementation/input-output/pdf-writer.js +0 -48
- package/src/implementation/pages/enum.d.ts +0 -201
- package/src/implementation/pages/enum.js +0 -55
- package/src/implementation/pages/index.d.ts +0 -17
- package/src/implementation/pages/index.js +0 -20
- package/src/implementation/pages/page-added-event-arguments.d.ts +0 -30
- package/src/implementation/pages/page-added-event-arguments.js +0 -23
- package/src/implementation/pages/pdf-document-page-collection.d.ts +0 -92
- package/src/implementation/pages/pdf-document-page-collection.js +0 -121
- package/src/implementation/pages/pdf-page-base.d.ts +0 -121
- package/src/implementation/pages/pdf-page-base.js +0 -104
- package/src/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
- package/src/implementation/pages/pdf-page-layer-collection.js +0 -113
- package/src/implementation/pages/pdf-page-layer.d.ts +0 -160
- package/src/implementation/pages/pdf-page-layer.js +0 -159
- package/src/implementation/pages/pdf-page-settings.d.ts +0 -111
- package/src/implementation/pages/pdf-page-settings.js +0 -126
- package/src/implementation/pages/pdf-page-size.d.ts +0 -159
- package/src/implementation/pages/pdf-page-size.js +0 -39
- package/src/implementation/pages/pdf-page-template-element.d.ts +0 -230
- package/src/implementation/pages/pdf-page-template-element.js +0 -509
- package/src/implementation/pages/pdf-page.d.ts +0 -153
- package/src/implementation/pages/pdf-page.js +0 -127
- package/src/implementation/pages/pdf-section-collection.d.ts +0 -109
- package/src/implementation/pages/pdf-section-collection.js +0 -91
- package/src/implementation/pages/pdf-section-page-collection.d.ts +0 -41
- package/src/implementation/pages/pdf-section-page-collection.js +0 -34
- package/src/implementation/pages/pdf-section-templates.d.ts +0 -64
- package/src/implementation/pages/pdf-section-templates.js +0 -74
- package/src/implementation/pages/pdf-section.d.ts +0 -319
- package/src/implementation/pages/pdf-section.js +0 -379
- package/src/implementation/primitives/index.d.ts +0 -12
- package/src/implementation/primitives/index.js +0 -15
- package/src/implementation/primitives/pdf-array.d.ts +0 -186
- package/src/implementation/primitives/pdf-array.js +0 -201
- package/src/implementation/primitives/pdf-boolean.d.ts +0 -84
- package/src/implementation/primitives/pdf-boolean.js +0 -70
- package/src/implementation/primitives/pdf-dictionary.d.ts +0 -311
- package/src/implementation/primitives/pdf-dictionary.js +0 -220
- package/src/implementation/primitives/pdf-name.d.ts +0 -121
- package/src/implementation/primitives/pdf-name.js +0 -106
- package/src/implementation/primitives/pdf-number.d.ts +0 -104
- package/src/implementation/primitives/pdf-number.js +0 -98
- package/src/implementation/primitives/pdf-reference.d.ts +0 -222
- package/src/implementation/primitives/pdf-reference.js +0 -192
- package/src/implementation/primitives/pdf-stream.d.ts +0 -111
- package/src/implementation/primitives/pdf-stream.js +0 -146
- package/src/implementation/primitives/pdf-string.d.ts +0 -212
- package/src/implementation/primitives/pdf-string.js +0 -147
- package/src/implementation/structured-elements/grid/index.d.ts +0 -0
- package/src/implementation/structured-elements/grid/index.js +0 -1
- package/src/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -248
- package/src/implementation/structured-elements/grid/pdf-grid-cell.js +0 -504
- package/src/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
- package/src/implementation/structured-elements/grid/pdf-grid-column.js +0 -127
- package/src/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -207
- package/src/implementation/structured-elements/grid/pdf-grid-row.js +0 -246
- package/src/implementation/structured-elements/grid/pdf-grid.d.ts +0 -678
- package/src/implementation/structured-elements/grid/pdf-grid.js +0 -982
- package/src/implementation/structured-elements/grid/styles/index.d.ts +0 -5
- package/src/implementation/structured-elements/grid/styles/index.js +0 -9
- package/src/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -126
- package/src/implementation/structured-elements/grid/styles/pdf-borders.js +0 -146
- package/src/implementation/structured-elements/grid/styles/style.d.ts +0 -250
- package/src/implementation/structured-elements/grid/styles/style.js +0 -269
- package/src/implementation/structured-elements/index.d.ts +0 -0
- package/src/implementation/structured-elements/index.js +0 -1
- package/src/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
- package/src/implementation/structured-elements/tables/light-tables/enum.js +0 -9
- package/src/interfaces/i-pdf-cache.d.ts +0 -23
- package/src/interfaces/i-pdf-cache.js +0 -4
- package/src/interfaces/i-pdf-changable.d.ts +0 -17
- package/src/interfaces/i-pdf-changable.js +0 -4
- package/src/interfaces/i-pdf-primitives.d.ts +0 -45
- package/src/interfaces/i-pdf-primitives.js +0 -4
- package/src/interfaces/i-pdf-wrapper.d.ts +0 -13
- package/src/interfaces/i-pdf-wrapper.js +0 -4
- package/src/interfaces/i-pdf-writer.d.ts +0 -29
- package/src/interfaces/i-pdf-writer.js +0 -4
- package/src/interfaces/index.d.ts +0 -9
- package/src/interfaces/index.js +0 -4
|
@@ -0,0 +1,3625 @@
|
|
|
1
|
+
var __extends = (this && this.__extends) || (function () {
|
|
2
|
+
var extendStatics = function (d, b) {
|
|
3
|
+
extendStatics = Object.setPrototypeOf ||
|
|
4
|
+
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
5
|
+
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
|
6
|
+
return extendStatics(d, b);
|
|
7
|
+
};
|
|
8
|
+
return function (d, b) {
|
|
9
|
+
extendStatics(d, b);
|
|
10
|
+
function __() { this.constructor = d; }
|
|
11
|
+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
12
|
+
};
|
|
13
|
+
})();
|
|
14
|
+
import { _PdfDictionary, _PdfName, _PdfReference } from './pdf-primitives';
|
|
15
|
+
import { PdfFormFieldVisibility, PdfAnnotationFlag, PdfCheckBoxStyle, PdfHighlightMode, PdfBorderStyle, PdfBorderEffectStyle, PdfLineEndingStyle, _PdfCheckFieldState, PdfMeasurementUnit, _PdfGraphicsUnit, PdfTextMarkupAnnotationType, PdfRotationAngle, PdfAnnotationState, PdfAnnotationStateModel, PdfPopupIcon, PdfRubberStampAnnotationIcon, PdfAttachmentIcon, PdfAnnotationIntent, PdfBlendMode, _PdfAnnotationType } from './enumerator';
|
|
16
|
+
import { _PdfTransformationMatrix } from './graphics/pdf-graphics';
|
|
17
|
+
import { _PdfBaseStream, _PdfStream } from './base-stream';
|
|
18
|
+
import { PdfAnnotation } from './annotations/annotation';
|
|
19
|
+
import { PdfTemplate } from './graphics/pdf-template';
|
|
20
|
+
import { PdfField } from './form/field';
|
|
21
|
+
import { PdfCjkFontFamily, PdfCjkStandardFont, PdfFontFamily, PdfFontStyle, PdfStandardFont, PdfTrueTypeFont } from './fonts/pdf-standard-font';
|
|
22
|
+
/**
|
|
23
|
+
* Gets the page rotation.
|
|
24
|
+
*
|
|
25
|
+
* @param {PdfPage} page Page.
|
|
26
|
+
* @param {number} height Height.
|
|
27
|
+
* @param {number} left Left.
|
|
28
|
+
* @returns {number} Page rotation.
|
|
29
|
+
*/
|
|
30
|
+
export function _checkRotation(page, height, left) {
|
|
31
|
+
var topValue = 0;
|
|
32
|
+
left = (typeof left === 'undefined' || left === null) ? 0 : left;
|
|
33
|
+
if (page.rotation === PdfRotationAngle.angle90) {
|
|
34
|
+
topValue = (typeof height === 'undefined' || height === null) ? 0 : left;
|
|
35
|
+
}
|
|
36
|
+
else if (page.rotation === PdfRotationAngle.angle180) {
|
|
37
|
+
topValue = (typeof height === 'undefined' || height === null) ? 0 : height;
|
|
38
|
+
}
|
|
39
|
+
else if (page.rotation === PdfRotationAngle.angle270) {
|
|
40
|
+
var size = page.size;
|
|
41
|
+
topValue = (typeof height === 'undefined' || height === null) ? 0 : size[0] - left;
|
|
42
|
+
}
|
|
43
|
+
return topValue;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the page index.
|
|
47
|
+
*
|
|
48
|
+
* @param {PdfDocument} loadedDocument Loaded document.
|
|
49
|
+
* @param {_PdfDictionary} pageDictionary Page dictionary.
|
|
50
|
+
* @returns {number} Page index.
|
|
51
|
+
*/
|
|
52
|
+
export function _getPageIndex(loadedDocument, pageDictionary) {
|
|
53
|
+
var index = -1;
|
|
54
|
+
for (var i = 0; i < loadedDocument.pageCount; i++) {
|
|
55
|
+
var page = loadedDocument.getPage(i);
|
|
56
|
+
if (page._pageDictionary === pageDictionary) {
|
|
57
|
+
index = i;
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
return index;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Convert string value from annotation flag
|
|
65
|
+
*
|
|
66
|
+
* @private
|
|
67
|
+
* @param {PdfAnnotationFlag} flag Annotation flag.
|
|
68
|
+
* @returns {string} Valid string to write into XML.
|
|
69
|
+
*/
|
|
70
|
+
export function _annotationFlagsToString(flag) {
|
|
71
|
+
var values = [];
|
|
72
|
+
if ((flag & PdfAnnotationFlag.hidden) !== 0) {
|
|
73
|
+
values.push('hidden');
|
|
74
|
+
}
|
|
75
|
+
if ((flag & PdfAnnotationFlag.invisible) !== 0) {
|
|
76
|
+
values.push('invisible');
|
|
77
|
+
}
|
|
78
|
+
if ((flag & PdfAnnotationFlag.locked) !== 0) {
|
|
79
|
+
values.push('locked');
|
|
80
|
+
}
|
|
81
|
+
if ((flag & PdfAnnotationFlag.noRotate) !== 0) {
|
|
82
|
+
values.push('norotate');
|
|
83
|
+
}
|
|
84
|
+
if ((flag & PdfAnnotationFlag.noView) !== 0) {
|
|
85
|
+
values.push('noview');
|
|
86
|
+
}
|
|
87
|
+
if ((flag & PdfAnnotationFlag.noZoom) !== 0) {
|
|
88
|
+
values.push('nozoom');
|
|
89
|
+
}
|
|
90
|
+
if ((flag & PdfAnnotationFlag.print) !== 0) {
|
|
91
|
+
values.push('print');
|
|
92
|
+
}
|
|
93
|
+
if ((flag & PdfAnnotationFlag.readOnly) !== 0) {
|
|
94
|
+
values.push('readonly');
|
|
95
|
+
}
|
|
96
|
+
if ((flag & PdfAnnotationFlag.toggleNoView) !== 0) {
|
|
97
|
+
values.push('togglenoview');
|
|
98
|
+
}
|
|
99
|
+
if ((flag & PdfAnnotationFlag.default) !== 0) {
|
|
100
|
+
values.push('default');
|
|
101
|
+
}
|
|
102
|
+
return values.join(',');
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Convert string value to annotation flag
|
|
106
|
+
*
|
|
107
|
+
* @private
|
|
108
|
+
* @param {string} flag String value to map
|
|
109
|
+
* @returns {PdfAnnotationFlag} Annotation flag
|
|
110
|
+
*/
|
|
111
|
+
export function _stringToAnnotationFlags(flag) {
|
|
112
|
+
switch (flag) {
|
|
113
|
+
case 'hidden':
|
|
114
|
+
return PdfAnnotationFlag.hidden;
|
|
115
|
+
case 'invisible':
|
|
116
|
+
return PdfAnnotationFlag.invisible;
|
|
117
|
+
case 'locked':
|
|
118
|
+
return PdfAnnotationFlag.locked;
|
|
119
|
+
case 'norotate':
|
|
120
|
+
return PdfAnnotationFlag.noRotate;
|
|
121
|
+
case 'noview':
|
|
122
|
+
return PdfAnnotationFlag.noView;
|
|
123
|
+
case 'nozoom':
|
|
124
|
+
return PdfAnnotationFlag.noZoom;
|
|
125
|
+
case 'print':
|
|
126
|
+
return PdfAnnotationFlag.print;
|
|
127
|
+
case 'readonly':
|
|
128
|
+
return PdfAnnotationFlag.readOnly;
|
|
129
|
+
case 'togglenoview':
|
|
130
|
+
return PdfAnnotationFlag.toggleNoView;
|
|
131
|
+
default:
|
|
132
|
+
return PdfAnnotationFlag.default;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Convert string value to byte array
|
|
137
|
+
*
|
|
138
|
+
* @private
|
|
139
|
+
* @param {string} value string value.
|
|
140
|
+
* @returns {string} Valid string to write into PDF.
|
|
141
|
+
*/
|
|
142
|
+
export function _stringToPdfString(value) {
|
|
143
|
+
if (value.charCodeAt(0) >= '\xEF'.charCodeAt(0)) {
|
|
144
|
+
var encoding = void 0;
|
|
145
|
+
if (value[0] === '\xEF' && value[1] === '\xBB' && value[2] === '\xBF') {
|
|
146
|
+
encoding = 'utf-8';
|
|
147
|
+
}
|
|
148
|
+
else if (value[0] === '\xFF' && value[1] === '\xFE') {
|
|
149
|
+
encoding = 'utf-16le';
|
|
150
|
+
}
|
|
151
|
+
else if (value[0] === '\xFE' && value[1] === '\xFF') {
|
|
152
|
+
encoding = 'utf-16be';
|
|
153
|
+
}
|
|
154
|
+
if (encoding) {
|
|
155
|
+
try {
|
|
156
|
+
return (new TextDecoder(encoding, { fatal: true })).decode(_stringToBytes(value));
|
|
157
|
+
}
|
|
158
|
+
catch (e) { } // eslint-disable-line
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
var buffer = [];
|
|
162
|
+
var translateTable = [
|
|
163
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0x2d8,
|
|
164
|
+
0x2c7, 0x2c6, 0x2d9, 0x2dd, 0x2db, 0x2da, 0x2dc, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
165
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
166
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
167
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
168
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0x2022, 0x2020, 0x2021, 0x2026, 0x2014, 0x2013, 0x192,
|
|
169
|
+
0x2044, 0x2039, 0x203a, 0x2212, 0x2030, 0x201e, 0x201c, 0x201d, 0x2018,
|
|
170
|
+
0x2019, 0x201a, 0x2122, 0xfb01, 0xfb02, 0x141, 0x152, 0x160, 0x178, 0x17d,
|
|
171
|
+
0x131, 0x142, 0x153, 0x161, 0x17e, 0, 0x20ac
|
|
172
|
+
];
|
|
173
|
+
for (var i = 0; i < value.length; i++) {
|
|
174
|
+
var code = translateTable[value.charCodeAt(i)];
|
|
175
|
+
buffer.push(code ? String.fromCharCode(code) : value.charAt(i));
|
|
176
|
+
}
|
|
177
|
+
return buffer.join('');
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Convert string value to byte array
|
|
181
|
+
*
|
|
182
|
+
* @private
|
|
183
|
+
* @param {string} value string value.
|
|
184
|
+
* @param {boolean} isDirect Whether to return object or number[]. Default is false.
|
|
185
|
+
* @returns {Uint8Array | number[]} Byte array
|
|
186
|
+
*/
|
|
187
|
+
export function _stringToBytes(value, isDirect) {
|
|
188
|
+
if (isDirect === void 0) { isDirect = false; }
|
|
189
|
+
var bytes = [];
|
|
190
|
+
for (var i = 0; i < value.length; ++i) {
|
|
191
|
+
bytes.push(value.charCodeAt(i) & 0xff);
|
|
192
|
+
}
|
|
193
|
+
return isDirect ? bytes : new Uint8Array(bytes);
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Convert string value to byte array
|
|
197
|
+
*
|
|
198
|
+
* @private
|
|
199
|
+
* @param {string} value string value.
|
|
200
|
+
* @param {number[]} destination byte array.
|
|
201
|
+
* @returns {number[]} Byte array
|
|
202
|
+
*/
|
|
203
|
+
export function _convertStringToBytes(value, destination) {
|
|
204
|
+
for (var i = 0; i < value.length; ++i) {
|
|
205
|
+
destination.push(value.charCodeAt(i) & 0xff);
|
|
206
|
+
}
|
|
207
|
+
return destination;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Check equal or not.
|
|
211
|
+
*
|
|
212
|
+
* @private
|
|
213
|
+
* @param {number[]} first byte array.
|
|
214
|
+
* @param {number[]} second byte array.
|
|
215
|
+
* @returns {boolean} Equal or not
|
|
216
|
+
*/
|
|
217
|
+
export function _areArrayEqual(first, second) {
|
|
218
|
+
if (first.length !== second.length) {
|
|
219
|
+
return false;
|
|
220
|
+
}
|
|
221
|
+
for (var i = 0; i < first.length; i++) {
|
|
222
|
+
if (first[Number.parseInt(i.toString(), 10)] !== second[Number.parseInt(i.toString(), 10)]) {
|
|
223
|
+
return false;
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Convert number to string as round value with fixed decimal points 2.
|
|
230
|
+
*
|
|
231
|
+
* @private
|
|
232
|
+
* @param {number[]} value number value.
|
|
233
|
+
* @returns {boolean} Equal string.
|
|
234
|
+
*/
|
|
235
|
+
export function _numberToString(value) {
|
|
236
|
+
if (Number.isInteger(value)) {
|
|
237
|
+
return value.toString();
|
|
238
|
+
}
|
|
239
|
+
return value.toFixed(7);
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Check whether entries in two array are equal or not.
|
|
243
|
+
*
|
|
244
|
+
* @private
|
|
245
|
+
* @param {number[]} value first array.
|
|
246
|
+
* @param {number[]} current second array.
|
|
247
|
+
* @returns {boolean} Return true if for each elements are equal in both array.
|
|
248
|
+
*/
|
|
249
|
+
export function _areNotEqual(value, current) {
|
|
250
|
+
var result = false;
|
|
251
|
+
if (value.length !== current.length) {
|
|
252
|
+
return true;
|
|
253
|
+
}
|
|
254
|
+
for (var i = 0; i < value.length; i++) {
|
|
255
|
+
if (value[i] !== current[i]) { // eslint-disable-line
|
|
256
|
+
result = true;
|
|
257
|
+
break;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
return result;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Process bytes and convert as string.
|
|
264
|
+
*
|
|
265
|
+
* @private
|
|
266
|
+
* @param {Uint8Array} bytes Input data.
|
|
267
|
+
* @returns {string} String value processed from input bytes.
|
|
268
|
+
*/
|
|
269
|
+
export function _bytesToString(bytes) {
|
|
270
|
+
var length = bytes.length;
|
|
271
|
+
var max = 8192;
|
|
272
|
+
if (length < max) {
|
|
273
|
+
return String.fromCharCode.apply(null, bytes);
|
|
274
|
+
}
|
|
275
|
+
var stringBuffer = [];
|
|
276
|
+
for (var i = 0; i < length; i += max) {
|
|
277
|
+
var chunkEnd = Math.min(i + max, length);
|
|
278
|
+
var chunk = bytes.subarray(i, chunkEnd);
|
|
279
|
+
stringBuffer.push(String.fromCharCode.apply(null, chunk));
|
|
280
|
+
}
|
|
281
|
+
return stringBuffer.join('');
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Convert string to unicode array.
|
|
285
|
+
*
|
|
286
|
+
* @private
|
|
287
|
+
* @param {string} value string value.
|
|
288
|
+
* @returns {Uint8Array} unicode array
|
|
289
|
+
*/
|
|
290
|
+
export function _stringToUnicodeArray(value) {
|
|
291
|
+
var output = [];
|
|
292
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
293
|
+
for (var i = 0; i < value.length; i++) {
|
|
294
|
+
var code = value.charCodeAt(i);
|
|
295
|
+
output.push(code / 256 >>> 0);
|
|
296
|
+
output.push(code & 0xff);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
var unicodeArray = new Uint8Array(output);
|
|
300
|
+
return unicodeArray;
|
|
301
|
+
}
|
|
302
|
+
/**
|
|
303
|
+
* Convert byte array to hex string.
|
|
304
|
+
*
|
|
305
|
+
* @private
|
|
306
|
+
* @param {Uint8Array} byteArray Byte array.
|
|
307
|
+
* @returns {string} Hex string.
|
|
308
|
+
*/
|
|
309
|
+
export function _byteArrayToHexString(byteArray) {
|
|
310
|
+
var nextHexByte;
|
|
311
|
+
var stringBuffer = [];
|
|
312
|
+
for (var i = 0; i < byteArray.length; i++) {
|
|
313
|
+
nextHexByte = byteArray[Number.parseInt(i.toString(), 10)].toString(16).toUpperCase();
|
|
314
|
+
if (nextHexByte.length < 2) {
|
|
315
|
+
nextHexByte = '0' + nextHexByte;
|
|
316
|
+
}
|
|
317
|
+
stringBuffer.push(nextHexByte);
|
|
318
|
+
}
|
|
319
|
+
return stringBuffer.join('');
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Convert hex string to byte array.
|
|
323
|
+
*
|
|
324
|
+
* @private
|
|
325
|
+
* @param {string} hexString Hex string.
|
|
326
|
+
* @param {boolean} isDirect Whether to return object or number[]. Default is false.
|
|
327
|
+
* @returns {Uint8Array | number[]} Byte array.
|
|
328
|
+
*/
|
|
329
|
+
export function _hexStringToByteArray(hexString, isDirect) {
|
|
330
|
+
if (isDirect === void 0) { isDirect = false; }
|
|
331
|
+
var array = [];
|
|
332
|
+
if (hexString) {
|
|
333
|
+
for (var i = 0; i < hexString.length; i += 2) {
|
|
334
|
+
array.push(Number.parseInt(hexString.substring(i, i + 2), 16));
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
return isDirect ? array : new Uint8Array(array);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Convert hex string to normal string.
|
|
341
|
+
*
|
|
342
|
+
* @private
|
|
343
|
+
* @param {string} hexString Hex string.
|
|
344
|
+
* @returns {string} Normal string.
|
|
345
|
+
*/
|
|
346
|
+
export function _hexStringToString(hexString) {
|
|
347
|
+
var result = '';
|
|
348
|
+
if (hexString && hexString[0] === '#') {
|
|
349
|
+
hexString = hexString.substring(1);
|
|
350
|
+
for (var i = 0; i < hexString.length; i += 2) {
|
|
351
|
+
result += String.fromCharCode(Number.parseInt(hexString.substring(i, i + 2), 16));
|
|
352
|
+
}
|
|
353
|
+
return result;
|
|
354
|
+
}
|
|
355
|
+
return hexString;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Check whether the character code is white space.
|
|
359
|
+
*
|
|
360
|
+
* @private
|
|
361
|
+
* @param {number} ch The character code to check.
|
|
362
|
+
* @returns {boolean} True if the character is space, otherwise false.
|
|
363
|
+
*/
|
|
364
|
+
export function _isWhiteSpace(ch) {
|
|
365
|
+
return ch === 0x20 || ch === 0x09 || ch === 0x0d || ch === 0x0a;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Decode bytes from base64 string.
|
|
369
|
+
*
|
|
370
|
+
* @private
|
|
371
|
+
* @param {string} input The base64 string to decode.
|
|
372
|
+
* @param {boolean} isDirect Whether to return object or number[]. Default is false.
|
|
373
|
+
* @returns {Uint8Array | number[]} Decoded bytes.
|
|
374
|
+
*/
|
|
375
|
+
export function _decode(input, isDirect) {
|
|
376
|
+
if (isDirect === void 0) { isDirect = false; }
|
|
377
|
+
var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
378
|
+
var chr1;
|
|
379
|
+
var chr2;
|
|
380
|
+
var chr3;
|
|
381
|
+
var enc1;
|
|
382
|
+
var enc2;
|
|
383
|
+
var enc3;
|
|
384
|
+
var enc4;
|
|
385
|
+
var i = 0;
|
|
386
|
+
var resultIndex = 0;
|
|
387
|
+
input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ''); // eslint-disable-line
|
|
388
|
+
var totalLength = input.length * 3 / 4;
|
|
389
|
+
if (input.charAt(input.length - 1) === key.charAt(64)) {
|
|
390
|
+
totalLength--;
|
|
391
|
+
}
|
|
392
|
+
var output = new Array(totalLength | 0);
|
|
393
|
+
while (i < input.length) {
|
|
394
|
+
enc1 = key.indexOf(input.charAt(i++));
|
|
395
|
+
enc2 = key.indexOf(input.charAt(i++));
|
|
396
|
+
enc3 = key.indexOf(input.charAt(i++));
|
|
397
|
+
enc4 = key.indexOf(input.charAt(i++));
|
|
398
|
+
chr1 = (enc1 << 2) | (enc2 >> 4);
|
|
399
|
+
chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
|
|
400
|
+
chr3 = ((enc3 & 3) << 6) | enc4;
|
|
401
|
+
if (resultIndex < totalLength) {
|
|
402
|
+
output[resultIndex++] = chr1;
|
|
403
|
+
}
|
|
404
|
+
if (resultIndex < totalLength) {
|
|
405
|
+
output[resultIndex++] = chr2;
|
|
406
|
+
}
|
|
407
|
+
if (resultIndex < totalLength) {
|
|
408
|
+
output[resultIndex++] = chr3;
|
|
409
|
+
}
|
|
410
|
+
}
|
|
411
|
+
return isDirect ? output : new Uint8Array(output);
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* Encode bytes to base64 string.
|
|
415
|
+
*
|
|
416
|
+
* @private
|
|
417
|
+
* @param {Uint8Array} bytes Bytes to encode.
|
|
418
|
+
* @returns {string} Decoded string.
|
|
419
|
+
*/
|
|
420
|
+
export function _encode(bytes) {
|
|
421
|
+
var key = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
|
422
|
+
var output = '';
|
|
423
|
+
var currentChar = 0;
|
|
424
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
425
|
+
if (i % 3 === 0) {
|
|
426
|
+
currentChar = (bytes[Number.parseInt(i.toString(), 10)] >> 2);
|
|
427
|
+
output += key[Number.parseInt(currentChar.toString(), 10)];
|
|
428
|
+
currentChar = (bytes[Number.parseInt(i.toString(), 10)] << 4) & 63;
|
|
429
|
+
}
|
|
430
|
+
else if (i % 3 === 1) {
|
|
431
|
+
currentChar += (bytes[Number.parseInt(i.toString(), 10)] >> 4);
|
|
432
|
+
output += key[Number.parseInt(currentChar.toString(), 10)];
|
|
433
|
+
currentChar = (bytes[Number.parseInt(i.toString(), 10)] << 2) & 63;
|
|
434
|
+
}
|
|
435
|
+
else if (i % 3 === 2) {
|
|
436
|
+
currentChar += (bytes[Number.parseInt(i.toString(), 10)] >> 6);
|
|
437
|
+
output += key[Number.parseInt(currentChar.toString(), 10)];
|
|
438
|
+
currentChar = bytes[Number.parseInt(i.toString(), 10)] & 63;
|
|
439
|
+
output += key[Number.parseInt(currentChar.toString(), 10)];
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
if (bytes.length % 3 === 1) {
|
|
443
|
+
output += key[Number.parseInt(currentChar.toString(), 10)] + "==";
|
|
444
|
+
}
|
|
445
|
+
if (bytes.length % 3 === 2) {
|
|
446
|
+
output += key[Number.parseInt(currentChar.toString(), 10)] + "=";
|
|
447
|
+
}
|
|
448
|
+
return output;
|
|
449
|
+
}
|
|
450
|
+
/**
|
|
451
|
+
* Get property value in inheritable mode.
|
|
452
|
+
*
|
|
453
|
+
* @private
|
|
454
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
455
|
+
* @param {string} key Input dictionary.
|
|
456
|
+
* @param {boolean} isArray Search array.
|
|
457
|
+
* @param {boolean} stopWhenFound Stop when found.
|
|
458
|
+
* @param {string[]} parentKey Key string for parent node.
|
|
459
|
+
* @returns {any} Property value.
|
|
460
|
+
*/
|
|
461
|
+
export function _getInheritableProperty(dictionary, key, isArray, stopWhenFound) {
|
|
462
|
+
if (isArray === void 0) { isArray = false; }
|
|
463
|
+
if (stopWhenFound === void 0) { stopWhenFound = true; }
|
|
464
|
+
var parentKey = [];
|
|
465
|
+
for (var _i = 4; _i < arguments.length; _i++) {
|
|
466
|
+
parentKey[_i - 4] = arguments[_i];
|
|
467
|
+
}
|
|
468
|
+
var values; // eslint-disable-line
|
|
469
|
+
var refSet = new Set(); // eslint-disable-line
|
|
470
|
+
while (dictionary instanceof _PdfDictionary && dictionary.objId && !refSet.has(dictionary.objId)) {
|
|
471
|
+
if (dictionary.objId) {
|
|
472
|
+
refSet.add(dictionary.objId);
|
|
473
|
+
}
|
|
474
|
+
var value = isArray ? dictionary.getArray(key) : dictionary.get(key); // eslint-disable-line
|
|
475
|
+
if (value !== undefined) {
|
|
476
|
+
if (stopWhenFound) {
|
|
477
|
+
return value;
|
|
478
|
+
}
|
|
479
|
+
if (!values) {
|
|
480
|
+
values = [];
|
|
481
|
+
}
|
|
482
|
+
values.push(value);
|
|
483
|
+
}
|
|
484
|
+
var index = 0;
|
|
485
|
+
var hasParent = false;
|
|
486
|
+
while (index < parentKey.length) {
|
|
487
|
+
var element = parentKey[index]; // eslint-disable-line
|
|
488
|
+
if (dictionary.has(element)) {
|
|
489
|
+
dictionary = dictionary.get(element);
|
|
490
|
+
hasParent = true;
|
|
491
|
+
break;
|
|
492
|
+
}
|
|
493
|
+
index++;
|
|
494
|
+
}
|
|
495
|
+
if (!hasParent) {
|
|
496
|
+
break;
|
|
497
|
+
}
|
|
498
|
+
}
|
|
499
|
+
return values;
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
* Calculate bounds of annotation or field.
|
|
503
|
+
*
|
|
504
|
+
* @private
|
|
505
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
506
|
+
* @param {boolean} isWidget Input page.
|
|
507
|
+
* @returns {any} Bounds value.
|
|
508
|
+
*/
|
|
509
|
+
export function _parseRectangle(dictionary, isWidget) {
|
|
510
|
+
var rectangle = { x: 0, y: 0, width: 0, height: 0 };
|
|
511
|
+
var elements = dictionary.getArray('Rect');
|
|
512
|
+
if (elements && Array.isArray(elements)) {
|
|
513
|
+
var x1 = elements[0];
|
|
514
|
+
var y1 = elements[1];
|
|
515
|
+
var x2 = elements[2];
|
|
516
|
+
var y2 = elements[3];
|
|
517
|
+
if (typeof x1 !== 'undefined' && typeof y1 !== 'undefined' && typeof x2 !== 'undefined' && typeof y2 !== 'undefined') {
|
|
518
|
+
rectangle.x = Math.min(x1, x2);
|
|
519
|
+
rectangle.y = Math.min(y1, y2);
|
|
520
|
+
rectangle.width = Math.max(x1, x2) - rectangle.x;
|
|
521
|
+
rectangle.height = Math.max(y1, y2) - rectangle.y;
|
|
522
|
+
if (isWidget) {
|
|
523
|
+
rectangle.height = parseFloat(rectangle.height.toFixed(3));
|
|
524
|
+
if (elements[1] < 0) {
|
|
525
|
+
rectangle.y = elements[1];
|
|
526
|
+
if (elements[1] > elements[3]) {
|
|
527
|
+
rectangle.y -= rectangle.height;
|
|
528
|
+
}
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return rectangle;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Calculate bounds of annotation or field.
|
|
537
|
+
*
|
|
538
|
+
* @private
|
|
539
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
540
|
+
* @param {string} page Input page.
|
|
541
|
+
* @returns {any} Bounds value.
|
|
542
|
+
*/
|
|
543
|
+
export function _calculateBounds(dictionary, page) {
|
|
544
|
+
var rect;
|
|
545
|
+
if (dictionary.has('Rect')) {
|
|
546
|
+
rect = _parseRectangle(dictionary);
|
|
547
|
+
if (page) {
|
|
548
|
+
var size = page.size;
|
|
549
|
+
var mBox = page.mediaBox;
|
|
550
|
+
var cropBox = page.cropBox;
|
|
551
|
+
if (cropBox && Array.isArray(cropBox) && cropBox.length === 4 && page._pageDictionary.has('CropBox')) {
|
|
552
|
+
if ((cropBox[0] !== 0 || cropBox[1] !== 0 || size[0] === cropBox[2] ||
|
|
553
|
+
size[1] === cropBox[3]) && (rect.x !== cropBox[0])) {
|
|
554
|
+
rect.x -= cropBox[0];
|
|
555
|
+
rect.y = cropBox[3] - (rect.y + rect.height);
|
|
556
|
+
}
|
|
557
|
+
else {
|
|
558
|
+
rect.y = size[1] - (rect.y + rect.height);
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
else if (mBox && Array.isArray(mBox) && mBox.length === 4 && page._pageDictionary.has('MediaBox')) {
|
|
562
|
+
if (mBox[0] > 0 || mBox[1] > 0 || size[0] === mBox[2] || size[1] === mBox[3]) {
|
|
563
|
+
rect.x -= mBox[0];
|
|
564
|
+
rect.y = mBox[3] - (rect.y + rect.height);
|
|
565
|
+
}
|
|
566
|
+
else {
|
|
567
|
+
rect.y = size[1] - (rect.y + rect.height);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
else {
|
|
571
|
+
rect.y = size[1] - (rect.y + rect.height);
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
else {
|
|
575
|
+
rect.y = rect.y + rect.height;
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
return rect;
|
|
579
|
+
}
|
|
580
|
+
/**
|
|
581
|
+
* Calculate bounds of annotation or field.
|
|
582
|
+
*
|
|
583
|
+
* @private
|
|
584
|
+
* @param {number[]} value array value.
|
|
585
|
+
* @returns {any} Rectangle value.
|
|
586
|
+
*/
|
|
587
|
+
export function _toRectangle(value) {
|
|
588
|
+
return {
|
|
589
|
+
x: Math.min(value[0], value[2]),
|
|
590
|
+
y: Math.min(value[1], value[3]),
|
|
591
|
+
width: Math.abs(value[0] - value[2]),
|
|
592
|
+
height: Math.abs(value[1] - value[3])
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Calculate bounds of annotation or field.
|
|
597
|
+
*
|
|
598
|
+
* @private
|
|
599
|
+
* @param {any} value Rectangle value.
|
|
600
|
+
* @param {any} value.x X value.
|
|
601
|
+
* @param {any} value.y Y value.
|
|
602
|
+
* @param {any} value.width Width value.
|
|
603
|
+
* @param {any} value.height Height value.
|
|
604
|
+
* @returns {number[]} Bounds value.
|
|
605
|
+
*/
|
|
606
|
+
export function _fromRectangle(value) {
|
|
607
|
+
return [value.x, value.y, value.x + value.width, value.y + value.height];
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* Calculate bounds of annotation or field.
|
|
611
|
+
*
|
|
612
|
+
* @private
|
|
613
|
+
* @param {number[]} value Input dictionary.
|
|
614
|
+
* @param {string} page Input page.
|
|
615
|
+
* @returns {number[]} Bounds value.
|
|
616
|
+
*/
|
|
617
|
+
export function _getUpdatedBounds(value, page) {
|
|
618
|
+
var x = value[0];
|
|
619
|
+
var y = value[1];
|
|
620
|
+
var width = value[2];
|
|
621
|
+
var height = value[3];
|
|
622
|
+
if (page) {
|
|
623
|
+
var size = page.size;
|
|
624
|
+
var pageWidth = size[0];
|
|
625
|
+
var pageHeight = size[1];
|
|
626
|
+
var mBox = page.mediaBox;
|
|
627
|
+
var cropBox = page.cropBox;
|
|
628
|
+
if (cropBox && Array.isArray(cropBox) && cropBox.length === 4) {
|
|
629
|
+
if (cropBox[0] !== 0 || cropBox[1] !== 0 || pageWidth === cropBox[2] || pageHeight === cropBox[3]) {
|
|
630
|
+
x += cropBox[0];
|
|
631
|
+
y = cropBox[3] - (y + height);
|
|
632
|
+
}
|
|
633
|
+
else {
|
|
634
|
+
y = pageHeight - (y + height);
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
else if (mBox && Array.isArray(mBox) && mBox.length === 4) {
|
|
638
|
+
if (mBox[0] > 0 || mBox[1] > 0 || pageWidth === mBox[2] || pageHeight === mBox[3]) {
|
|
639
|
+
x -= mBox[0];
|
|
640
|
+
y = mBox[3] - (y + height);
|
|
641
|
+
}
|
|
642
|
+
else {
|
|
643
|
+
y = pageHeight - (y + height);
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
else {
|
|
647
|
+
y = pageHeight - (y + height);
|
|
648
|
+
}
|
|
649
|
+
}
|
|
650
|
+
return [x, y, x + width, y + height];
|
|
651
|
+
}
|
|
652
|
+
/**
|
|
653
|
+
* Parse RGB color.
|
|
654
|
+
*
|
|
655
|
+
* @private
|
|
656
|
+
* @param {string} colorString Color value in string format.
|
|
657
|
+
* @returns {number[]} RGB color value.
|
|
658
|
+
*/
|
|
659
|
+
export function _convertToColor(colorString) {
|
|
660
|
+
var color = _getColorValue(colorString);
|
|
661
|
+
if (!color) {
|
|
662
|
+
var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(colorString);
|
|
663
|
+
if (result) {
|
|
664
|
+
color = [Number.parseInt(result[1], 16), parseInt(result[2], 16), parseInt(result[3], 16)];
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
return color;
|
|
668
|
+
}
|
|
669
|
+
/**
|
|
670
|
+
* Parse RGB color.
|
|
671
|
+
*
|
|
672
|
+
* @private
|
|
673
|
+
* @param {number[]} array Color array in dictionary.
|
|
674
|
+
* @returns {number[]} RGB color value.
|
|
675
|
+
*/
|
|
676
|
+
export function _parseColor(array) {
|
|
677
|
+
var color;
|
|
678
|
+
if (array) {
|
|
679
|
+
if (array.length === 1) {
|
|
680
|
+
var entry = array[0];
|
|
681
|
+
if (typeof entry !== 'undefined') {
|
|
682
|
+
var round = Math.round(entry * 255);
|
|
683
|
+
color = [round, round, round];
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
else if (array.length === 3) {
|
|
687
|
+
var r = array[0];
|
|
688
|
+
var g = array[1];
|
|
689
|
+
var b = array[2];
|
|
690
|
+
if (typeof r !== 'undefined' && typeof g !== 'undefined' && typeof b !== 'undefined') {
|
|
691
|
+
color = [Math.round(r * 255), Math.round(g * 255), Math.round(b * 255)];
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
else if (array.length === 4) {
|
|
695
|
+
var c = array[0];
|
|
696
|
+
var m = array[1];
|
|
697
|
+
var y = array[2];
|
|
698
|
+
var k = array[3];
|
|
699
|
+
if (typeof c !== 'undefined' && typeof m !== 'undefined' && typeof y !== 'undefined' && typeof k !== 'undefined') {
|
|
700
|
+
var fBlack = k * 255;
|
|
701
|
+
color = [Math.round(255 - Math.min(255, ((c * (255 - fBlack)) + fBlack))),
|
|
702
|
+
Math.round(255 - Math.min(255, ((m * (255 - fBlack)) + fBlack))),
|
|
703
|
+
Math.round(255 - Math.min(255, ((y * (255 - fBlack)) + fBlack)))];
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
return color;
|
|
708
|
+
}
|
|
709
|
+
/**
|
|
710
|
+
* Get the border style in _PdfName.
|
|
711
|
+
*
|
|
712
|
+
* @private
|
|
713
|
+
* @param {PdfBorderStyle} style border style in enum.
|
|
714
|
+
* @returns {_PdfName} border style in _PdfName.
|
|
715
|
+
*/
|
|
716
|
+
export function _mapBorderStyle(style) {
|
|
717
|
+
var token = 'S';
|
|
718
|
+
switch (style) {
|
|
719
|
+
case PdfBorderStyle.dot:
|
|
720
|
+
case PdfBorderStyle.dashed:
|
|
721
|
+
token = 'D';
|
|
722
|
+
break;
|
|
723
|
+
case PdfBorderStyle.beveled:
|
|
724
|
+
token = 'B';
|
|
725
|
+
break;
|
|
726
|
+
case PdfBorderStyle.inset:
|
|
727
|
+
token = 'I';
|
|
728
|
+
break;
|
|
729
|
+
case PdfBorderStyle.underline:
|
|
730
|
+
token = 'U';
|
|
731
|
+
break;
|
|
732
|
+
}
|
|
733
|
+
return _PdfName.get(token);
|
|
734
|
+
}
|
|
735
|
+
/**
|
|
736
|
+
* Get the border effect style in _PdfName.
|
|
737
|
+
*
|
|
738
|
+
* @private
|
|
739
|
+
* @param {string} style border effect style as string.
|
|
740
|
+
* @returns {PdfBorderEffectStyle} border effect style.
|
|
741
|
+
*/
|
|
742
|
+
export function _mapBorderEffectStyle(style) {
|
|
743
|
+
var value = PdfBorderEffectStyle.solid;
|
|
744
|
+
switch (style) {
|
|
745
|
+
case 'C':
|
|
746
|
+
value = PdfBorderEffectStyle.cloudy;
|
|
747
|
+
break;
|
|
748
|
+
}
|
|
749
|
+
return value;
|
|
750
|
+
}
|
|
751
|
+
/**
|
|
752
|
+
* Get the string value for line ending style.
|
|
753
|
+
*
|
|
754
|
+
* @private
|
|
755
|
+
* @param {PdfLineEndingStyle} style style in enum.
|
|
756
|
+
* @returns {string} value default None.
|
|
757
|
+
*/
|
|
758
|
+
export function _reverseMapEndingStyle(style) {
|
|
759
|
+
var value = 'None';
|
|
760
|
+
if (typeof style !== 'undefined') {
|
|
761
|
+
switch (style) {
|
|
762
|
+
case PdfLineEndingStyle.openArrow:
|
|
763
|
+
value = 'OpenArrow';
|
|
764
|
+
break;
|
|
765
|
+
case PdfLineEndingStyle.closedArrow:
|
|
766
|
+
value = 'ClosedArrow';
|
|
767
|
+
break;
|
|
768
|
+
case PdfLineEndingStyle.rOpenArrow:
|
|
769
|
+
value = 'ROpenArrow';
|
|
770
|
+
break;
|
|
771
|
+
case PdfLineEndingStyle.rClosedArrow:
|
|
772
|
+
value = 'RClosedArrow';
|
|
773
|
+
break;
|
|
774
|
+
case PdfLineEndingStyle.butt:
|
|
775
|
+
value = 'Butt';
|
|
776
|
+
break;
|
|
777
|
+
case PdfLineEndingStyle.diamond:
|
|
778
|
+
value = 'Diamond';
|
|
779
|
+
break;
|
|
780
|
+
case PdfLineEndingStyle.circle:
|
|
781
|
+
value = 'Circle';
|
|
782
|
+
break;
|
|
783
|
+
case PdfLineEndingStyle.square:
|
|
784
|
+
value = 'Square';
|
|
785
|
+
break;
|
|
786
|
+
case PdfLineEndingStyle.slash:
|
|
787
|
+
value = 'Slash';
|
|
788
|
+
break;
|
|
789
|
+
}
|
|
790
|
+
}
|
|
791
|
+
return value;
|
|
792
|
+
}
|
|
793
|
+
/**
|
|
794
|
+
* Get the enum value for line ending style.
|
|
795
|
+
*
|
|
796
|
+
* @private
|
|
797
|
+
* @param {string} style Style value in string.
|
|
798
|
+
* @param {PdfLineEndingStyle} defaultValue Default style value to return.
|
|
799
|
+
* @returns {PdfLineEndingStyle} enum value default 0.
|
|
800
|
+
*/
|
|
801
|
+
export function _mapLineEndingStyle(style, defaultValue) {
|
|
802
|
+
var value = typeof defaultValue !== 'undefined' ? defaultValue : PdfLineEndingStyle.none;
|
|
803
|
+
switch (style.toLowerCase()) {
|
|
804
|
+
case 'openarrow':
|
|
805
|
+
value = PdfLineEndingStyle.openArrow;
|
|
806
|
+
break;
|
|
807
|
+
case 'closedarrow':
|
|
808
|
+
value = PdfLineEndingStyle.closedArrow;
|
|
809
|
+
break;
|
|
810
|
+
case 'ropenarrow':
|
|
811
|
+
value = PdfLineEndingStyle.rOpenArrow;
|
|
812
|
+
break;
|
|
813
|
+
case 'rclosedarrow':
|
|
814
|
+
value = PdfLineEndingStyle.rClosedArrow;
|
|
815
|
+
break;
|
|
816
|
+
case 'butt':
|
|
817
|
+
value = PdfLineEndingStyle.butt;
|
|
818
|
+
break;
|
|
819
|
+
case 'diamond':
|
|
820
|
+
value = PdfLineEndingStyle.diamond;
|
|
821
|
+
break;
|
|
822
|
+
case 'circle':
|
|
823
|
+
value = PdfLineEndingStyle.circle;
|
|
824
|
+
break;
|
|
825
|
+
case 'square':
|
|
826
|
+
value = PdfLineEndingStyle.square;
|
|
827
|
+
break;
|
|
828
|
+
case 'slash':
|
|
829
|
+
value = PdfLineEndingStyle.slash;
|
|
830
|
+
break;
|
|
831
|
+
}
|
|
832
|
+
return value;
|
|
833
|
+
}
|
|
834
|
+
/**
|
|
835
|
+
* Get highlight mode.
|
|
836
|
+
*
|
|
837
|
+
* @private
|
|
838
|
+
* @param {string} mode Mode entry in dictionary.
|
|
839
|
+
* @returns {PdfHighlightMode} Highlight mode.
|
|
840
|
+
*/
|
|
841
|
+
export function _mapHighlightMode(mode) {
|
|
842
|
+
switch (mode) {
|
|
843
|
+
case 'P':
|
|
844
|
+
return PdfHighlightMode.push;
|
|
845
|
+
case 'N':
|
|
846
|
+
return PdfHighlightMode.noHighlighting;
|
|
847
|
+
case 'O':
|
|
848
|
+
return PdfHighlightMode.outline;
|
|
849
|
+
default:
|
|
850
|
+
return PdfHighlightMode.invert;
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* Get highlight mode as string.
|
|
855
|
+
*
|
|
856
|
+
* @private
|
|
857
|
+
* @param {PdfHighlightMode} mode Mode entry.
|
|
858
|
+
* @returns {_PdfName} Highlight mode as PDF name.
|
|
859
|
+
*/
|
|
860
|
+
export function _reverseMapHighlightMode(mode) {
|
|
861
|
+
switch (mode) {
|
|
862
|
+
case PdfHighlightMode.push:
|
|
863
|
+
return _PdfName.get('P');
|
|
864
|
+
case PdfHighlightMode.noHighlighting:
|
|
865
|
+
return _PdfName.get('N');
|
|
866
|
+
case PdfHighlightMode.outline:
|
|
867
|
+
return _PdfName.get('O');
|
|
868
|
+
default:
|
|
869
|
+
return _PdfName.get('I');
|
|
870
|
+
}
|
|
871
|
+
}
|
|
872
|
+
/**
|
|
873
|
+
* Reverse map blend mode.
|
|
874
|
+
*
|
|
875
|
+
* @private
|
|
876
|
+
* @param {PdfBlendMode} mode Mode entry.
|
|
877
|
+
* @returns {_PdfName} Blend mode as name.
|
|
878
|
+
*/
|
|
879
|
+
export function _reverseMapBlendMode(mode) {
|
|
880
|
+
var token = 'Normal';
|
|
881
|
+
switch (mode) {
|
|
882
|
+
case PdfBlendMode.multiply:
|
|
883
|
+
token = 'Multiply';
|
|
884
|
+
break;
|
|
885
|
+
case PdfBlendMode.screen:
|
|
886
|
+
token = 'Screen';
|
|
887
|
+
break;
|
|
888
|
+
case PdfBlendMode.overlay:
|
|
889
|
+
token = 'Overlay';
|
|
890
|
+
break;
|
|
891
|
+
case PdfBlendMode.darken:
|
|
892
|
+
token = 'Darken';
|
|
893
|
+
break;
|
|
894
|
+
case PdfBlendMode.lighten:
|
|
895
|
+
token = 'Lighten';
|
|
896
|
+
break;
|
|
897
|
+
case PdfBlendMode.colorDodge:
|
|
898
|
+
token = 'ColorDodge';
|
|
899
|
+
break;
|
|
900
|
+
case PdfBlendMode.colorBurn:
|
|
901
|
+
token = 'ColorBurn';
|
|
902
|
+
break;
|
|
903
|
+
case PdfBlendMode.hardLight:
|
|
904
|
+
token = 'HardLight';
|
|
905
|
+
break;
|
|
906
|
+
case PdfBlendMode.softLight:
|
|
907
|
+
token = 'SoftLight';
|
|
908
|
+
break;
|
|
909
|
+
case PdfBlendMode.difference:
|
|
910
|
+
token = 'Difference';
|
|
911
|
+
break;
|
|
912
|
+
case PdfBlendMode.exclusion:
|
|
913
|
+
token = 'Exclusion';
|
|
914
|
+
break;
|
|
915
|
+
case PdfBlendMode.hue:
|
|
916
|
+
token = 'Hue';
|
|
917
|
+
break;
|
|
918
|
+
case PdfBlendMode.saturation:
|
|
919
|
+
token = 'Saturation';
|
|
920
|
+
break;
|
|
921
|
+
case PdfBlendMode.color:
|
|
922
|
+
token = 'Color';
|
|
923
|
+
break;
|
|
924
|
+
case PdfBlendMode.luminosity:
|
|
925
|
+
token = 'Luminosity';
|
|
926
|
+
break;
|
|
927
|
+
default:
|
|
928
|
+
token = 'Normal';
|
|
929
|
+
break;
|
|
930
|
+
}
|
|
931
|
+
return _PdfName.get(token);
|
|
932
|
+
}
|
|
933
|
+
/**
|
|
934
|
+
* Map blend mode.
|
|
935
|
+
*
|
|
936
|
+
* @private
|
|
937
|
+
* @param {_PdfName} token Blend mode as name.
|
|
938
|
+
* @returns {PdfBlendMode} Mode value;
|
|
939
|
+
*/
|
|
940
|
+
export function _mapBlendMode(token) {
|
|
941
|
+
var style = PdfBlendMode.normal;
|
|
942
|
+
switch (token.name) {
|
|
943
|
+
case 'Multiply':
|
|
944
|
+
style = PdfBlendMode.multiply;
|
|
945
|
+
break;
|
|
946
|
+
case 'Screen':
|
|
947
|
+
style = PdfBlendMode.screen;
|
|
948
|
+
break;
|
|
949
|
+
case 'Overlay':
|
|
950
|
+
style = PdfBlendMode.overlay;
|
|
951
|
+
break;
|
|
952
|
+
case 'Darken':
|
|
953
|
+
style = PdfBlendMode.darken;
|
|
954
|
+
break;
|
|
955
|
+
case 'Lighten':
|
|
956
|
+
style = PdfBlendMode.lighten;
|
|
957
|
+
break;
|
|
958
|
+
case 'ColorDodge':
|
|
959
|
+
style = PdfBlendMode.colorDodge;
|
|
960
|
+
break;
|
|
961
|
+
case 'ColorBurn':
|
|
962
|
+
style = PdfBlendMode.colorBurn;
|
|
963
|
+
break;
|
|
964
|
+
case 'HardLight':
|
|
965
|
+
style = PdfBlendMode.hardLight;
|
|
966
|
+
break;
|
|
967
|
+
case 'SoftLight':
|
|
968
|
+
style = PdfBlendMode.softLight;
|
|
969
|
+
break;
|
|
970
|
+
case 'Difference':
|
|
971
|
+
style = PdfBlendMode.difference;
|
|
972
|
+
break;
|
|
973
|
+
case 'Exclusion':
|
|
974
|
+
style = PdfBlendMode.exclusion;
|
|
975
|
+
break;
|
|
976
|
+
case 'Hue':
|
|
977
|
+
style = PdfBlendMode.hue;
|
|
978
|
+
break;
|
|
979
|
+
case 'Saturation':
|
|
980
|
+
style = PdfBlendMode.saturation;
|
|
981
|
+
break;
|
|
982
|
+
case 'Color':
|
|
983
|
+
style = PdfBlendMode.color;
|
|
984
|
+
break;
|
|
985
|
+
case 'Luminosity':
|
|
986
|
+
style = PdfBlendMode.luminosity;
|
|
987
|
+
break;
|
|
988
|
+
default:
|
|
989
|
+
style = PdfBlendMode.normal;
|
|
990
|
+
break;
|
|
991
|
+
}
|
|
992
|
+
return style;
|
|
993
|
+
}
|
|
994
|
+
/**
|
|
995
|
+
* Convert float to string.
|
|
996
|
+
*
|
|
997
|
+
* @private
|
|
998
|
+
* @param {number} value number value.
|
|
999
|
+
* @returns {string} equal fixed length string value;
|
|
1000
|
+
*/
|
|
1001
|
+
export function _floatToString(value) {
|
|
1002
|
+
var returnString = value.toFixed(2);
|
|
1003
|
+
if (returnString === '0.00') {
|
|
1004
|
+
returnString = '.00';
|
|
1005
|
+
}
|
|
1006
|
+
return returnString;
|
|
1007
|
+
}
|
|
1008
|
+
/**
|
|
1009
|
+
* Check and add proc set value.
|
|
1010
|
+
*
|
|
1011
|
+
* @private
|
|
1012
|
+
* @param {string} value entry.
|
|
1013
|
+
* @param {_PdfDictionary} dictionary source dictionary.
|
|
1014
|
+
* @returns {void} Nothing;
|
|
1015
|
+
*/
|
|
1016
|
+
export function _addProcSet(value, dictionary) {
|
|
1017
|
+
var name = _PdfName.get(value);
|
|
1018
|
+
if (dictionary.has('ProcSet')) {
|
|
1019
|
+
var procset = dictionary.getArray('ProcSet');
|
|
1020
|
+
if (procset && procset.indexOf(name) === -1) {
|
|
1021
|
+
procset.push(name);
|
|
1022
|
+
dictionary.update('ProcSet', procset);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
else {
|
|
1026
|
+
dictionary.update('ProcSet', [name]);
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
/**
|
|
1030
|
+
* Get new GUID string.
|
|
1031
|
+
*
|
|
1032
|
+
* @private
|
|
1033
|
+
* @returns {string} A new GUID string;
|
|
1034
|
+
*/
|
|
1035
|
+
export function _getNewGuidString() {
|
|
1036
|
+
return 'aaaaaaaa-aaaa-4aaa-baaa-aaaaaaaaaaaa'.replace(/[ab]/g, function (c) {
|
|
1037
|
+
var random = Math.random() * 16 | 0;
|
|
1038
|
+
var result = c === 'a' ? random : (random & 0x3 | 0x8);
|
|
1039
|
+
return result.toString(16);
|
|
1040
|
+
});
|
|
1041
|
+
}
|
|
1042
|
+
/**
|
|
1043
|
+
* Escape PDF name.
|
|
1044
|
+
*
|
|
1045
|
+
* @private
|
|
1046
|
+
* @param {string} value name value.
|
|
1047
|
+
* @returns {string} equal and processed name value;
|
|
1048
|
+
*/
|
|
1049
|
+
export function _escapePdfName(value) {
|
|
1050
|
+
var buffer = [];
|
|
1051
|
+
var start = 0;
|
|
1052
|
+
for (var i = 0; i < value.length; i++) {
|
|
1053
|
+
var char = value.charCodeAt(i);
|
|
1054
|
+
if (char < 0x21 ||
|
|
1055
|
+
char > 0x7e ||
|
|
1056
|
+
char === 0x23 ||
|
|
1057
|
+
char === 0x28 ||
|
|
1058
|
+
char === 0x29 ||
|
|
1059
|
+
char === 0x3c ||
|
|
1060
|
+
char === 0x3e ||
|
|
1061
|
+
char === 0x5b ||
|
|
1062
|
+
char === 0x5d ||
|
|
1063
|
+
char === 0x7b ||
|
|
1064
|
+
char === 0x7d ||
|
|
1065
|
+
char === 0x2f ||
|
|
1066
|
+
char === 0x25) {
|
|
1067
|
+
if (start < i) {
|
|
1068
|
+
buffer.push(value.substring(start, i));
|
|
1069
|
+
}
|
|
1070
|
+
buffer.push("#" + char.toString(16));
|
|
1071
|
+
start = i + 1;
|
|
1072
|
+
}
|
|
1073
|
+
}
|
|
1074
|
+
if (buffer.length === 0) {
|
|
1075
|
+
return value;
|
|
1076
|
+
}
|
|
1077
|
+
if (start < value.length) {
|
|
1078
|
+
buffer.push(value.substring(start, value.length));
|
|
1079
|
+
}
|
|
1080
|
+
return buffer.join('');
|
|
1081
|
+
}
|
|
1082
|
+
/**
|
|
1083
|
+
* Calculate bezier arc points.
|
|
1084
|
+
*
|
|
1085
|
+
* @private
|
|
1086
|
+
* @param {number} x1 value.
|
|
1087
|
+
* @param {number} y1 value.
|
|
1088
|
+
* @param {number} x2 value.
|
|
1089
|
+
* @param {number} y2 value.
|
|
1090
|
+
* @param {number} start value.
|
|
1091
|
+
* @param {number} extent value.
|
|
1092
|
+
* @returns {number[]} bezier arc points;
|
|
1093
|
+
*/
|
|
1094
|
+
export function _getBezierArc(x1, y1, x2, y2, start, extent) {
|
|
1095
|
+
if (x1 > x2) {
|
|
1096
|
+
var swap = x1;
|
|
1097
|
+
x1 = x2;
|
|
1098
|
+
x2 = swap;
|
|
1099
|
+
}
|
|
1100
|
+
if (y2 > y1) {
|
|
1101
|
+
var swap = y1;
|
|
1102
|
+
y1 = y2;
|
|
1103
|
+
y2 = swap;
|
|
1104
|
+
}
|
|
1105
|
+
var angle;
|
|
1106
|
+
var count;
|
|
1107
|
+
if (Math.abs(extent) <= 90) {
|
|
1108
|
+
angle = extent;
|
|
1109
|
+
count = 1;
|
|
1110
|
+
}
|
|
1111
|
+
else {
|
|
1112
|
+
count = Math.ceil(Math.abs(extent) / 90);
|
|
1113
|
+
angle = extent / count;
|
|
1114
|
+
}
|
|
1115
|
+
var first = ((x1 + x2) / 2);
|
|
1116
|
+
var second = ((y1 + y2) / 2);
|
|
1117
|
+
var firstAngle = ((x2 - x1) / 2);
|
|
1118
|
+
var secondAngle = ((y2 - y1) / 2);
|
|
1119
|
+
var half = (angle * (Math.PI / 360));
|
|
1120
|
+
var value = (Math.abs(4.0 / 3.0 * (1.0 - Math.cos(half)) / Math.sin(half)));
|
|
1121
|
+
var points = [];
|
|
1122
|
+
for (var i = 0; (i < count); i++) {
|
|
1123
|
+
var zero = (((start + (i * angle)) * (Math.PI / 180)));
|
|
1124
|
+
var one = (((start + ((i + 1) * angle)) * (Math.PI / 180)));
|
|
1125
|
+
var cosZero = (Math.cos(zero));
|
|
1126
|
+
var cosOne = (Math.cos(one));
|
|
1127
|
+
var sinZero = (Math.sin(zero));
|
|
1128
|
+
var sinOne = (Math.sin(one));
|
|
1129
|
+
if ((angle > 0)) {
|
|
1130
|
+
points.push(first + (firstAngle * cosZero));
|
|
1131
|
+
points.push(second - (secondAngle * sinZero));
|
|
1132
|
+
points.push(first + (firstAngle * (cosZero - (value * sinZero))));
|
|
1133
|
+
points.push(second - (secondAngle * (sinZero + (value * cosZero))));
|
|
1134
|
+
points.push(first + (firstAngle * (cosOne + (value * sinOne))));
|
|
1135
|
+
points.push(second - (secondAngle * (sinOne - (value * cosOne))));
|
|
1136
|
+
points.push(first + (firstAngle * cosOne));
|
|
1137
|
+
points.push(second - (secondAngle * sinOne));
|
|
1138
|
+
}
|
|
1139
|
+
else {
|
|
1140
|
+
points.push(first + (firstAngle * cosZero));
|
|
1141
|
+
points.push(second - (secondAngle * sinZero));
|
|
1142
|
+
points.push(first + (firstAngle * (cosZero + (value * sinZero))));
|
|
1143
|
+
points.push(second - (secondAngle * (sinZero - (value * cosZero))));
|
|
1144
|
+
points.push(first + (firstAngle * (cosOne - (value * sinOne))));
|
|
1145
|
+
points.push(second - (secondAngle * (sinOne + (value * cosOne))));
|
|
1146
|
+
points.push(first + (firstAngle * cosOne));
|
|
1147
|
+
points.push(second - (secondAngle * sinOne));
|
|
1148
|
+
}
|
|
1149
|
+
}
|
|
1150
|
+
return points;
|
|
1151
|
+
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Find page of the annotation.
|
|
1154
|
+
*
|
|
1155
|
+
* @private
|
|
1156
|
+
* @param {PdfDocument} document PDF document.
|
|
1157
|
+
* @param {_PdfReference} reference Annotation reference.
|
|
1158
|
+
* @returns {PdfPage} Page of the annotation;
|
|
1159
|
+
*/
|
|
1160
|
+
export function _findPage(document, reference) {
|
|
1161
|
+
var page;
|
|
1162
|
+
for (var i = 0; i < document.pageCount && typeof page === 'undefined'; i++) {
|
|
1163
|
+
var entry = document.getPage(i);
|
|
1164
|
+
if (entry && entry._pageDictionary.has('Annots')) {
|
|
1165
|
+
var annots = entry._pageDictionary.get('Annots');
|
|
1166
|
+
if (annots !== null && typeof annots !== 'undefined' && annots.length > 0) {
|
|
1167
|
+
for (var j = 0; j < annots.length && typeof page === 'undefined'; j++) {
|
|
1168
|
+
var ref = annots[Number.parseInt(j.toString(), 10)];
|
|
1169
|
+
if (ref !== null && typeof ref !== 'undefined' && ref instanceof _PdfReference && ref === reference) {
|
|
1170
|
+
page = entry;
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
}
|
|
1176
|
+
return page;
|
|
1177
|
+
}
|
|
1178
|
+
/**
|
|
1179
|
+
* Check the field is checked or not.
|
|
1180
|
+
*
|
|
1181
|
+
* @private
|
|
1182
|
+
* @param {_PdfDictionary} dictionary PDF dictionary.
|
|
1183
|
+
* @returns {boolean} True if the field is checked, otherwise false;
|
|
1184
|
+
*/
|
|
1185
|
+
export function _checkField(dictionary) {
|
|
1186
|
+
var check = false;
|
|
1187
|
+
if (dictionary.has('AS')) {
|
|
1188
|
+
var state = dictionary.get('AS');
|
|
1189
|
+
if (state) {
|
|
1190
|
+
check = state.name !== 'Off';
|
|
1191
|
+
}
|
|
1192
|
+
else {
|
|
1193
|
+
var actual = dictionary.get('V');
|
|
1194
|
+
if (actual) {
|
|
1195
|
+
check = actual.name === _getItemValue(dictionary);
|
|
1196
|
+
}
|
|
1197
|
+
}
|
|
1198
|
+
}
|
|
1199
|
+
return check;
|
|
1200
|
+
}
|
|
1201
|
+
/**
|
|
1202
|
+
* Get item value from state item field.
|
|
1203
|
+
*
|
|
1204
|
+
* @private
|
|
1205
|
+
* @param {_PdfDictionary} itemDictionary PDF document.
|
|
1206
|
+
* @returns {string} value of item;
|
|
1207
|
+
*/
|
|
1208
|
+
export function _getItemValue(itemDictionary) {
|
|
1209
|
+
var itemValue = '';
|
|
1210
|
+
var name;
|
|
1211
|
+
if (itemDictionary.has('AS')) {
|
|
1212
|
+
name = itemDictionary.get('AS');
|
|
1213
|
+
if (name !== null && name.name !== 'Off') {
|
|
1214
|
+
itemValue = name.name;
|
|
1215
|
+
}
|
|
1216
|
+
}
|
|
1217
|
+
if (itemValue === '' && itemDictionary.has('AP')) {
|
|
1218
|
+
var dictionary = itemDictionary.get('AP');
|
|
1219
|
+
if (dictionary && dictionary.has('N')) {
|
|
1220
|
+
var appearance = dictionary.get('N');
|
|
1221
|
+
if (appearance instanceof _PdfBaseStream) {
|
|
1222
|
+
appearance = appearance.dictionary;
|
|
1223
|
+
}
|
|
1224
|
+
if (appearance && appearance instanceof _PdfDictionary) {
|
|
1225
|
+
var keys_1 = [];
|
|
1226
|
+
appearance.forEach(function (key, value) {
|
|
1227
|
+
keys_1.push(key);
|
|
1228
|
+
});
|
|
1229
|
+
for (var i = 0; i < keys_1.length; i++) {
|
|
1230
|
+
if (keys_1[Number.parseInt(i.toString(), 10)] !== 'Off') {
|
|
1231
|
+
itemValue = keys_1[Number.parseInt(i.toString(), 10)];
|
|
1232
|
+
break;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
return itemValue;
|
|
1239
|
+
}
|
|
1240
|
+
/**
|
|
1241
|
+
* Get state item template.
|
|
1242
|
+
*
|
|
1243
|
+
* @private
|
|
1244
|
+
* @param {_PdfCheckFieldState} state Check field state.
|
|
1245
|
+
* @param {PdfStateItem | PdfField} item source to check.
|
|
1246
|
+
* @returns {PdfTemplate} Appearance template;
|
|
1247
|
+
*/
|
|
1248
|
+
export function _getStateTemplate(state, item) {
|
|
1249
|
+
var value = state === _PdfCheckFieldState.checked ? _getItemValue(item._dictionary) : 'Off';
|
|
1250
|
+
var template;
|
|
1251
|
+
if (item._dictionary.has('AP')) {
|
|
1252
|
+
var dictionary = item._dictionary.get('AP');
|
|
1253
|
+
if (dictionary && dictionary.has('N')) {
|
|
1254
|
+
var appearance = dictionary.get('N');
|
|
1255
|
+
if (appearance && appearance instanceof _PdfBaseStream) {
|
|
1256
|
+
appearance = appearance.dictionary;
|
|
1257
|
+
}
|
|
1258
|
+
if (appearance && appearance instanceof _PdfDictionary && (value && value !== '' && appearance.has(value))) {
|
|
1259
|
+
var stream = appearance.get(value);
|
|
1260
|
+
var reference = appearance.getRaw(value);
|
|
1261
|
+
if (reference) {
|
|
1262
|
+
stream.reference = reference;
|
|
1263
|
+
}
|
|
1264
|
+
if (stream) {
|
|
1265
|
+
template = new PdfTemplate(stream, item._crossReference);
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
return template;
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Get color value
|
|
1274
|
+
*
|
|
1275
|
+
* @private
|
|
1276
|
+
* @param {string} colorName name of the color.
|
|
1277
|
+
* @returns {number[]} return color value as number array.
|
|
1278
|
+
*/
|
|
1279
|
+
export function _getColorValue(colorName) {
|
|
1280
|
+
var color;
|
|
1281
|
+
switch (colorName) {
|
|
1282
|
+
case 'transparent':
|
|
1283
|
+
color = [255, 255, 255];
|
|
1284
|
+
break;
|
|
1285
|
+
case 'aliceblue':
|
|
1286
|
+
color = [240, 248, 255];
|
|
1287
|
+
break;
|
|
1288
|
+
case 'antiquewhite':
|
|
1289
|
+
color = [250, 235, 215];
|
|
1290
|
+
break;
|
|
1291
|
+
case 'aqua':
|
|
1292
|
+
color = [0, 255, 255];
|
|
1293
|
+
break;
|
|
1294
|
+
case 'aquamarine':
|
|
1295
|
+
color = [127, 255, 212];
|
|
1296
|
+
break;
|
|
1297
|
+
case 'azure':
|
|
1298
|
+
color = [240, 255, 255];
|
|
1299
|
+
break;
|
|
1300
|
+
case 'beige':
|
|
1301
|
+
color = [245, 245, 220];
|
|
1302
|
+
break;
|
|
1303
|
+
case 'bisque':
|
|
1304
|
+
color = [255, 228, 196];
|
|
1305
|
+
break;
|
|
1306
|
+
case 'black':
|
|
1307
|
+
color = [0, 0, 0];
|
|
1308
|
+
break;
|
|
1309
|
+
case 'blanchedalmond':
|
|
1310
|
+
color = [255, 235, 205];
|
|
1311
|
+
break;
|
|
1312
|
+
case 'blue':
|
|
1313
|
+
color = [0, 0, 255];
|
|
1314
|
+
break;
|
|
1315
|
+
case 'blueviolet':
|
|
1316
|
+
color = [138, 43, 226];
|
|
1317
|
+
break;
|
|
1318
|
+
case 'brown':
|
|
1319
|
+
color = [165, 42, 42];
|
|
1320
|
+
break;
|
|
1321
|
+
case 'burlywood':
|
|
1322
|
+
color = [222, 184, 135];
|
|
1323
|
+
break;
|
|
1324
|
+
case 'cadetBlue':
|
|
1325
|
+
color = [95, 158, 160];
|
|
1326
|
+
break;
|
|
1327
|
+
case 'chartreuse':
|
|
1328
|
+
color = [127, 255, 0];
|
|
1329
|
+
break;
|
|
1330
|
+
case 'chocolate':
|
|
1331
|
+
color = [210, 105, 30];
|
|
1332
|
+
break;
|
|
1333
|
+
case 'coral':
|
|
1334
|
+
color = [255, 127, 80];
|
|
1335
|
+
break;
|
|
1336
|
+
case 'cornflowerblue':
|
|
1337
|
+
color = [100, 149, 237];
|
|
1338
|
+
break;
|
|
1339
|
+
case 'cornsilk':
|
|
1340
|
+
color = [255, 248, 220];
|
|
1341
|
+
break;
|
|
1342
|
+
case 'crimson':
|
|
1343
|
+
color = [220, 20, 60];
|
|
1344
|
+
break;
|
|
1345
|
+
case 'cyan':
|
|
1346
|
+
color = [0, 255, 255];
|
|
1347
|
+
break;
|
|
1348
|
+
case 'darkblue':
|
|
1349
|
+
color = [0, 0, 139];
|
|
1350
|
+
break;
|
|
1351
|
+
case 'darkcyan':
|
|
1352
|
+
color = [0, 139, 139];
|
|
1353
|
+
break;
|
|
1354
|
+
case 'darkgoldenrod':
|
|
1355
|
+
color = [184, 134, 11];
|
|
1356
|
+
break;
|
|
1357
|
+
case 'darkgray':
|
|
1358
|
+
color = [169, 169, 169];
|
|
1359
|
+
break;
|
|
1360
|
+
case 'darkgreen':
|
|
1361
|
+
color = [0, 100, 0];
|
|
1362
|
+
break;
|
|
1363
|
+
case 'darkkhaki':
|
|
1364
|
+
color = [189, 183, 107];
|
|
1365
|
+
break;
|
|
1366
|
+
case 'darkmagenta':
|
|
1367
|
+
color = [139, 0, 139];
|
|
1368
|
+
break;
|
|
1369
|
+
case 'darkolivegreen':
|
|
1370
|
+
color = [85, 107, 47];
|
|
1371
|
+
break;
|
|
1372
|
+
case 'darkorange':
|
|
1373
|
+
color = [255, 140, 0];
|
|
1374
|
+
break;
|
|
1375
|
+
case 'darkorchid':
|
|
1376
|
+
color = [153, 50, 204];
|
|
1377
|
+
break;
|
|
1378
|
+
case 'darkred':
|
|
1379
|
+
color = [139, 0, 0];
|
|
1380
|
+
break;
|
|
1381
|
+
case 'darksalmon':
|
|
1382
|
+
color = [233, 150, 122];
|
|
1383
|
+
break;
|
|
1384
|
+
case 'darkseagreen':
|
|
1385
|
+
color = [143, 188, 139];
|
|
1386
|
+
break;
|
|
1387
|
+
case 'darkslateblue':
|
|
1388
|
+
color = [72, 61, 139];
|
|
1389
|
+
break;
|
|
1390
|
+
case 'darkslategray':
|
|
1391
|
+
color = [47, 79, 79];
|
|
1392
|
+
break;
|
|
1393
|
+
case 'darkturquoise':
|
|
1394
|
+
color = [0, 206, 209];
|
|
1395
|
+
break;
|
|
1396
|
+
case 'darkviolet':
|
|
1397
|
+
color = [148, 0, 211];
|
|
1398
|
+
break;
|
|
1399
|
+
case 'deeppink':
|
|
1400
|
+
color = [255, 20, 147];
|
|
1401
|
+
break;
|
|
1402
|
+
case 'deepskyblue':
|
|
1403
|
+
color = [0, 191, 255];
|
|
1404
|
+
break;
|
|
1405
|
+
case 'dimgray':
|
|
1406
|
+
color = [105, 105, 105];
|
|
1407
|
+
break;
|
|
1408
|
+
case 'dodgerblue':
|
|
1409
|
+
color = [30, 144, 255];
|
|
1410
|
+
break;
|
|
1411
|
+
case 'firebrick':
|
|
1412
|
+
color = [178, 34, 34];
|
|
1413
|
+
break;
|
|
1414
|
+
case 'floralwhite':
|
|
1415
|
+
color = [255, 250, 240];
|
|
1416
|
+
break;
|
|
1417
|
+
case 'forestgreen':
|
|
1418
|
+
color = [34, 139, 34];
|
|
1419
|
+
break;
|
|
1420
|
+
case 'fuchsia':
|
|
1421
|
+
color = [255, 0, 255];
|
|
1422
|
+
break;
|
|
1423
|
+
case 'gainsboro':
|
|
1424
|
+
color = [220, 220, 220];
|
|
1425
|
+
break;
|
|
1426
|
+
case 'ghostwhite':
|
|
1427
|
+
color = [248, 248, 255];
|
|
1428
|
+
break;
|
|
1429
|
+
case 'gold':
|
|
1430
|
+
color = [255, 215, 0];
|
|
1431
|
+
break;
|
|
1432
|
+
case 'goldenrod':
|
|
1433
|
+
color = [218, 165, 32];
|
|
1434
|
+
break;
|
|
1435
|
+
case 'gray':
|
|
1436
|
+
color = [128, 128, 128];
|
|
1437
|
+
break;
|
|
1438
|
+
case 'green':
|
|
1439
|
+
color = [0, 128, 0];
|
|
1440
|
+
break;
|
|
1441
|
+
case 'greenyellow':
|
|
1442
|
+
color = [173, 255, 47];
|
|
1443
|
+
break;
|
|
1444
|
+
case 'honeydew':
|
|
1445
|
+
color = [240, 255, 240];
|
|
1446
|
+
break;
|
|
1447
|
+
case 'hotpink':
|
|
1448
|
+
color = [255, 105, 180];
|
|
1449
|
+
break;
|
|
1450
|
+
case 'indianred':
|
|
1451
|
+
color = [205, 92, 92];
|
|
1452
|
+
break;
|
|
1453
|
+
case 'indigo':
|
|
1454
|
+
color = [75, 0, 130];
|
|
1455
|
+
break;
|
|
1456
|
+
case 'ivory':
|
|
1457
|
+
color = [255, 255, 240];
|
|
1458
|
+
break;
|
|
1459
|
+
case 'khaki':
|
|
1460
|
+
color = [240, 230, 140];
|
|
1461
|
+
break;
|
|
1462
|
+
case 'lavender':
|
|
1463
|
+
color = [230, 230, 250];
|
|
1464
|
+
break;
|
|
1465
|
+
case 'lavenderblush':
|
|
1466
|
+
color = [255, 240, 245];
|
|
1467
|
+
break;
|
|
1468
|
+
case 'lawngreen':
|
|
1469
|
+
color = [124, 252, 0];
|
|
1470
|
+
break;
|
|
1471
|
+
case 'lemonchiffon':
|
|
1472
|
+
color = [255, 250, 205];
|
|
1473
|
+
break;
|
|
1474
|
+
case 'lightblue':
|
|
1475
|
+
color = [173, 216, 230];
|
|
1476
|
+
break;
|
|
1477
|
+
case 'lightcoral':
|
|
1478
|
+
color = [240, 128, 128];
|
|
1479
|
+
break;
|
|
1480
|
+
case 'lightcyan':
|
|
1481
|
+
color = [224, 255, 255];
|
|
1482
|
+
break;
|
|
1483
|
+
case 'lightgoldenrodyellow':
|
|
1484
|
+
color = [250, 250, 210];
|
|
1485
|
+
break;
|
|
1486
|
+
case 'lightgreen':
|
|
1487
|
+
color = [144, 238, 144];
|
|
1488
|
+
break;
|
|
1489
|
+
case 'lightgray':
|
|
1490
|
+
color = [211, 211, 211];
|
|
1491
|
+
break;
|
|
1492
|
+
case 'LightPink':
|
|
1493
|
+
color = [255, 182, 193];
|
|
1494
|
+
break;
|
|
1495
|
+
case 'lightsalmon':
|
|
1496
|
+
color = [255, 160, 122];
|
|
1497
|
+
break;
|
|
1498
|
+
case 'lightseagreen':
|
|
1499
|
+
color = [32, 178, 170];
|
|
1500
|
+
break;
|
|
1501
|
+
case 'lightskyblue':
|
|
1502
|
+
color = [135, 206, 250];
|
|
1503
|
+
break;
|
|
1504
|
+
case 'lightslategray':
|
|
1505
|
+
color = [119, 136, 153];
|
|
1506
|
+
break;
|
|
1507
|
+
case 'lightsteelblue':
|
|
1508
|
+
color = [176, 196, 222];
|
|
1509
|
+
break;
|
|
1510
|
+
case 'lightyellow':
|
|
1511
|
+
color = [255, 255, 224];
|
|
1512
|
+
break;
|
|
1513
|
+
case 'lime':
|
|
1514
|
+
color = [0, 255, 0];
|
|
1515
|
+
break;
|
|
1516
|
+
case 'limeGreen':
|
|
1517
|
+
color = [50, 205, 50];
|
|
1518
|
+
break;
|
|
1519
|
+
case 'linen':
|
|
1520
|
+
color = [250, 240, 230];
|
|
1521
|
+
break;
|
|
1522
|
+
case 'magenta':
|
|
1523
|
+
color = [255, 0, 255];
|
|
1524
|
+
break;
|
|
1525
|
+
case 'maroon':
|
|
1526
|
+
color = [128, 0, 0];
|
|
1527
|
+
break;
|
|
1528
|
+
case 'mediumaquamarine':
|
|
1529
|
+
color = [102, 205, 170];
|
|
1530
|
+
break;
|
|
1531
|
+
case 'mediumblue':
|
|
1532
|
+
color = [0, 0, 205];
|
|
1533
|
+
break;
|
|
1534
|
+
case 'mediumorchid':
|
|
1535
|
+
color = [186, 85, 211];
|
|
1536
|
+
break;
|
|
1537
|
+
case 'mediumpurple':
|
|
1538
|
+
color = [147, 112, 219];
|
|
1539
|
+
break;
|
|
1540
|
+
case 'mediumseagreen':
|
|
1541
|
+
color = [60, 179, 113];
|
|
1542
|
+
break;
|
|
1543
|
+
case 'mediumslateblue':
|
|
1544
|
+
color = [123, 104, 238];
|
|
1545
|
+
break;
|
|
1546
|
+
case 'mediumspringgreen':
|
|
1547
|
+
color = [0, 250, 154];
|
|
1548
|
+
break;
|
|
1549
|
+
case 'mediumturquoise':
|
|
1550
|
+
color = [72, 209, 204];
|
|
1551
|
+
break;
|
|
1552
|
+
case 'mediumvioletred':
|
|
1553
|
+
color = [199, 21, 133];
|
|
1554
|
+
break;
|
|
1555
|
+
case 'midnightblue':
|
|
1556
|
+
color = [25, 25, 112];
|
|
1557
|
+
break;
|
|
1558
|
+
case 'mintcream':
|
|
1559
|
+
color = [245, 255, 250];
|
|
1560
|
+
break;
|
|
1561
|
+
case 'mistyrose':
|
|
1562
|
+
color = [255, 228, 225];
|
|
1563
|
+
break;
|
|
1564
|
+
case 'moccasin':
|
|
1565
|
+
color = [255, 228, 181];
|
|
1566
|
+
break;
|
|
1567
|
+
case 'navajowhite':
|
|
1568
|
+
color = [255, 222, 173];
|
|
1569
|
+
break;
|
|
1570
|
+
case 'navy':
|
|
1571
|
+
color = [0, 0, 128];
|
|
1572
|
+
break;
|
|
1573
|
+
case 'oldLace':
|
|
1574
|
+
color = [253, 245, 230];
|
|
1575
|
+
break;
|
|
1576
|
+
case 'olive':
|
|
1577
|
+
color = [128, 128, 0];
|
|
1578
|
+
break;
|
|
1579
|
+
case 'olivedrab':
|
|
1580
|
+
color = [107, 142, 35];
|
|
1581
|
+
break;
|
|
1582
|
+
case 'orange':
|
|
1583
|
+
color = [255, 165, 0];
|
|
1584
|
+
break;
|
|
1585
|
+
case 'orangered':
|
|
1586
|
+
color = [255, 69, 0];
|
|
1587
|
+
break;
|
|
1588
|
+
case 'orchid':
|
|
1589
|
+
color = [218, 112, 214];
|
|
1590
|
+
break;
|
|
1591
|
+
case 'palegoldenrod':
|
|
1592
|
+
color = [238, 232, 170];
|
|
1593
|
+
break;
|
|
1594
|
+
case 'palegreen':
|
|
1595
|
+
color = [152, 251, 152];
|
|
1596
|
+
break;
|
|
1597
|
+
case 'paleturquoise':
|
|
1598
|
+
color = [175, 238, 238];
|
|
1599
|
+
break;
|
|
1600
|
+
case 'palebioletred':
|
|
1601
|
+
color = [219, 112, 147];
|
|
1602
|
+
break;
|
|
1603
|
+
case 'papayawhip':
|
|
1604
|
+
color = [255, 239, 213];
|
|
1605
|
+
break;
|
|
1606
|
+
case 'peachpuff':
|
|
1607
|
+
color = [255, 218, 185];
|
|
1608
|
+
break;
|
|
1609
|
+
case 'peru':
|
|
1610
|
+
color = [205, 133, 63];
|
|
1611
|
+
break;
|
|
1612
|
+
case 'pink':
|
|
1613
|
+
color = [255, 192, 203];
|
|
1614
|
+
break;
|
|
1615
|
+
case 'plum':
|
|
1616
|
+
color = [221, 160, 221];
|
|
1617
|
+
break;
|
|
1618
|
+
case 'powderblue':
|
|
1619
|
+
color = [176, 224, 230];
|
|
1620
|
+
break;
|
|
1621
|
+
case 'purple':
|
|
1622
|
+
color = [128, 0, 128];
|
|
1623
|
+
break;
|
|
1624
|
+
case 'red':
|
|
1625
|
+
color = [255, 0, 0];
|
|
1626
|
+
break;
|
|
1627
|
+
case 'rosybrown':
|
|
1628
|
+
color = [188, 143, 143];
|
|
1629
|
+
break;
|
|
1630
|
+
case 'royalblue':
|
|
1631
|
+
color = [65, 105, 225];
|
|
1632
|
+
break;
|
|
1633
|
+
case 'saddlebrown':
|
|
1634
|
+
color = [139, 69, 19];
|
|
1635
|
+
break;
|
|
1636
|
+
case 'salmon':
|
|
1637
|
+
color = [250, 128, 114];
|
|
1638
|
+
break;
|
|
1639
|
+
case 'sandybrown':
|
|
1640
|
+
color = [244, 164, 96];
|
|
1641
|
+
break;
|
|
1642
|
+
case 'seagreen':
|
|
1643
|
+
color = [46, 139, 87];
|
|
1644
|
+
break;
|
|
1645
|
+
case 'seashell':
|
|
1646
|
+
color = [255, 245, 238];
|
|
1647
|
+
break;
|
|
1648
|
+
case 'sienna':
|
|
1649
|
+
color = [160, 82, 45];
|
|
1650
|
+
break;
|
|
1651
|
+
case 'silver':
|
|
1652
|
+
color = [192, 192, 192];
|
|
1653
|
+
break;
|
|
1654
|
+
case 'skyblue':
|
|
1655
|
+
color = [135, 206, 235];
|
|
1656
|
+
break;
|
|
1657
|
+
case 'slateblue':
|
|
1658
|
+
color = [106, 90, 205];
|
|
1659
|
+
break;
|
|
1660
|
+
case 'slategray':
|
|
1661
|
+
color = [112, 128, 144];
|
|
1662
|
+
break;
|
|
1663
|
+
case 'snow':
|
|
1664
|
+
color = [255, 250, 250];
|
|
1665
|
+
break;
|
|
1666
|
+
case 'springgreen':
|
|
1667
|
+
color = [0, 255, 127];
|
|
1668
|
+
break;
|
|
1669
|
+
case 'steelblue':
|
|
1670
|
+
color = [70, 130, 180];
|
|
1671
|
+
break;
|
|
1672
|
+
case 'tan':
|
|
1673
|
+
color = [210, 180, 140];
|
|
1674
|
+
break;
|
|
1675
|
+
case 'teal':
|
|
1676
|
+
color = [0, 128, 128];
|
|
1677
|
+
break;
|
|
1678
|
+
case 'thistle':
|
|
1679
|
+
color = [216, 191, 216];
|
|
1680
|
+
break;
|
|
1681
|
+
case 'tomato':
|
|
1682
|
+
color = [255, 99, 71];
|
|
1683
|
+
break;
|
|
1684
|
+
case 'turquoise':
|
|
1685
|
+
color = [64, 224, 208];
|
|
1686
|
+
break;
|
|
1687
|
+
case 'violet':
|
|
1688
|
+
color = [238, 130, 238];
|
|
1689
|
+
break;
|
|
1690
|
+
case 'wheat':
|
|
1691
|
+
color = [245, 222, 179];
|
|
1692
|
+
break;
|
|
1693
|
+
case 'white':
|
|
1694
|
+
color = [255, 255, 255];
|
|
1695
|
+
break;
|
|
1696
|
+
case 'whitesmoke':
|
|
1697
|
+
color = [245, 245, 245];
|
|
1698
|
+
break;
|
|
1699
|
+
case 'yellow':
|
|
1700
|
+
color = [255, 255, 0];
|
|
1701
|
+
break;
|
|
1702
|
+
case 'yellowgreen':
|
|
1703
|
+
color = [154, 205, 50];
|
|
1704
|
+
break;
|
|
1705
|
+
}
|
|
1706
|
+
return color;
|
|
1707
|
+
}
|
|
1708
|
+
/**
|
|
1709
|
+
* Update box value in template bounds.
|
|
1710
|
+
*
|
|
1711
|
+
* @private
|
|
1712
|
+
* @param {PdfTemplate} template Template object.
|
|
1713
|
+
* @param {number} angle Angle value.
|
|
1714
|
+
* @returns {void} Nothing.
|
|
1715
|
+
*/
|
|
1716
|
+
export function _setMatrix(template, angle) {
|
|
1717
|
+
var box = template._content.dictionary.getArray('BBox');
|
|
1718
|
+
if (box && typeof angle !== 'undefined' && angle !== null) {
|
|
1719
|
+
if (angle === 0) {
|
|
1720
|
+
template._content.dictionary.set('Matrix', [1, 0, 0, 1, -box[0], -box[1]]);
|
|
1721
|
+
}
|
|
1722
|
+
else {
|
|
1723
|
+
var matrix = new _PdfTransformationMatrix();
|
|
1724
|
+
matrix._rotate(angle);
|
|
1725
|
+
template._content.dictionary.set('Matrix', matrix._matrix._elements);
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
/**
|
|
1730
|
+
* Get the state item style to string
|
|
1731
|
+
*
|
|
1732
|
+
* @private
|
|
1733
|
+
* @param {PdfCheckBoxStyle} style State item style.
|
|
1734
|
+
* @returns {string} return as string value.
|
|
1735
|
+
*/
|
|
1736
|
+
export function _styleToString(style) {
|
|
1737
|
+
var value = '4';
|
|
1738
|
+
switch (style) {
|
|
1739
|
+
case PdfCheckBoxStyle.circle:
|
|
1740
|
+
value = 'l';
|
|
1741
|
+
break;
|
|
1742
|
+
case PdfCheckBoxStyle.cross:
|
|
1743
|
+
value = '8';
|
|
1744
|
+
break;
|
|
1745
|
+
case PdfCheckBoxStyle.diamond:
|
|
1746
|
+
value = 'u';
|
|
1747
|
+
break;
|
|
1748
|
+
case PdfCheckBoxStyle.square:
|
|
1749
|
+
value = 'n';
|
|
1750
|
+
break;
|
|
1751
|
+
case PdfCheckBoxStyle.star:
|
|
1752
|
+
value = 'H';
|
|
1753
|
+
break;
|
|
1754
|
+
}
|
|
1755
|
+
return value;
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* Get the string to state item style
|
|
1759
|
+
*
|
|
1760
|
+
* @private
|
|
1761
|
+
* @param {string} style State item style as string.
|
|
1762
|
+
* @returns {PdfCheckBoxStyle} return as state item style.
|
|
1763
|
+
*/
|
|
1764
|
+
export function _stringToStyle(style) {
|
|
1765
|
+
var value = PdfCheckBoxStyle.check;
|
|
1766
|
+
switch (style) {
|
|
1767
|
+
case 'l':
|
|
1768
|
+
value = PdfCheckBoxStyle.circle;
|
|
1769
|
+
break;
|
|
1770
|
+
case '8':
|
|
1771
|
+
value = PdfCheckBoxStyle.cross;
|
|
1772
|
+
break;
|
|
1773
|
+
case 'u':
|
|
1774
|
+
value = PdfCheckBoxStyle.diamond;
|
|
1775
|
+
break;
|
|
1776
|
+
case 'n':
|
|
1777
|
+
value = PdfCheckBoxStyle.square;
|
|
1778
|
+
break;
|
|
1779
|
+
case 'H':
|
|
1780
|
+
value = PdfCheckBoxStyle.star;
|
|
1781
|
+
break;
|
|
1782
|
+
}
|
|
1783
|
+
return value;
|
|
1784
|
+
}
|
|
1785
|
+
/**
|
|
1786
|
+
* Map measurement unit type.
|
|
1787
|
+
*
|
|
1788
|
+
* @private
|
|
1789
|
+
* @param {string} unitString measurement unit as string.
|
|
1790
|
+
* @returns {PdfMeasurementUnit} measurement unit.
|
|
1791
|
+
*/
|
|
1792
|
+
export function _mapMeasurementUnit(unitString) {
|
|
1793
|
+
var unit;
|
|
1794
|
+
switch (unitString) {
|
|
1795
|
+
case 'cm':
|
|
1796
|
+
unit = PdfMeasurementUnit.centimeter;
|
|
1797
|
+
break;
|
|
1798
|
+
case 'in':
|
|
1799
|
+
unit = PdfMeasurementUnit.inch;
|
|
1800
|
+
break;
|
|
1801
|
+
case 'mm':
|
|
1802
|
+
unit = PdfMeasurementUnit.millimeter;
|
|
1803
|
+
break;
|
|
1804
|
+
case 'p':
|
|
1805
|
+
unit = PdfMeasurementUnit.pica;
|
|
1806
|
+
break;
|
|
1807
|
+
case 'pt':
|
|
1808
|
+
unit = PdfMeasurementUnit.point;
|
|
1809
|
+
break;
|
|
1810
|
+
default:
|
|
1811
|
+
unit = PdfMeasurementUnit.centimeter;
|
|
1812
|
+
break;
|
|
1813
|
+
}
|
|
1814
|
+
return unit;
|
|
1815
|
+
}
|
|
1816
|
+
/**
|
|
1817
|
+
* Map markup annotation type.
|
|
1818
|
+
*
|
|
1819
|
+
* @private
|
|
1820
|
+
* @param {string} text markup type as string.
|
|
1821
|
+
* @returns {PdfTextMarkupAnnotationType} markup type as name.
|
|
1822
|
+
*/
|
|
1823
|
+
export function _mapMarkupAnnotationType(text) {
|
|
1824
|
+
var type;
|
|
1825
|
+
switch (text) {
|
|
1826
|
+
case 'Highlight':
|
|
1827
|
+
type = PdfTextMarkupAnnotationType.highlight;
|
|
1828
|
+
break;
|
|
1829
|
+
case 'Squiggly':
|
|
1830
|
+
type = PdfTextMarkupAnnotationType.squiggly;
|
|
1831
|
+
break;
|
|
1832
|
+
case 'StrikeOut':
|
|
1833
|
+
type = PdfTextMarkupAnnotationType.strikeOut;
|
|
1834
|
+
break;
|
|
1835
|
+
case 'Underline':
|
|
1836
|
+
type = PdfTextMarkupAnnotationType.underline;
|
|
1837
|
+
break;
|
|
1838
|
+
default:
|
|
1839
|
+
type = PdfTextMarkupAnnotationType.highlight;
|
|
1840
|
+
break;
|
|
1841
|
+
}
|
|
1842
|
+
return type;
|
|
1843
|
+
}
|
|
1844
|
+
/**
|
|
1845
|
+
* Reverse text markup annotation type.
|
|
1846
|
+
*
|
|
1847
|
+
* @private
|
|
1848
|
+
* @param {PdfTextMarkupAnnotationType} type markup type.
|
|
1849
|
+
* @returns {string} markup type as name.
|
|
1850
|
+
*/
|
|
1851
|
+
export function _reverseMarkupAnnotationType(type) {
|
|
1852
|
+
var token = 'Highlight';
|
|
1853
|
+
switch (type) {
|
|
1854
|
+
case PdfTextMarkupAnnotationType.highlight:
|
|
1855
|
+
token = 'Highlight';
|
|
1856
|
+
break;
|
|
1857
|
+
case PdfTextMarkupAnnotationType.squiggly:
|
|
1858
|
+
token = 'Squiggly';
|
|
1859
|
+
break;
|
|
1860
|
+
case PdfTextMarkupAnnotationType.strikeOut:
|
|
1861
|
+
token = 'StrikeOut';
|
|
1862
|
+
break;
|
|
1863
|
+
case PdfTextMarkupAnnotationType.underline:
|
|
1864
|
+
token = 'Underline';
|
|
1865
|
+
break;
|
|
1866
|
+
default:
|
|
1867
|
+
token = 'Highlight';
|
|
1868
|
+
break;
|
|
1869
|
+
}
|
|
1870
|
+
return token;
|
|
1871
|
+
}
|
|
1872
|
+
/**
|
|
1873
|
+
* Map graphics unit.
|
|
1874
|
+
*
|
|
1875
|
+
* @private
|
|
1876
|
+
* @param {string} unitString String value.
|
|
1877
|
+
* @returns {_PdfGraphicsUnit} PDF graphics unit.
|
|
1878
|
+
*/
|
|
1879
|
+
export function _mapGraphicsUnit(unitString) {
|
|
1880
|
+
var unit;
|
|
1881
|
+
switch (unitString) {
|
|
1882
|
+
case 'cm':
|
|
1883
|
+
unit = _PdfGraphicsUnit.centimeter;
|
|
1884
|
+
break;
|
|
1885
|
+
case 'in':
|
|
1886
|
+
unit = _PdfGraphicsUnit.inch;
|
|
1887
|
+
break;
|
|
1888
|
+
case 'mm':
|
|
1889
|
+
unit = _PdfGraphicsUnit.millimeter;
|
|
1890
|
+
break;
|
|
1891
|
+
case 'p':
|
|
1892
|
+
unit = _PdfGraphicsUnit.pica;
|
|
1893
|
+
break;
|
|
1894
|
+
case 'pt':
|
|
1895
|
+
unit = _PdfGraphicsUnit.point;
|
|
1896
|
+
break;
|
|
1897
|
+
default:
|
|
1898
|
+
unit = _PdfGraphicsUnit.centimeter;
|
|
1899
|
+
break;
|
|
1900
|
+
}
|
|
1901
|
+
return unit;
|
|
1902
|
+
}
|
|
1903
|
+
/**
|
|
1904
|
+
* Map rubber stamp icon.
|
|
1905
|
+
*
|
|
1906
|
+
* @param {string} iconString String value.
|
|
1907
|
+
* @returns {PdfRubberStampAnnotationIcon} Rubber stamp icon.
|
|
1908
|
+
*/
|
|
1909
|
+
export function _mapRubberStampIcon(iconString) {
|
|
1910
|
+
var icon;
|
|
1911
|
+
switch (iconString) {
|
|
1912
|
+
case '#Approved':
|
|
1913
|
+
icon = PdfRubberStampAnnotationIcon.approved;
|
|
1914
|
+
break;
|
|
1915
|
+
case '#AsIs':
|
|
1916
|
+
icon = PdfRubberStampAnnotationIcon.asIs;
|
|
1917
|
+
break;
|
|
1918
|
+
case '#Completed':
|
|
1919
|
+
icon = PdfRubberStampAnnotationIcon.completed;
|
|
1920
|
+
break;
|
|
1921
|
+
case '#Confidential':
|
|
1922
|
+
icon = PdfRubberStampAnnotationIcon.confidential;
|
|
1923
|
+
break;
|
|
1924
|
+
case '#Departmental':
|
|
1925
|
+
icon = PdfRubberStampAnnotationIcon.departmental;
|
|
1926
|
+
break;
|
|
1927
|
+
case '#Draft':
|
|
1928
|
+
icon = PdfRubberStampAnnotationIcon.draft;
|
|
1929
|
+
break;
|
|
1930
|
+
case '#Experimental':
|
|
1931
|
+
icon = PdfRubberStampAnnotationIcon.experimental;
|
|
1932
|
+
break;
|
|
1933
|
+
case '#Expired':
|
|
1934
|
+
icon = PdfRubberStampAnnotationIcon.expired;
|
|
1935
|
+
break;
|
|
1936
|
+
case '#Final':
|
|
1937
|
+
icon = PdfRubberStampAnnotationIcon.final;
|
|
1938
|
+
break;
|
|
1939
|
+
case '#ForComment':
|
|
1940
|
+
icon = PdfRubberStampAnnotationIcon.forComment;
|
|
1941
|
+
break;
|
|
1942
|
+
case '#ForPublicRelease':
|
|
1943
|
+
icon = PdfRubberStampAnnotationIcon.forPublicRelease;
|
|
1944
|
+
break;
|
|
1945
|
+
case '#InformationOnly':
|
|
1946
|
+
icon = PdfRubberStampAnnotationIcon.informationOnly;
|
|
1947
|
+
break;
|
|
1948
|
+
case '#NotApproved':
|
|
1949
|
+
icon = PdfRubberStampAnnotationIcon.notApproved;
|
|
1950
|
+
break;
|
|
1951
|
+
case '#NotForPublicRelease':
|
|
1952
|
+
icon = PdfRubberStampAnnotationIcon.notForPublicRelease;
|
|
1953
|
+
break;
|
|
1954
|
+
case '#PreliminaryResults':
|
|
1955
|
+
icon = PdfRubberStampAnnotationIcon.preliminaryResults;
|
|
1956
|
+
break;
|
|
1957
|
+
case '#Sold':
|
|
1958
|
+
icon = PdfRubberStampAnnotationIcon.sold;
|
|
1959
|
+
break;
|
|
1960
|
+
case '#TopSecret':
|
|
1961
|
+
icon = PdfRubberStampAnnotationIcon.topSecret;
|
|
1962
|
+
break;
|
|
1963
|
+
case '#Void':
|
|
1964
|
+
icon = PdfRubberStampAnnotationIcon.void;
|
|
1965
|
+
break;
|
|
1966
|
+
default:
|
|
1967
|
+
icon = PdfRubberStampAnnotationIcon.draft;
|
|
1968
|
+
break;
|
|
1969
|
+
}
|
|
1970
|
+
return icon;
|
|
1971
|
+
}
|
|
1972
|
+
/**
|
|
1973
|
+
* Map popup icon.
|
|
1974
|
+
*
|
|
1975
|
+
* @private
|
|
1976
|
+
* @param {string} iconString String value.
|
|
1977
|
+
* @returns {PdfRubberStampAnnotationIcon} Popup icon.
|
|
1978
|
+
*/
|
|
1979
|
+
export function _mapPopupIcon(iconString) {
|
|
1980
|
+
var icon;
|
|
1981
|
+
switch (iconString) {
|
|
1982
|
+
case 'Note':
|
|
1983
|
+
icon = PdfPopupIcon.note;
|
|
1984
|
+
break;
|
|
1985
|
+
case 'Comment':
|
|
1986
|
+
icon = PdfPopupIcon.comment;
|
|
1987
|
+
break;
|
|
1988
|
+
case 'Help':
|
|
1989
|
+
icon = PdfPopupIcon.help;
|
|
1990
|
+
break;
|
|
1991
|
+
case 'Insert':
|
|
1992
|
+
icon = PdfPopupIcon.insert;
|
|
1993
|
+
break;
|
|
1994
|
+
case 'Key':
|
|
1995
|
+
icon = PdfPopupIcon.key;
|
|
1996
|
+
break;
|
|
1997
|
+
case 'NewParagraph':
|
|
1998
|
+
icon = PdfPopupIcon.newParagraph;
|
|
1999
|
+
break;
|
|
2000
|
+
case 'Paragraph':
|
|
2001
|
+
icon = PdfPopupIcon.paragraph;
|
|
2002
|
+
break;
|
|
2003
|
+
default:
|
|
2004
|
+
icon = PdfPopupIcon.note;
|
|
2005
|
+
break;
|
|
2006
|
+
}
|
|
2007
|
+
return icon;
|
|
2008
|
+
}
|
|
2009
|
+
/**
|
|
2010
|
+
* Convert annotation state to string value.
|
|
2011
|
+
*
|
|
2012
|
+
* @private
|
|
2013
|
+
* @param {PdfAnnotationState} type Annotation state.
|
|
2014
|
+
* @returns {string} String value.
|
|
2015
|
+
*/
|
|
2016
|
+
export function _reverseMapAnnotationState(type) {
|
|
2017
|
+
var token = 'None';
|
|
2018
|
+
switch (type) {
|
|
2019
|
+
case PdfAnnotationState.none:
|
|
2020
|
+
token = 'None';
|
|
2021
|
+
break;
|
|
2022
|
+
case PdfAnnotationState.accepted:
|
|
2023
|
+
token = 'Accepted';
|
|
2024
|
+
break;
|
|
2025
|
+
case PdfAnnotationState.rejected:
|
|
2026
|
+
token = 'Rejected';
|
|
2027
|
+
break;
|
|
2028
|
+
case PdfAnnotationState.cancel:
|
|
2029
|
+
token = 'Cancelled';
|
|
2030
|
+
break;
|
|
2031
|
+
case PdfAnnotationState.completed:
|
|
2032
|
+
token = 'Completed';
|
|
2033
|
+
break;
|
|
2034
|
+
case PdfAnnotationState.marked:
|
|
2035
|
+
token = 'Marked';
|
|
2036
|
+
break;
|
|
2037
|
+
case PdfAnnotationState.unmarked:
|
|
2038
|
+
token = 'Unmarked';
|
|
2039
|
+
break;
|
|
2040
|
+
case PdfAnnotationState.unknown:
|
|
2041
|
+
token = 'Unknown';
|
|
2042
|
+
break;
|
|
2043
|
+
default:
|
|
2044
|
+
token = 'None';
|
|
2045
|
+
break;
|
|
2046
|
+
}
|
|
2047
|
+
return token;
|
|
2048
|
+
}
|
|
2049
|
+
/**
|
|
2050
|
+
* Convert string value to annotation state.
|
|
2051
|
+
*
|
|
2052
|
+
* @private
|
|
2053
|
+
* @param {string} type String value.
|
|
2054
|
+
* @returns {PdfAnnotationState} Annotation state.
|
|
2055
|
+
*/
|
|
2056
|
+
export function _mapAnnotationState(type) {
|
|
2057
|
+
var token = PdfAnnotationState.none;
|
|
2058
|
+
switch (type) {
|
|
2059
|
+
case 'None':
|
|
2060
|
+
token = PdfAnnotationState.none;
|
|
2061
|
+
break;
|
|
2062
|
+
case 'Accepted':
|
|
2063
|
+
token = PdfAnnotationState.accepted;
|
|
2064
|
+
break;
|
|
2065
|
+
case 'Rejected':
|
|
2066
|
+
token = PdfAnnotationState.rejected;
|
|
2067
|
+
break;
|
|
2068
|
+
case 'Cancelled':
|
|
2069
|
+
token = PdfAnnotationState.cancel;
|
|
2070
|
+
break;
|
|
2071
|
+
case 'Completed':
|
|
2072
|
+
token = PdfAnnotationState.completed;
|
|
2073
|
+
break;
|
|
2074
|
+
case 'Marked':
|
|
2075
|
+
token = PdfAnnotationState.marked;
|
|
2076
|
+
break;
|
|
2077
|
+
case 'Unmarked':
|
|
2078
|
+
token = PdfAnnotationState.unmarked;
|
|
2079
|
+
break;
|
|
2080
|
+
case 'Unknown':
|
|
2081
|
+
token = PdfAnnotationState.unknown;
|
|
2082
|
+
break;
|
|
2083
|
+
}
|
|
2084
|
+
return token;
|
|
2085
|
+
}
|
|
2086
|
+
/**
|
|
2087
|
+
* Convert annotation state model to string value.
|
|
2088
|
+
*
|
|
2089
|
+
* @private
|
|
2090
|
+
* @param {PdfAnnotationStateModel} type Annotation state model.
|
|
2091
|
+
* @returns {string} String value.
|
|
2092
|
+
*/
|
|
2093
|
+
export function _reverseMapAnnotationStateModel(type) {
|
|
2094
|
+
var token = 'None';
|
|
2095
|
+
switch (type) {
|
|
2096
|
+
case PdfAnnotationStateModel.none:
|
|
2097
|
+
token = 'None';
|
|
2098
|
+
break;
|
|
2099
|
+
case PdfAnnotationStateModel.marked:
|
|
2100
|
+
token = 'Marked';
|
|
2101
|
+
break;
|
|
2102
|
+
case PdfAnnotationStateModel.review:
|
|
2103
|
+
token = 'Review';
|
|
2104
|
+
break;
|
|
2105
|
+
default:
|
|
2106
|
+
token = 'None';
|
|
2107
|
+
break;
|
|
2108
|
+
}
|
|
2109
|
+
return token;
|
|
2110
|
+
}
|
|
2111
|
+
/**
|
|
2112
|
+
* Convert string value to annotation state model.
|
|
2113
|
+
*
|
|
2114
|
+
* @private
|
|
2115
|
+
* @param {string} type String value.
|
|
2116
|
+
* @returns {PdfAnnotationStateModel} Annotation state model.
|
|
2117
|
+
*/
|
|
2118
|
+
export function _mapAnnotationStateModel(type) {
|
|
2119
|
+
var token = PdfAnnotationStateModel.none;
|
|
2120
|
+
switch (type) {
|
|
2121
|
+
case 'None':
|
|
2122
|
+
token = PdfAnnotationStateModel.none;
|
|
2123
|
+
break;
|
|
2124
|
+
case 'Marked':
|
|
2125
|
+
token = PdfAnnotationStateModel.marked;
|
|
2126
|
+
break;
|
|
2127
|
+
case 'Review':
|
|
2128
|
+
token = PdfAnnotationStateModel.review;
|
|
2129
|
+
break;
|
|
2130
|
+
}
|
|
2131
|
+
return token;
|
|
2132
|
+
}
|
|
2133
|
+
/**
|
|
2134
|
+
* Map attachment icon.
|
|
2135
|
+
*
|
|
2136
|
+
* @private
|
|
2137
|
+
* @param {string} iconString String value.
|
|
2138
|
+
* @returns {PdfAttachmentIcon} Icon.
|
|
2139
|
+
*/
|
|
2140
|
+
export function _mapAttachmentIcon(iconString) {
|
|
2141
|
+
var icon;
|
|
2142
|
+
switch (iconString) {
|
|
2143
|
+
case 'PushPin':
|
|
2144
|
+
icon = PdfAttachmentIcon.pushPin;
|
|
2145
|
+
break;
|
|
2146
|
+
case 'Tag':
|
|
2147
|
+
icon = PdfAttachmentIcon.tag;
|
|
2148
|
+
break;
|
|
2149
|
+
case 'Graph':
|
|
2150
|
+
icon = PdfAttachmentIcon.graph;
|
|
2151
|
+
break;
|
|
2152
|
+
case 'Paperclip':
|
|
2153
|
+
icon = PdfAttachmentIcon.paperClip;
|
|
2154
|
+
break;
|
|
2155
|
+
default:
|
|
2156
|
+
icon = PdfAttachmentIcon.pushPin;
|
|
2157
|
+
break;
|
|
2158
|
+
}
|
|
2159
|
+
return icon;
|
|
2160
|
+
}
|
|
2161
|
+
/**
|
|
2162
|
+
* Map attachment intent.
|
|
2163
|
+
*
|
|
2164
|
+
* @private
|
|
2165
|
+
* @param {string} intentString String value.
|
|
2166
|
+
* @returns {PdfAnnotationIntent} intent.
|
|
2167
|
+
*/
|
|
2168
|
+
export function _mapAnnotationIntent(intentString) {
|
|
2169
|
+
var intent;
|
|
2170
|
+
switch (intentString) {
|
|
2171
|
+
case 'None':
|
|
2172
|
+
intent = PdfAnnotationIntent.none;
|
|
2173
|
+
break;
|
|
2174
|
+
case 'FreeTextCallout':
|
|
2175
|
+
intent = PdfAnnotationIntent.freeTextCallout;
|
|
2176
|
+
break;
|
|
2177
|
+
case 'FreeTextTypeWriter':
|
|
2178
|
+
intent = PdfAnnotationIntent.freeTextTypeWriter;
|
|
2179
|
+
break;
|
|
2180
|
+
default:
|
|
2181
|
+
intent = PdfAnnotationIntent.none;
|
|
2182
|
+
break;
|
|
2183
|
+
}
|
|
2184
|
+
return intent;
|
|
2185
|
+
}
|
|
2186
|
+
/**
|
|
2187
|
+
* Convert PDF font style to string value.
|
|
2188
|
+
*
|
|
2189
|
+
* @private
|
|
2190
|
+
* @param {PdfFontStyle} style Font style.
|
|
2191
|
+
* @returns {string} String value.
|
|
2192
|
+
*/
|
|
2193
|
+
export function _reverseMapPdfFontStyle(style) {
|
|
2194
|
+
var value = '';
|
|
2195
|
+
switch (style) {
|
|
2196
|
+
case PdfFontStyle.regular:
|
|
2197
|
+
value = 'Regular';
|
|
2198
|
+
break;
|
|
2199
|
+
case PdfFontStyle.bold:
|
|
2200
|
+
value = 'Bold';
|
|
2201
|
+
break;
|
|
2202
|
+
case PdfFontStyle.italic:
|
|
2203
|
+
value = 'Italic';
|
|
2204
|
+
break;
|
|
2205
|
+
case PdfFontStyle.underline:
|
|
2206
|
+
value = 'Underline';
|
|
2207
|
+
break;
|
|
2208
|
+
case PdfFontStyle.strikeout:
|
|
2209
|
+
value = 'Strikeout';
|
|
2210
|
+
break;
|
|
2211
|
+
default:
|
|
2212
|
+
value = 'Regular';
|
|
2213
|
+
break;
|
|
2214
|
+
}
|
|
2215
|
+
return value;
|
|
2216
|
+
}
|
|
2217
|
+
/**
|
|
2218
|
+
* Get special character.
|
|
2219
|
+
*
|
|
2220
|
+
* @private
|
|
2221
|
+
* @param {string} input Input string.
|
|
2222
|
+
* @returns {string} String value.
|
|
2223
|
+
*/
|
|
2224
|
+
export function _getSpecialCharacter(input) {
|
|
2225
|
+
var result;
|
|
2226
|
+
switch (input) {
|
|
2227
|
+
case 'head2right':
|
|
2228
|
+
result = '\u27A2';
|
|
2229
|
+
break;
|
|
2230
|
+
case 'aacute':
|
|
2231
|
+
result = 'a\u0301';
|
|
2232
|
+
break;
|
|
2233
|
+
case 'eacute':
|
|
2234
|
+
result = 'e\u0301';
|
|
2235
|
+
break;
|
|
2236
|
+
case 'iacute':
|
|
2237
|
+
result = 'i\u0301';
|
|
2238
|
+
break;
|
|
2239
|
+
case 'oacute':
|
|
2240
|
+
result = 'o\u0301';
|
|
2241
|
+
break;
|
|
2242
|
+
case 'uacute':
|
|
2243
|
+
result = 'u\u0301';
|
|
2244
|
+
break;
|
|
2245
|
+
case 'circleright':
|
|
2246
|
+
result = '\u27B2';
|
|
2247
|
+
break;
|
|
2248
|
+
case 'bleft':
|
|
2249
|
+
result = '\u21E6';
|
|
2250
|
+
break;
|
|
2251
|
+
case 'bright':
|
|
2252
|
+
result = '\u21E8';
|
|
2253
|
+
break;
|
|
2254
|
+
case 'bup':
|
|
2255
|
+
result = '\u21E7';
|
|
2256
|
+
break;
|
|
2257
|
+
case 'bdown':
|
|
2258
|
+
result = '\u21E9';
|
|
2259
|
+
break;
|
|
2260
|
+
case 'barb4right':
|
|
2261
|
+
result = '\u2794';
|
|
2262
|
+
break;
|
|
2263
|
+
case 'bleftright':
|
|
2264
|
+
result = '\u2B04';
|
|
2265
|
+
break;
|
|
2266
|
+
case 'bupdown':
|
|
2267
|
+
result = '\u21F3';
|
|
2268
|
+
break;
|
|
2269
|
+
case 'bnw':
|
|
2270
|
+
result = '\u2B00';
|
|
2271
|
+
break;
|
|
2272
|
+
case 'bne':
|
|
2273
|
+
result = '\u2B01';
|
|
2274
|
+
break;
|
|
2275
|
+
case 'bsw':
|
|
2276
|
+
result = '\u2B03';
|
|
2277
|
+
break;
|
|
2278
|
+
case 'bse':
|
|
2279
|
+
result = '\u2B02';
|
|
2280
|
+
break;
|
|
2281
|
+
case 'bdash1':
|
|
2282
|
+
result = '\u25AD';
|
|
2283
|
+
break;
|
|
2284
|
+
case 'bdash2':
|
|
2285
|
+
result = '\u25AB';
|
|
2286
|
+
break;
|
|
2287
|
+
case 'xmarkbld':
|
|
2288
|
+
result = '\u2717';
|
|
2289
|
+
break;
|
|
2290
|
+
case 'checkbld':
|
|
2291
|
+
result = '\u2713';
|
|
2292
|
+
break;
|
|
2293
|
+
case 'boxxmarkbld':
|
|
2294
|
+
result = '\u2612';
|
|
2295
|
+
break;
|
|
2296
|
+
case 'boxcheckbld':
|
|
2297
|
+
result = '\u2611';
|
|
2298
|
+
break;
|
|
2299
|
+
case 'space':
|
|
2300
|
+
result = '\u0020';
|
|
2301
|
+
break;
|
|
2302
|
+
case 'pencil':
|
|
2303
|
+
result = '\u270F';
|
|
2304
|
+
break;
|
|
2305
|
+
case 'scissors':
|
|
2306
|
+
result = '\u2702';
|
|
2307
|
+
break;
|
|
2308
|
+
case 'scissorscutting':
|
|
2309
|
+
result = '\u2701';
|
|
2310
|
+
break;
|
|
2311
|
+
case 'readingglasses':
|
|
2312
|
+
result = '\u2701';
|
|
2313
|
+
break;
|
|
2314
|
+
case 'bell':
|
|
2315
|
+
result = '\u2701';
|
|
2316
|
+
break;
|
|
2317
|
+
case 'book':
|
|
2318
|
+
result = '\u2701';
|
|
2319
|
+
break;
|
|
2320
|
+
case 'telephonesolid':
|
|
2321
|
+
result = '\u2701';
|
|
2322
|
+
break;
|
|
2323
|
+
case 'telhandsetcirc':
|
|
2324
|
+
result = '\u2701';
|
|
2325
|
+
break;
|
|
2326
|
+
case 'envelopeback':
|
|
2327
|
+
result = '\u2701';
|
|
2328
|
+
break;
|
|
2329
|
+
case 'hourglass':
|
|
2330
|
+
result = '\u231B';
|
|
2331
|
+
break;
|
|
2332
|
+
case 'keyboard':
|
|
2333
|
+
result = '\u2328';
|
|
2334
|
+
break;
|
|
2335
|
+
case 'tapereel':
|
|
2336
|
+
result = '\u2707';
|
|
2337
|
+
break;
|
|
2338
|
+
case 'handwrite':
|
|
2339
|
+
result = '\u270D';
|
|
2340
|
+
break;
|
|
2341
|
+
case 'handv':
|
|
2342
|
+
result = '\u270C';
|
|
2343
|
+
break;
|
|
2344
|
+
case 'handptleft':
|
|
2345
|
+
result = '\u261C';
|
|
2346
|
+
break;
|
|
2347
|
+
case 'handptright':
|
|
2348
|
+
result = '\u261E';
|
|
2349
|
+
break;
|
|
2350
|
+
case 'handptup':
|
|
2351
|
+
result = '\u261D';
|
|
2352
|
+
break;
|
|
2353
|
+
case 'handptdown':
|
|
2354
|
+
result = '\u261F';
|
|
2355
|
+
break;
|
|
2356
|
+
case 'smileface':
|
|
2357
|
+
result = '\u263A';
|
|
2358
|
+
break;
|
|
2359
|
+
case 'frownface':
|
|
2360
|
+
result = '\u2639';
|
|
2361
|
+
break;
|
|
2362
|
+
case 'skullcrossbones':
|
|
2363
|
+
result = '\u2620';
|
|
2364
|
+
break;
|
|
2365
|
+
case 'flag':
|
|
2366
|
+
result = '\u2690';
|
|
2367
|
+
break;
|
|
2368
|
+
case 'pennant':
|
|
2369
|
+
result = '\u1F6A9';
|
|
2370
|
+
break;
|
|
2371
|
+
case 'airplane':
|
|
2372
|
+
result = '\u2708';
|
|
2373
|
+
break;
|
|
2374
|
+
case 'sunshine':
|
|
2375
|
+
result = '\u263C';
|
|
2376
|
+
break;
|
|
2377
|
+
case 'droplet':
|
|
2378
|
+
result = '\u1F4A7';
|
|
2379
|
+
break;
|
|
2380
|
+
case 'snowflake':
|
|
2381
|
+
result = '\u2744';
|
|
2382
|
+
break;
|
|
2383
|
+
case 'crossshadow':
|
|
2384
|
+
result = '\u271E';
|
|
2385
|
+
break;
|
|
2386
|
+
case 'crossmaltese':
|
|
2387
|
+
result = '\u2720';
|
|
2388
|
+
break;
|
|
2389
|
+
case 'starofdavid':
|
|
2390
|
+
result = '\u2721';
|
|
2391
|
+
break;
|
|
2392
|
+
case 'crescentstar':
|
|
2393
|
+
result = '\u262A';
|
|
2394
|
+
break;
|
|
2395
|
+
case 'yinyang':
|
|
2396
|
+
result = '\u262F';
|
|
2397
|
+
break;
|
|
2398
|
+
case 'om':
|
|
2399
|
+
result = '\u0950';
|
|
2400
|
+
break;
|
|
2401
|
+
case 'wheel':
|
|
2402
|
+
result = '\u2638';
|
|
2403
|
+
break;
|
|
2404
|
+
case 'aries':
|
|
2405
|
+
result = '\u2648';
|
|
2406
|
+
break;
|
|
2407
|
+
case 'taurus':
|
|
2408
|
+
result = '\u2649';
|
|
2409
|
+
break;
|
|
2410
|
+
case 'gemini':
|
|
2411
|
+
result = '\u264A';
|
|
2412
|
+
break;
|
|
2413
|
+
case 'cancer':
|
|
2414
|
+
result = '\u264B';
|
|
2415
|
+
break;
|
|
2416
|
+
case 'leo':
|
|
2417
|
+
result = '\u264C';
|
|
2418
|
+
break;
|
|
2419
|
+
case 'virgo':
|
|
2420
|
+
result = '\u264D';
|
|
2421
|
+
break;
|
|
2422
|
+
case 'libra':
|
|
2423
|
+
result = '\u264E';
|
|
2424
|
+
break;
|
|
2425
|
+
case 'scorpio':
|
|
2426
|
+
result = '\u264F';
|
|
2427
|
+
break;
|
|
2428
|
+
case 'saggitarius':
|
|
2429
|
+
result = '\u2650';
|
|
2430
|
+
break;
|
|
2431
|
+
case 'capricorn':
|
|
2432
|
+
result = '\u2651';
|
|
2433
|
+
break;
|
|
2434
|
+
case 'aquarius':
|
|
2435
|
+
result = '\u2652';
|
|
2436
|
+
break;
|
|
2437
|
+
case 'pisces':
|
|
2438
|
+
result = '\u2653';
|
|
2439
|
+
break;
|
|
2440
|
+
case 'ampersanditlc':
|
|
2441
|
+
result = '\u0026';
|
|
2442
|
+
break;
|
|
2443
|
+
case 'ampersandit':
|
|
2444
|
+
result = '\u0026';
|
|
2445
|
+
break;
|
|
2446
|
+
case 'circle6':
|
|
2447
|
+
result = '\u25CF';
|
|
2448
|
+
break;
|
|
2449
|
+
case 'circleshadowdwn':
|
|
2450
|
+
result = '\u274D';
|
|
2451
|
+
break;
|
|
2452
|
+
case 'square6':
|
|
2453
|
+
result = '\u25A0';
|
|
2454
|
+
break;
|
|
2455
|
+
case 'box3':
|
|
2456
|
+
result = '\u25A1';
|
|
2457
|
+
break;
|
|
2458
|
+
case 'boxshadowdwn':
|
|
2459
|
+
result = '\u2751';
|
|
2460
|
+
break;
|
|
2461
|
+
case 'boxshadowup':
|
|
2462
|
+
result = '\u2752';
|
|
2463
|
+
break;
|
|
2464
|
+
case 'lozenge4':
|
|
2465
|
+
result = '\u2B27';
|
|
2466
|
+
break;
|
|
2467
|
+
case 'lozenge6':
|
|
2468
|
+
result = '\u29EB';
|
|
2469
|
+
break;
|
|
2470
|
+
case 'rhombus6':
|
|
2471
|
+
result = '\u25C6';
|
|
2472
|
+
break;
|
|
2473
|
+
case 'xrhombus':
|
|
2474
|
+
result = '\u2756';
|
|
2475
|
+
break;
|
|
2476
|
+
case 'rhombus4':
|
|
2477
|
+
result = '\u2B25';
|
|
2478
|
+
break;
|
|
2479
|
+
case 'clear':
|
|
2480
|
+
result = '\u2327';
|
|
2481
|
+
break;
|
|
2482
|
+
case 'escape':
|
|
2483
|
+
result = '\u2353';
|
|
2484
|
+
break;
|
|
2485
|
+
case 'command':
|
|
2486
|
+
result = '\u2318';
|
|
2487
|
+
break;
|
|
2488
|
+
case 'rosette':
|
|
2489
|
+
result = '\u2740';
|
|
2490
|
+
break;
|
|
2491
|
+
case 'rosettesolid':
|
|
2492
|
+
result = '\u273F';
|
|
2493
|
+
break;
|
|
2494
|
+
case 'quotedbllftbld':
|
|
2495
|
+
result = '\u275D';
|
|
2496
|
+
break;
|
|
2497
|
+
case 'quotedblrtbld':
|
|
2498
|
+
result = '\u275E';
|
|
2499
|
+
break;
|
|
2500
|
+
case '.notdef':
|
|
2501
|
+
result = '\u25AF';
|
|
2502
|
+
break;
|
|
2503
|
+
case 'zerosans':
|
|
2504
|
+
result = '\u24EA';
|
|
2505
|
+
break;
|
|
2506
|
+
case 'onesans':
|
|
2507
|
+
result = '\u2460';
|
|
2508
|
+
break;
|
|
2509
|
+
case 'twosans':
|
|
2510
|
+
result = '\u2461';
|
|
2511
|
+
break;
|
|
2512
|
+
case 'threesans':
|
|
2513
|
+
result = '\u2462';
|
|
2514
|
+
break;
|
|
2515
|
+
case 'foursans':
|
|
2516
|
+
result = '\u2463';
|
|
2517
|
+
break;
|
|
2518
|
+
case 'fivesans':
|
|
2519
|
+
result = '\u2464';
|
|
2520
|
+
break;
|
|
2521
|
+
case 'sixsans':
|
|
2522
|
+
result = '\u2465';
|
|
2523
|
+
break;
|
|
2524
|
+
case 'sevensans':
|
|
2525
|
+
result = '\u2466';
|
|
2526
|
+
break;
|
|
2527
|
+
case 'eightsans':
|
|
2528
|
+
result = '\u2467';
|
|
2529
|
+
break;
|
|
2530
|
+
case 'ninesans':
|
|
2531
|
+
result = '\u2468';
|
|
2532
|
+
break;
|
|
2533
|
+
case 'tensans':
|
|
2534
|
+
result = '\u2469';
|
|
2535
|
+
break;
|
|
2536
|
+
case 'zerosansinv':
|
|
2537
|
+
result = '\u24FF';
|
|
2538
|
+
break;
|
|
2539
|
+
case 'onesansinv':
|
|
2540
|
+
result = '\u2776';
|
|
2541
|
+
break;
|
|
2542
|
+
case 'twosansinv':
|
|
2543
|
+
result = '\u2777';
|
|
2544
|
+
break;
|
|
2545
|
+
case 'threesansinv':
|
|
2546
|
+
result = '\u2778';
|
|
2547
|
+
break;
|
|
2548
|
+
case 'foursansinv':
|
|
2549
|
+
result = '\u2779';
|
|
2550
|
+
break;
|
|
2551
|
+
case 'circle2':
|
|
2552
|
+
result = '\u00B7';
|
|
2553
|
+
break;
|
|
2554
|
+
case 'circle4':
|
|
2555
|
+
result = '\u2022';
|
|
2556
|
+
break;
|
|
2557
|
+
case 'square2':
|
|
2558
|
+
result = '\u25AA';
|
|
2559
|
+
break;
|
|
2560
|
+
case 'ring2':
|
|
2561
|
+
result = '\u25CB';
|
|
2562
|
+
break;
|
|
2563
|
+
case 'ringbutton2':
|
|
2564
|
+
result = '\u25C9';
|
|
2565
|
+
break;
|
|
2566
|
+
case 'target':
|
|
2567
|
+
result = '\u25CE';
|
|
2568
|
+
break;
|
|
2569
|
+
case 'square4':
|
|
2570
|
+
result = '\u25AA';
|
|
2571
|
+
break;
|
|
2572
|
+
case 'box2':
|
|
2573
|
+
result = '\u25FB';
|
|
2574
|
+
break;
|
|
2575
|
+
case 'crosstar2':
|
|
2576
|
+
result = '\u2726';
|
|
2577
|
+
break;
|
|
2578
|
+
case 'pentastar2':
|
|
2579
|
+
result = '\u2605';
|
|
2580
|
+
break;
|
|
2581
|
+
case 'hexstar2':
|
|
2582
|
+
result = '\u2736';
|
|
2583
|
+
break;
|
|
2584
|
+
case 'octastar2':
|
|
2585
|
+
result = '\u2734';
|
|
2586
|
+
break;
|
|
2587
|
+
case 'dodecastar3':
|
|
2588
|
+
result = '\u2739';
|
|
2589
|
+
break;
|
|
2590
|
+
case 'octastar4':
|
|
2591
|
+
result = '\u2735';
|
|
2592
|
+
break;
|
|
2593
|
+
case 'registercircle':
|
|
2594
|
+
result = '\u2316';
|
|
2595
|
+
break;
|
|
2596
|
+
case 'cuspopen':
|
|
2597
|
+
result = '\u27E1';
|
|
2598
|
+
break;
|
|
2599
|
+
case 'cuspopen1':
|
|
2600
|
+
result = '\u2311';
|
|
2601
|
+
break;
|
|
2602
|
+
case 'circlestar':
|
|
2603
|
+
result = '\u2605';
|
|
2604
|
+
break;
|
|
2605
|
+
case 'starshadow':
|
|
2606
|
+
result = '\u2730';
|
|
2607
|
+
break;
|
|
2608
|
+
case 'deleteleft':
|
|
2609
|
+
result = '\u232B';
|
|
2610
|
+
break;
|
|
2611
|
+
case 'deleteright':
|
|
2612
|
+
result = '\u2326';
|
|
2613
|
+
break;
|
|
2614
|
+
case 'scissorsoutline':
|
|
2615
|
+
result = '\u2704';
|
|
2616
|
+
break;
|
|
2617
|
+
case 'telephone':
|
|
2618
|
+
result = '\u260F';
|
|
2619
|
+
break;
|
|
2620
|
+
case 'telhandset':
|
|
2621
|
+
result = '\u1F4DE';
|
|
2622
|
+
break;
|
|
2623
|
+
case 'handptlft1':
|
|
2624
|
+
result = '\u261C';
|
|
2625
|
+
break;
|
|
2626
|
+
case 'handptrt1':
|
|
2627
|
+
result = '\u261E';
|
|
2628
|
+
break;
|
|
2629
|
+
case 'handptlftsld1':
|
|
2630
|
+
result = '\u261A';
|
|
2631
|
+
break;
|
|
2632
|
+
case 'handptrtsld1':
|
|
2633
|
+
result = '\u261B';
|
|
2634
|
+
break;
|
|
2635
|
+
case 'handptup1':
|
|
2636
|
+
result = '\u261D';
|
|
2637
|
+
break;
|
|
2638
|
+
case 'handptdwn1':
|
|
2639
|
+
result = '\u261F';
|
|
2640
|
+
break;
|
|
2641
|
+
case 'xmark':
|
|
2642
|
+
result = '\u2717';
|
|
2643
|
+
break;
|
|
2644
|
+
case 'check':
|
|
2645
|
+
result = '\u2713';
|
|
2646
|
+
break;
|
|
2647
|
+
case 'boxcheck':
|
|
2648
|
+
result = '\u2611';
|
|
2649
|
+
break;
|
|
2650
|
+
case 'boxx':
|
|
2651
|
+
result = '\u2612';
|
|
2652
|
+
break;
|
|
2653
|
+
case 'boxxbld':
|
|
2654
|
+
result = '\u2612';
|
|
2655
|
+
break;
|
|
2656
|
+
case 'circlex':
|
|
2657
|
+
result = '=\u2314';
|
|
2658
|
+
break;
|
|
2659
|
+
case 'circlexbld':
|
|
2660
|
+
result = '\u2314';
|
|
2661
|
+
break;
|
|
2662
|
+
case 'prohibit':
|
|
2663
|
+
case 'prohibitbld':
|
|
2664
|
+
result = '\u29B8';
|
|
2665
|
+
break;
|
|
2666
|
+
case 'ampersanditaldm':
|
|
2667
|
+
case 'ampersandbld':
|
|
2668
|
+
case 'ampersandsans':
|
|
2669
|
+
case 'ampersandsandm':
|
|
2670
|
+
result = '\u0026';
|
|
2671
|
+
break;
|
|
2672
|
+
case 'interrobang':
|
|
2673
|
+
case 'interrobangdm':
|
|
2674
|
+
case 'interrobangsans':
|
|
2675
|
+
case 'interrobngsandm':
|
|
2676
|
+
result = '\u203D';
|
|
2677
|
+
break;
|
|
2678
|
+
case 'sacute':
|
|
2679
|
+
result = 'ś';
|
|
2680
|
+
break;
|
|
2681
|
+
case 'Sacute':
|
|
2682
|
+
result = 'Ś';
|
|
2683
|
+
break;
|
|
2684
|
+
case 'eogonek':
|
|
2685
|
+
result = 'ę';
|
|
2686
|
+
break;
|
|
2687
|
+
case 'cacute':
|
|
2688
|
+
result = 'ć';
|
|
2689
|
+
break;
|
|
2690
|
+
case 'aogonek':
|
|
2691
|
+
result = 'ą';
|
|
2692
|
+
break;
|
|
2693
|
+
default:
|
|
2694
|
+
result = input;
|
|
2695
|
+
break;
|
|
2696
|
+
}
|
|
2697
|
+
return result;
|
|
2698
|
+
}
|
|
2699
|
+
/**
|
|
2700
|
+
* Get latin character.
|
|
2701
|
+
*
|
|
2702
|
+
* @private
|
|
2703
|
+
* @param {string} input Input string.
|
|
2704
|
+
* @returns {string} String value.
|
|
2705
|
+
*/
|
|
2706
|
+
export function _getLatinCharacter(input) {
|
|
2707
|
+
var result;
|
|
2708
|
+
switch (input) {
|
|
2709
|
+
case 'zero':
|
|
2710
|
+
result = '0';
|
|
2711
|
+
break;
|
|
2712
|
+
case 'one':
|
|
2713
|
+
result = '1';
|
|
2714
|
+
break;
|
|
2715
|
+
case 'two':
|
|
2716
|
+
result = '2';
|
|
2717
|
+
break;
|
|
2718
|
+
case 'three':
|
|
2719
|
+
result = '3';
|
|
2720
|
+
break;
|
|
2721
|
+
case 'four':
|
|
2722
|
+
result = '4';
|
|
2723
|
+
break;
|
|
2724
|
+
case 'five':
|
|
2725
|
+
result = '5';
|
|
2726
|
+
break;
|
|
2727
|
+
case 'six':
|
|
2728
|
+
result = '6';
|
|
2729
|
+
break;
|
|
2730
|
+
case 'seven':
|
|
2731
|
+
result = '7';
|
|
2732
|
+
break;
|
|
2733
|
+
case 'eight':
|
|
2734
|
+
result = '8';
|
|
2735
|
+
break;
|
|
2736
|
+
case 'nine':
|
|
2737
|
+
result = '9';
|
|
2738
|
+
break;
|
|
2739
|
+
case 'aacute':
|
|
2740
|
+
result = 'á';
|
|
2741
|
+
break;
|
|
2742
|
+
case 'asciicircum':
|
|
2743
|
+
result = '^';
|
|
2744
|
+
break;
|
|
2745
|
+
case 'asciitilde':
|
|
2746
|
+
result = '~';
|
|
2747
|
+
break;
|
|
2748
|
+
case 'asterisk':
|
|
2749
|
+
result = '*';
|
|
2750
|
+
break;
|
|
2751
|
+
case 'at':
|
|
2752
|
+
result = '@';
|
|
2753
|
+
break;
|
|
2754
|
+
case 'atilde':
|
|
2755
|
+
result = 'ã';
|
|
2756
|
+
break;
|
|
2757
|
+
case 'backslash':
|
|
2758
|
+
result = '\\';
|
|
2759
|
+
break;
|
|
2760
|
+
case 'bar':
|
|
2761
|
+
result = '|';
|
|
2762
|
+
break;
|
|
2763
|
+
case 'braceleft':
|
|
2764
|
+
result = '{';
|
|
2765
|
+
break;
|
|
2766
|
+
case 'braceright':
|
|
2767
|
+
result = '}';
|
|
2768
|
+
break;
|
|
2769
|
+
case 'bracketleft':
|
|
2770
|
+
result = '[';
|
|
2771
|
+
break;
|
|
2772
|
+
case 'bracketright':
|
|
2773
|
+
result = ']';
|
|
2774
|
+
break;
|
|
2775
|
+
case 'breve':
|
|
2776
|
+
result = '˘';
|
|
2777
|
+
break;
|
|
2778
|
+
case 'brokenbar':
|
|
2779
|
+
result = '|';
|
|
2780
|
+
break;
|
|
2781
|
+
case 'bullet3':
|
|
2782
|
+
result = '•';
|
|
2783
|
+
break;
|
|
2784
|
+
case 'bullet':
|
|
2785
|
+
result = '•';
|
|
2786
|
+
break;
|
|
2787
|
+
case 'caron':
|
|
2788
|
+
result = 'ˇ';
|
|
2789
|
+
break;
|
|
2790
|
+
case 'ccedilla':
|
|
2791
|
+
result = 'ç';
|
|
2792
|
+
break;
|
|
2793
|
+
case 'cedilla':
|
|
2794
|
+
result = '¸';
|
|
2795
|
+
break;
|
|
2796
|
+
case 'cent':
|
|
2797
|
+
result = '¢';
|
|
2798
|
+
break;
|
|
2799
|
+
case 'circumflex':
|
|
2800
|
+
result = 'ˆ';
|
|
2801
|
+
break;
|
|
2802
|
+
case 'colon':
|
|
2803
|
+
result = ':';
|
|
2804
|
+
break;
|
|
2805
|
+
case 'comma':
|
|
2806
|
+
result = ',';
|
|
2807
|
+
break;
|
|
2808
|
+
case 'copyright':
|
|
2809
|
+
result = '©';
|
|
2810
|
+
break;
|
|
2811
|
+
case 'currency1':
|
|
2812
|
+
result = '¤';
|
|
2813
|
+
break;
|
|
2814
|
+
case 'dagger':
|
|
2815
|
+
result = '†';
|
|
2816
|
+
break;
|
|
2817
|
+
case 'daggerdbl':
|
|
2818
|
+
result = '‡';
|
|
2819
|
+
break;
|
|
2820
|
+
case 'degree':
|
|
2821
|
+
result = '°';
|
|
2822
|
+
break;
|
|
2823
|
+
case 'dieresis':
|
|
2824
|
+
result = '¨';
|
|
2825
|
+
break;
|
|
2826
|
+
case 'divide':
|
|
2827
|
+
result = '÷';
|
|
2828
|
+
break;
|
|
2829
|
+
case 'dollar':
|
|
2830
|
+
result = '$';
|
|
2831
|
+
break;
|
|
2832
|
+
case 'dotaccent':
|
|
2833
|
+
result = '˙';
|
|
2834
|
+
break;
|
|
2835
|
+
case 'dotlessi':
|
|
2836
|
+
result = 'ı';
|
|
2837
|
+
break;
|
|
2838
|
+
case 'eacute':
|
|
2839
|
+
result = 'é';
|
|
2840
|
+
break;
|
|
2841
|
+
case 'middot':
|
|
2842
|
+
result = '˙';
|
|
2843
|
+
break;
|
|
2844
|
+
case 'edieresis':
|
|
2845
|
+
result = 'ë';
|
|
2846
|
+
break;
|
|
2847
|
+
case 'egrave':
|
|
2848
|
+
result = 'è';
|
|
2849
|
+
break;
|
|
2850
|
+
case 'ellipsis':
|
|
2851
|
+
result = '...';
|
|
2852
|
+
break;
|
|
2853
|
+
case 'emdash':
|
|
2854
|
+
result = '—';
|
|
2855
|
+
break;
|
|
2856
|
+
case 'endash':
|
|
2857
|
+
result = '–';
|
|
2858
|
+
break;
|
|
2859
|
+
case 'equal':
|
|
2860
|
+
result = '=';
|
|
2861
|
+
break;
|
|
2862
|
+
case 'eth':
|
|
2863
|
+
result = 'ð';
|
|
2864
|
+
break;
|
|
2865
|
+
case 'exclam':
|
|
2866
|
+
result = '!';
|
|
2867
|
+
break;
|
|
2868
|
+
case 'exclamdown':
|
|
2869
|
+
result = '¡';
|
|
2870
|
+
break;
|
|
2871
|
+
case 'florin':
|
|
2872
|
+
result = 'ƒ';
|
|
2873
|
+
break;
|
|
2874
|
+
case 'fraction':
|
|
2875
|
+
result = '⁄';
|
|
2876
|
+
break;
|
|
2877
|
+
case 'germandbls':
|
|
2878
|
+
result = 'ß';
|
|
2879
|
+
break;
|
|
2880
|
+
case 'grave':
|
|
2881
|
+
result = '`';
|
|
2882
|
+
break;
|
|
2883
|
+
case 'greater':
|
|
2884
|
+
result = '>';
|
|
2885
|
+
break;
|
|
2886
|
+
case 'guillemotleft4':
|
|
2887
|
+
result = '«';
|
|
2888
|
+
break;
|
|
2889
|
+
case 'guillemotright4':
|
|
2890
|
+
result = '»';
|
|
2891
|
+
break;
|
|
2892
|
+
case 'guilsinglleft':
|
|
2893
|
+
result = '‹';
|
|
2894
|
+
break;
|
|
2895
|
+
case 'guilsinglright':
|
|
2896
|
+
result = '›';
|
|
2897
|
+
break;
|
|
2898
|
+
case 'hungarumlaut':
|
|
2899
|
+
result = '˝';
|
|
2900
|
+
break;
|
|
2901
|
+
case 'hyphen5':
|
|
2902
|
+
result = '-';
|
|
2903
|
+
break;
|
|
2904
|
+
case 'iacute':
|
|
2905
|
+
result = 'í';
|
|
2906
|
+
break;
|
|
2907
|
+
case 'icircumflex':
|
|
2908
|
+
result = 'î';
|
|
2909
|
+
break;
|
|
2910
|
+
case 'idieresis':
|
|
2911
|
+
result = 'ï';
|
|
2912
|
+
break;
|
|
2913
|
+
case 'igrave':
|
|
2914
|
+
result = 'ì';
|
|
2915
|
+
break;
|
|
2916
|
+
case 'less':
|
|
2917
|
+
result = '<';
|
|
2918
|
+
break;
|
|
2919
|
+
case 'logicalnot':
|
|
2920
|
+
result = '¬';
|
|
2921
|
+
break;
|
|
2922
|
+
case 'lslash':
|
|
2923
|
+
result = 'ł';
|
|
2924
|
+
break;
|
|
2925
|
+
case 'Lslash':
|
|
2926
|
+
result = 'Ł';
|
|
2927
|
+
break;
|
|
2928
|
+
case 'macron':
|
|
2929
|
+
result = '¯';
|
|
2930
|
+
break;
|
|
2931
|
+
case 'minus':
|
|
2932
|
+
result = '−';
|
|
2933
|
+
break;
|
|
2934
|
+
case 'mu':
|
|
2935
|
+
result = 'μ';
|
|
2936
|
+
break;
|
|
2937
|
+
case 'multiply':
|
|
2938
|
+
result = '×';
|
|
2939
|
+
break;
|
|
2940
|
+
case 'ntilde':
|
|
2941
|
+
result = 'ñ';
|
|
2942
|
+
break;
|
|
2943
|
+
case 'numbersign':
|
|
2944
|
+
result = '#';
|
|
2945
|
+
break;
|
|
2946
|
+
case 'oacute':
|
|
2947
|
+
result = 'ó';
|
|
2948
|
+
break;
|
|
2949
|
+
case 'ocircumflex':
|
|
2950
|
+
result = 'ô';
|
|
2951
|
+
break;
|
|
2952
|
+
case 'odieresis':
|
|
2953
|
+
result = 'ö';
|
|
2954
|
+
break;
|
|
2955
|
+
case 'oe':
|
|
2956
|
+
result = 'oe';
|
|
2957
|
+
break;
|
|
2958
|
+
case 'ogonek':
|
|
2959
|
+
result = '˛';
|
|
2960
|
+
break;
|
|
2961
|
+
case 'ograve':
|
|
2962
|
+
result = 'ò';
|
|
2963
|
+
break;
|
|
2964
|
+
case 'onehalf':
|
|
2965
|
+
result = '1/2';
|
|
2966
|
+
break;
|
|
2967
|
+
case 'onequarter':
|
|
2968
|
+
result = '1/4';
|
|
2969
|
+
break;
|
|
2970
|
+
case 'onesuperior':
|
|
2971
|
+
result = '¹';
|
|
2972
|
+
break;
|
|
2973
|
+
case 'ordfeminine':
|
|
2974
|
+
result = 'ª';
|
|
2975
|
+
break;
|
|
2976
|
+
case 'ordmasculine':
|
|
2977
|
+
result = 'º';
|
|
2978
|
+
break;
|
|
2979
|
+
case 'otilde':
|
|
2980
|
+
result = 'õ';
|
|
2981
|
+
break;
|
|
2982
|
+
case 'paragraph':
|
|
2983
|
+
result = '¶';
|
|
2984
|
+
break;
|
|
2985
|
+
case 'parenleft':
|
|
2986
|
+
result = '(';
|
|
2987
|
+
break;
|
|
2988
|
+
case 'parenright':
|
|
2989
|
+
result = ')';
|
|
2990
|
+
break;
|
|
2991
|
+
case 'percent':
|
|
2992
|
+
result = '%';
|
|
2993
|
+
break;
|
|
2994
|
+
case 'period':
|
|
2995
|
+
result = '.';
|
|
2996
|
+
break;
|
|
2997
|
+
case 'periodcentered':
|
|
2998
|
+
result = '·';
|
|
2999
|
+
break;
|
|
3000
|
+
case 'perthousand':
|
|
3001
|
+
result = '‰';
|
|
3002
|
+
break;
|
|
3003
|
+
case 'plus':
|
|
3004
|
+
result = '+';
|
|
3005
|
+
break;
|
|
3006
|
+
case 'plusminus':
|
|
3007
|
+
result = '±';
|
|
3008
|
+
break;
|
|
3009
|
+
case 'question':
|
|
3010
|
+
result = '?';
|
|
3011
|
+
break;
|
|
3012
|
+
case 'questiondown':
|
|
3013
|
+
result = '¿';
|
|
3014
|
+
break;
|
|
3015
|
+
case 'quotedbl':
|
|
3016
|
+
result = '\'';
|
|
3017
|
+
break;
|
|
3018
|
+
case 'quotedblbase':
|
|
3019
|
+
result = '„';
|
|
3020
|
+
break;
|
|
3021
|
+
case 'quotedblleft':
|
|
3022
|
+
result = '“';
|
|
3023
|
+
break;
|
|
3024
|
+
case 'quotedblright':
|
|
3025
|
+
result = '”';
|
|
3026
|
+
break;
|
|
3027
|
+
case 'quoteleft':
|
|
3028
|
+
result = '‘';
|
|
3029
|
+
break;
|
|
3030
|
+
case 'quoteright':
|
|
3031
|
+
result = '’';
|
|
3032
|
+
break;
|
|
3033
|
+
case 'quotesinglbase':
|
|
3034
|
+
result = '‚';
|
|
3035
|
+
break;
|
|
3036
|
+
case 'quotesingle':
|
|
3037
|
+
result = '\'';
|
|
3038
|
+
break;
|
|
3039
|
+
case 'registered':
|
|
3040
|
+
result = '®';
|
|
3041
|
+
break;
|
|
3042
|
+
case 'ring':
|
|
3043
|
+
result = '˚';
|
|
3044
|
+
break;
|
|
3045
|
+
case 'scaron':
|
|
3046
|
+
result = 'š';
|
|
3047
|
+
break;
|
|
3048
|
+
case 'section':
|
|
3049
|
+
result = '§';
|
|
3050
|
+
break;
|
|
3051
|
+
case 'semicolon':
|
|
3052
|
+
result = ';';
|
|
3053
|
+
break;
|
|
3054
|
+
case 'slash':
|
|
3055
|
+
result = '/';
|
|
3056
|
+
break;
|
|
3057
|
+
case 'space6':
|
|
3058
|
+
result = ' ';
|
|
3059
|
+
break;
|
|
3060
|
+
case 'space':
|
|
3061
|
+
result = ' ';
|
|
3062
|
+
break;
|
|
3063
|
+
case 'udieresis':
|
|
3064
|
+
result = 'ü';
|
|
3065
|
+
break;
|
|
3066
|
+
case 'uacute':
|
|
3067
|
+
result = 'ú';
|
|
3068
|
+
break;
|
|
3069
|
+
case 'Ecircumflex':
|
|
3070
|
+
result = 'Ê';
|
|
3071
|
+
break;
|
|
3072
|
+
case 'hyphen':
|
|
3073
|
+
result = '-';
|
|
3074
|
+
break;
|
|
3075
|
+
case 'underscore':
|
|
3076
|
+
result = '_';
|
|
3077
|
+
break;
|
|
3078
|
+
case 'adieresis':
|
|
3079
|
+
result = 'ä';
|
|
3080
|
+
break;
|
|
3081
|
+
case 'ampersand':
|
|
3082
|
+
result = '&';
|
|
3083
|
+
break;
|
|
3084
|
+
case 'Adieresis':
|
|
3085
|
+
result = 'Ä';
|
|
3086
|
+
break;
|
|
3087
|
+
case 'Udieresis':
|
|
3088
|
+
result = 'Ü';
|
|
3089
|
+
break;
|
|
3090
|
+
case 'ccaron':
|
|
3091
|
+
result = 'č';
|
|
3092
|
+
break;
|
|
3093
|
+
case 'Scaron':
|
|
3094
|
+
result = 'Š';
|
|
3095
|
+
break;
|
|
3096
|
+
case 'zcaron':
|
|
3097
|
+
result = 'ž';
|
|
3098
|
+
break;
|
|
3099
|
+
case 'sterling':
|
|
3100
|
+
result = '£';
|
|
3101
|
+
break;
|
|
3102
|
+
case 'agrave':
|
|
3103
|
+
result = 'à';
|
|
3104
|
+
break;
|
|
3105
|
+
case 'ecircumflex':
|
|
3106
|
+
result = 'ê';
|
|
3107
|
+
break;
|
|
3108
|
+
case 'acircumflex':
|
|
3109
|
+
result = 'â';
|
|
3110
|
+
break;
|
|
3111
|
+
case 'Oacute':
|
|
3112
|
+
result = 'Ó';
|
|
3113
|
+
break;
|
|
3114
|
+
default:
|
|
3115
|
+
result = input;
|
|
3116
|
+
break;
|
|
3117
|
+
}
|
|
3118
|
+
return result;
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Encode value to string.
|
|
3122
|
+
*
|
|
3123
|
+
* @private
|
|
3124
|
+
* @param {string} value Input string.
|
|
3125
|
+
* @returns {string} result.
|
|
3126
|
+
*/
|
|
3127
|
+
export function _encodeValue(value) {
|
|
3128
|
+
var name = '';
|
|
3129
|
+
for (var i = 0; i < value.length; i++) {
|
|
3130
|
+
var code = value.charCodeAt(i) & 0xff;
|
|
3131
|
+
var entry = String.fromCharCode(code);
|
|
3132
|
+
var hex = '';
|
|
3133
|
+
switch (entry) {
|
|
3134
|
+
case ' ':
|
|
3135
|
+
case '%':
|
|
3136
|
+
case '(':
|
|
3137
|
+
case ')':
|
|
3138
|
+
case '<':
|
|
3139
|
+
case '>':
|
|
3140
|
+
case '[':
|
|
3141
|
+
case ']':
|
|
3142
|
+
case '{':
|
|
3143
|
+
case '}':
|
|
3144
|
+
case '/':
|
|
3145
|
+
case '#':
|
|
3146
|
+
name += '#';
|
|
3147
|
+
hex = code.toString(16).toUpperCase();
|
|
3148
|
+
name += (hex.length === 1 ? ('0' + hex) : hex);
|
|
3149
|
+
break;
|
|
3150
|
+
default:
|
|
3151
|
+
if (code > 126 || code < 37) {
|
|
3152
|
+
name += '#';
|
|
3153
|
+
hex = code.toString(16).toUpperCase();
|
|
3154
|
+
name += (hex.length === 1 ? ('0' + hex) : hex);
|
|
3155
|
+
}
|
|
3156
|
+
else {
|
|
3157
|
+
name += entry;
|
|
3158
|
+
}
|
|
3159
|
+
break;
|
|
3160
|
+
}
|
|
3161
|
+
}
|
|
3162
|
+
return name;
|
|
3163
|
+
}
|
|
3164
|
+
/**
|
|
3165
|
+
* Parse and retrieve comments and review history from the annotation.
|
|
3166
|
+
*
|
|
3167
|
+
* @private
|
|
3168
|
+
* @param {PdfComment} annotation Input annotation.
|
|
3169
|
+
* @param {boolean} isReview Input is review or not.
|
|
3170
|
+
* @returns {PdfPopupAnnotationCollection} result.
|
|
3171
|
+
*/
|
|
3172
|
+
export function _getCommentsOrReview(annotation, isReview) {
|
|
3173
|
+
if (isReview) {
|
|
3174
|
+
return annotation.reviewHistory;
|
|
3175
|
+
}
|
|
3176
|
+
else {
|
|
3177
|
+
return annotation.comments;
|
|
3178
|
+
}
|
|
3179
|
+
}
|
|
3180
|
+
/**
|
|
3181
|
+
* Returns true if input dictionary is belongs to the review history.
|
|
3182
|
+
*
|
|
3183
|
+
* @private
|
|
3184
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
3185
|
+
* @returns {boolean} Input is review or not.
|
|
3186
|
+
*/
|
|
3187
|
+
export function _checkReview(dictionary) {
|
|
3188
|
+
var flag = dictionary.get('F');
|
|
3189
|
+
return ((dictionary.has('State') || dictionary.has('StateModel')) && (flag === 30 || flag === 128));
|
|
3190
|
+
}
|
|
3191
|
+
/**
|
|
3192
|
+
* Returns true if input dictionary is belongs to the comments.
|
|
3193
|
+
*
|
|
3194
|
+
* @private
|
|
3195
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
3196
|
+
* @returns {boolean} Input is comments or not.
|
|
3197
|
+
*/
|
|
3198
|
+
export function _checkComment(dictionary) {
|
|
3199
|
+
var flag = dictionary.get('F');
|
|
3200
|
+
return (!(dictionary.has('State') || dictionary.has('StateModel')) && (flag === 28 || flag === 128));
|
|
3201
|
+
}
|
|
3202
|
+
/**
|
|
3203
|
+
* Update visibility.
|
|
3204
|
+
*
|
|
3205
|
+
* @private
|
|
3206
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
3207
|
+
* @param {PdfFormFieldVisibility} value Visibility.
|
|
3208
|
+
* @returns {void} Nothing.
|
|
3209
|
+
*/
|
|
3210
|
+
export function _updateVisibility(dictionary, value) {
|
|
3211
|
+
if (dictionary.has('F')) {
|
|
3212
|
+
delete dictionary._map.F;
|
|
3213
|
+
dictionary._updated = true;
|
|
3214
|
+
}
|
|
3215
|
+
switch (value) {
|
|
3216
|
+
case PdfFormFieldVisibility.hidden:
|
|
3217
|
+
dictionary.update('F', PdfAnnotationFlag.hidden);
|
|
3218
|
+
break;
|
|
3219
|
+
case PdfFormFieldVisibility.hiddenPrintable:
|
|
3220
|
+
dictionary.update('F', (PdfAnnotationFlag.noView | PdfAnnotationFlag.print));
|
|
3221
|
+
break;
|
|
3222
|
+
case PdfFormFieldVisibility.visible:
|
|
3223
|
+
if (dictionary.has('DV')) {
|
|
3224
|
+
delete dictionary._map.DV;
|
|
3225
|
+
dictionary._updated = true;
|
|
3226
|
+
}
|
|
3227
|
+
if (dictionary.has('MK')) {
|
|
3228
|
+
var mkDict = dictionary.get('MK');
|
|
3229
|
+
if (mkDict && mkDict.has('BG')) {
|
|
3230
|
+
delete mkDict._map.BG;
|
|
3231
|
+
mkDict._updated = true;
|
|
3232
|
+
}
|
|
3233
|
+
}
|
|
3234
|
+
break;
|
|
3235
|
+
}
|
|
3236
|
+
}
|
|
3237
|
+
/**
|
|
3238
|
+
* Remove duplicate reference.
|
|
3239
|
+
*
|
|
3240
|
+
* @private
|
|
3241
|
+
* @param {_PdfDictionary} dictionary Input dictionary.
|
|
3242
|
+
* @param {_PdfCrossReference} crossTable Cross reference table.
|
|
3243
|
+
* @param {string} key Key string for appearance type.
|
|
3244
|
+
* @returns {void} Nothing.
|
|
3245
|
+
*/
|
|
3246
|
+
export function _removeDuplicateReference(dictionary, crossTable, key) {
|
|
3247
|
+
if (dictionary && dictionary.has(key)) {
|
|
3248
|
+
var oldAppearance = dictionary.getRaw(key);
|
|
3249
|
+
if (oldAppearance && oldAppearance instanceof _PdfReference && oldAppearance._isNew) {
|
|
3250
|
+
var appearance = dictionary.get(key); // eslint-disable-line
|
|
3251
|
+
if (appearance) {
|
|
3252
|
+
if (appearance instanceof _PdfReference) {
|
|
3253
|
+
appearance = crossTable._fetch(appearance);
|
|
3254
|
+
}
|
|
3255
|
+
var appearanceDictionary = void 0;
|
|
3256
|
+
if (appearance instanceof _PdfDictionary) {
|
|
3257
|
+
appearanceDictionary = appearance;
|
|
3258
|
+
}
|
|
3259
|
+
else if (appearance instanceof _PdfBaseStream) {
|
|
3260
|
+
appearanceDictionary = appearance.dictionary;
|
|
3261
|
+
}
|
|
3262
|
+
if (appearanceDictionary && appearanceDictionary.has('Resources')) {
|
|
3263
|
+
_removeDuplicateFromResources(appearanceDictionary.get('Resources'), crossTable);
|
|
3264
|
+
}
|
|
3265
|
+
}
|
|
3266
|
+
crossTable._cacheMap.delete(oldAppearance);
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3269
|
+
}
|
|
3270
|
+
/**
|
|
3271
|
+
* Remove duplicate reference from resources.
|
|
3272
|
+
*
|
|
3273
|
+
* @private
|
|
3274
|
+
* @param {_PdfDictionary} resources Input resources.
|
|
3275
|
+
* @param {_PdfCrossReference} crossTable Cross reference table.
|
|
3276
|
+
* @returns {void} Nothing.
|
|
3277
|
+
*/
|
|
3278
|
+
export function _removeDuplicateFromResources(resources, crossTable) {
|
|
3279
|
+
if (resources && resources.size > 0) {
|
|
3280
|
+
resources.forEach(function (key, value) {
|
|
3281
|
+
if (typeof key !== 'undefined' && typeof value !== 'undefined') {
|
|
3282
|
+
if (value instanceof _PdfReference) {
|
|
3283
|
+
var reference = value;
|
|
3284
|
+
if (reference._isNew) {
|
|
3285
|
+
var dictionary = resources.get(key);
|
|
3286
|
+
if (dictionary && dictionary instanceof _PdfDictionary) {
|
|
3287
|
+
if (key === 'XObject' && dictionary.has('Resources')) {
|
|
3288
|
+
_removeDuplicateFromResources(dictionary.get('Resources'), crossTable);
|
|
3289
|
+
}
|
|
3290
|
+
crossTable._cacheMap.delete(reference);
|
|
3291
|
+
}
|
|
3292
|
+
}
|
|
3293
|
+
}
|
|
3294
|
+
else if (value instanceof _PdfDictionary) {
|
|
3295
|
+
if (value.has('Resources')) {
|
|
3296
|
+
_removeDuplicateFromResources(value.get('Resources'), crossTable);
|
|
3297
|
+
}
|
|
3298
|
+
if (key === 'Font' || key === 'XObject' || key === 'ExtGState') {
|
|
3299
|
+
_removeDuplicateFromResources(value, crossTable);
|
|
3300
|
+
}
|
|
3301
|
+
}
|
|
3302
|
+
}
|
|
3303
|
+
});
|
|
3304
|
+
}
|
|
3305
|
+
}
|
|
3306
|
+
/**
|
|
3307
|
+
* Remove duplicate reference.
|
|
3308
|
+
*
|
|
3309
|
+
* @private
|
|
3310
|
+
* @param {any} normal Input.
|
|
3311
|
+
* @param {_PdfCrossReference} crossReference Cross reference table.
|
|
3312
|
+
* @param {string} firstKey Key string for appearance type.
|
|
3313
|
+
* @param {string} secondKey Key string for appearance type.
|
|
3314
|
+
* @returns {void} Nothing.
|
|
3315
|
+
*/
|
|
3316
|
+
export function _removeReferences(normal, crossReference, firstKey, secondKey) {
|
|
3317
|
+
var normalElement;
|
|
3318
|
+
if (normal) {
|
|
3319
|
+
if (normal instanceof _PdfDictionary) {
|
|
3320
|
+
normalElement = normal;
|
|
3321
|
+
}
|
|
3322
|
+
else if (normal instanceof _PdfStream) {
|
|
3323
|
+
normalElement = normal.dictionary;
|
|
3324
|
+
}
|
|
3325
|
+
}
|
|
3326
|
+
if (normalElement) {
|
|
3327
|
+
_removeDuplicateReference(normalElement, crossReference, firstKey);
|
|
3328
|
+
_removeDuplicateReference(normalElement, crossReference, secondKey);
|
|
3329
|
+
}
|
|
3330
|
+
}
|
|
3331
|
+
var BaseException = /** @class */ (function () {
|
|
3332
|
+
function BaseException(message, name) {
|
|
3333
|
+
this.message = message;
|
|
3334
|
+
this.name = name;
|
|
3335
|
+
}
|
|
3336
|
+
return BaseException;
|
|
3337
|
+
}());
|
|
3338
|
+
export { BaseException };
|
|
3339
|
+
var FormatError = /** @class */ (function (_super) {
|
|
3340
|
+
__extends(FormatError, _super);
|
|
3341
|
+
function FormatError(message) {
|
|
3342
|
+
return _super.call(this, message, 'FormatError') || this;
|
|
3343
|
+
}
|
|
3344
|
+
return FormatError;
|
|
3345
|
+
}(BaseException));
|
|
3346
|
+
export { FormatError };
|
|
3347
|
+
var ParserEndOfFileException = /** @class */ (function (_super) {
|
|
3348
|
+
__extends(ParserEndOfFileException, _super);
|
|
3349
|
+
function ParserEndOfFileException(message) {
|
|
3350
|
+
return _super.call(this, message, 'ParserEndOfFileException') || this;
|
|
3351
|
+
}
|
|
3352
|
+
return ParserEndOfFileException;
|
|
3353
|
+
}(BaseException));
|
|
3354
|
+
export { ParserEndOfFileException };
|
|
3355
|
+
/**
|
|
3356
|
+
* Gets the default string.
|
|
3357
|
+
*
|
|
3358
|
+
* @param {string} item Input string.
|
|
3359
|
+
* @returns {string} result.
|
|
3360
|
+
*/
|
|
3361
|
+
export function _defaultToString(item) {
|
|
3362
|
+
if (Object.prototype.toString.call(item) === '[object String]') {
|
|
3363
|
+
return '$s' + item;
|
|
3364
|
+
}
|
|
3365
|
+
else {
|
|
3366
|
+
return '$o' + item.toString();
|
|
3367
|
+
}
|
|
3368
|
+
}
|
|
3369
|
+
/**
|
|
3370
|
+
* Gets the form field font.
|
|
3371
|
+
*
|
|
3372
|
+
* @param {PdfForm} form form.
|
|
3373
|
+
* @param {PdfWidgetAnnotation} widget widget annotation.
|
|
3374
|
+
* @param {PdfField} field field.
|
|
3375
|
+
* @returns {PdfFont} font.
|
|
3376
|
+
*/
|
|
3377
|
+
export function _obtainFontDetails(form, widget, field) {
|
|
3378
|
+
var fontFamily = '';
|
|
3379
|
+
var fontSize;
|
|
3380
|
+
var font;
|
|
3381
|
+
var defaultAppearance;
|
|
3382
|
+
if (widget && widget._dictionary.has('DA') || field._dictionary.has('DA')) {
|
|
3383
|
+
if (widget && widget._dictionary.has('DA')) {
|
|
3384
|
+
defaultAppearance = widget._dictionary.get('DA');
|
|
3385
|
+
}
|
|
3386
|
+
else {
|
|
3387
|
+
defaultAppearance = field._dictionary.get('DA');
|
|
3388
|
+
}
|
|
3389
|
+
}
|
|
3390
|
+
if (defaultAppearance && defaultAppearance !== '' && defaultAppearance.indexOf('Tf') !== -1) {
|
|
3391
|
+
var textCollection = defaultAppearance.split(' ');
|
|
3392
|
+
for (var i = 0; i < textCollection.length; i++) {
|
|
3393
|
+
if (textCollection[Number.parseInt(i.toString(), 10)].indexOf('Tf') !== -1) {
|
|
3394
|
+
fontFamily = textCollection[i - 2];
|
|
3395
|
+
while (fontFamily !== '' && fontFamily.length > 1 && fontFamily[0] === '/') {
|
|
3396
|
+
fontFamily = fontFamily.substring(1);
|
|
3397
|
+
}
|
|
3398
|
+
fontSize = Number.parseFloat(textCollection[i - 1]);
|
|
3399
|
+
}
|
|
3400
|
+
}
|
|
3401
|
+
}
|
|
3402
|
+
if (fontFamily) {
|
|
3403
|
+
fontFamily = fontFamily.trim();
|
|
3404
|
+
}
|
|
3405
|
+
if (form && form._dictionary.has('DR')) {
|
|
3406
|
+
var resources = form._dictionary.get('DR');
|
|
3407
|
+
if (resources.has('Font')) {
|
|
3408
|
+
var fonts = resources.get('Font');
|
|
3409
|
+
if (fonts.has(fontFamily)) {
|
|
3410
|
+
var fontDictionary = fonts.get(fontFamily);
|
|
3411
|
+
if (fontDictionary && fontFamily && fontDictionary.has('BaseFont')) {
|
|
3412
|
+
var baseFont = fontDictionary.get('BaseFont');
|
|
3413
|
+
var textFontStyle = PdfFontStyle.regular;
|
|
3414
|
+
if (baseFont) {
|
|
3415
|
+
defaultAppearance = baseFont.name;
|
|
3416
|
+
textFontStyle = _getFontStyle(baseFont.name);
|
|
3417
|
+
if (defaultAppearance.includes('-')) {
|
|
3418
|
+
defaultAppearance = defaultAppearance.substring(0, defaultAppearance.indexOf('-'));
|
|
3419
|
+
}
|
|
3420
|
+
if (widget && widget._dictionary.has('DA')) {
|
|
3421
|
+
font = _mapFont(defaultAppearance, fontSize, textFontStyle, widget);
|
|
3422
|
+
}
|
|
3423
|
+
else if (field && field._dictionary.has('DA')) {
|
|
3424
|
+
font = _mapFont(defaultAppearance, fontSize, textFontStyle, field);
|
|
3425
|
+
}
|
|
3426
|
+
}
|
|
3427
|
+
}
|
|
3428
|
+
}
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
if ((font === null || typeof font === 'undefined') && fontSize) {
|
|
3432
|
+
font = new PdfStandardFont(PdfFontFamily.helvetica, fontSize, PdfFontStyle.regular);
|
|
3433
|
+
}
|
|
3434
|
+
if ((font === null || typeof font === 'undefined') || (font && font.size === 1)) {
|
|
3435
|
+
if (widget) {
|
|
3436
|
+
font = widget._circleCaptionFont;
|
|
3437
|
+
}
|
|
3438
|
+
else if (field) {
|
|
3439
|
+
font = field._circleCaptionFont;
|
|
3440
|
+
}
|
|
3441
|
+
}
|
|
3442
|
+
return font;
|
|
3443
|
+
}
|
|
3444
|
+
/**
|
|
3445
|
+
* Gets the font style.
|
|
3446
|
+
*
|
|
3447
|
+
* @param {string} fontFamilyString Font family string.
|
|
3448
|
+
* @returns {PdfFontStyle} result.
|
|
3449
|
+
*/
|
|
3450
|
+
export function _getFontStyle(fontFamilyString) {
|
|
3451
|
+
var position = fontFamilyString.indexOf('-');
|
|
3452
|
+
if (position < 0) {
|
|
3453
|
+
position = fontFamilyString.indexOf(',');
|
|
3454
|
+
}
|
|
3455
|
+
var style = PdfFontStyle.regular;
|
|
3456
|
+
if (position >= 0) {
|
|
3457
|
+
var standardName = fontFamilyString.substring(position + 1, fontFamilyString.length);
|
|
3458
|
+
switch (standardName) {
|
|
3459
|
+
case 'Bold':
|
|
3460
|
+
case 'BoldMT':
|
|
3461
|
+
style = PdfFontStyle.bold;
|
|
3462
|
+
break;
|
|
3463
|
+
case 'Italic':
|
|
3464
|
+
case 'ItalicMT':
|
|
3465
|
+
case 'Oblique':
|
|
3466
|
+
case 'It':
|
|
3467
|
+
style = PdfFontStyle.italic;
|
|
3468
|
+
break;
|
|
3469
|
+
case 'BoldItalic':
|
|
3470
|
+
case 'BoldItalicMT':
|
|
3471
|
+
case 'BoldOblique':
|
|
3472
|
+
style = PdfFontStyle.bold | PdfFontStyle.italic;
|
|
3473
|
+
break;
|
|
3474
|
+
}
|
|
3475
|
+
}
|
|
3476
|
+
return style;
|
|
3477
|
+
}
|
|
3478
|
+
/**
|
|
3479
|
+
* Map the font.
|
|
3480
|
+
*
|
|
3481
|
+
* @param {string} name Font name.
|
|
3482
|
+
* @param {number} size Font size.
|
|
3483
|
+
* @param {PdfFontStyle} style Font style.
|
|
3484
|
+
* @param {PdfAnnotation} annotation Annotation or Field.
|
|
3485
|
+
* @returns {PdfFont} result.
|
|
3486
|
+
*/
|
|
3487
|
+
export function _mapFont(name, size, style, annotation) {
|
|
3488
|
+
var font;
|
|
3489
|
+
var fontFamily = name ? name : '';
|
|
3490
|
+
if (fontFamily.includes('-')) {
|
|
3491
|
+
fontFamily = fontFamily.substring(0, fontFamily.indexOf('-'));
|
|
3492
|
+
}
|
|
3493
|
+
var fontSize = typeof size !== 'undefined' ? size : 1;
|
|
3494
|
+
if (annotation._dictionary.has('DS') || annotation._dictionary.has('DA')) {
|
|
3495
|
+
switch (fontFamily) {
|
|
3496
|
+
case 'Helvetica':
|
|
3497
|
+
font = new PdfStandardFont(PdfFontFamily.helvetica, fontSize, style);
|
|
3498
|
+
break;
|
|
3499
|
+
case 'Courier':
|
|
3500
|
+
font = new PdfStandardFont(PdfFontFamily.courier, fontSize, style);
|
|
3501
|
+
break;
|
|
3502
|
+
case 'Symbol':
|
|
3503
|
+
font = new PdfStandardFont(PdfFontFamily.symbol, fontSize, style);
|
|
3504
|
+
break;
|
|
3505
|
+
case 'Times':
|
|
3506
|
+
case 'TimesRoman':
|
|
3507
|
+
font = new PdfStandardFont(PdfFontFamily.timesRoman, fontSize, style);
|
|
3508
|
+
break;
|
|
3509
|
+
case 'ZapfDingbats':
|
|
3510
|
+
font = new PdfStandardFont(PdfFontFamily.zapfDingbats, fontSize, style);
|
|
3511
|
+
break;
|
|
3512
|
+
case 'MonotypeSungLight':
|
|
3513
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.monotypeSungLight, fontSize, style);
|
|
3514
|
+
break;
|
|
3515
|
+
case 'SinoTypeSongLight':
|
|
3516
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.sinoTypeSongLight, fontSize, style);
|
|
3517
|
+
break;
|
|
3518
|
+
case 'MonotypeHeiMedium':
|
|
3519
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.monotypeHeiMedium, fontSize, style);
|
|
3520
|
+
break;
|
|
3521
|
+
case 'HanyangSystemsGothicMedium':
|
|
3522
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.hanyangSystemsGothicMedium, fontSize, style);
|
|
3523
|
+
break;
|
|
3524
|
+
case 'HanyangSystemsShinMyeongJoMedium':
|
|
3525
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.hanyangSystemsShinMyeongJoMedium, fontSize, style);
|
|
3526
|
+
break;
|
|
3527
|
+
case 'HeiseiKakuGothicW5':
|
|
3528
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.heiseiKakuGothicW5, fontSize, style);
|
|
3529
|
+
break;
|
|
3530
|
+
case 'HeiseiMinchoW3':
|
|
3531
|
+
font = new PdfCjkStandardFont(PdfCjkFontFamily.heiseiMinchoW3, fontSize, style);
|
|
3532
|
+
break;
|
|
3533
|
+
default:
|
|
3534
|
+
if (annotation._dictionary.has('AP')) {
|
|
3535
|
+
var fontData = _tryParseFontStream(annotation._dictionary, annotation._crossReference, annotation);
|
|
3536
|
+
if (annotation._hasData) {
|
|
3537
|
+
var base64String = _encode(fontData);
|
|
3538
|
+
font = new PdfTrueTypeFont(base64String, fontSize, style);
|
|
3539
|
+
}
|
|
3540
|
+
}
|
|
3541
|
+
break;
|
|
3542
|
+
}
|
|
3543
|
+
}
|
|
3544
|
+
if (font === null || typeof font === 'undefined') {
|
|
3545
|
+
if (annotation instanceof PdfAnnotation) {
|
|
3546
|
+
if (annotation._type !== _PdfAnnotationType.widgetAnnotation) {
|
|
3547
|
+
font = new PdfStandardFont(PdfFontFamily.helvetica, fontSize, style);
|
|
3548
|
+
}
|
|
3549
|
+
else {
|
|
3550
|
+
font = annotation._circleCaptionFont;
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
else if (annotation instanceof PdfField) {
|
|
3554
|
+
font = annotation._circleCaptionFont;
|
|
3555
|
+
}
|
|
3556
|
+
}
|
|
3557
|
+
return font;
|
|
3558
|
+
}
|
|
3559
|
+
/**
|
|
3560
|
+
* Gets the font stream.
|
|
3561
|
+
*
|
|
3562
|
+
* @param {_PdfDictionary} widgetDictionary Widget dictionary.
|
|
3563
|
+
* @param {_PdfCrossReference} crossReference Cross reference.
|
|
3564
|
+
* @param {PdfAnnotation} annotation Annotation.
|
|
3565
|
+
* @returns {Uint8Array} result.
|
|
3566
|
+
*/
|
|
3567
|
+
export function _tryParseFontStream(widgetDictionary, crossReference, annotation) {
|
|
3568
|
+
var fontData;
|
|
3569
|
+
var apperance = widgetDictionary.get('AP');
|
|
3570
|
+
if (apperance && apperance.has('N')) {
|
|
3571
|
+
var normal = apperance.get('N');
|
|
3572
|
+
if (normal && normal instanceof _PdfStream && normal.dictionary.has('Resources')) {
|
|
3573
|
+
var resourcesDictionary = normal.dictionary.get('Resources');
|
|
3574
|
+
if (resourcesDictionary && resourcesDictionary.has('Font')) {
|
|
3575
|
+
var fontDictionary = resourcesDictionary.get('Font');
|
|
3576
|
+
if (fontDictionary && fontDictionary instanceof _PdfDictionary) {
|
|
3577
|
+
fontDictionary.forEach(function (key, value) {
|
|
3578
|
+
if (value) {
|
|
3579
|
+
var dictionary = crossReference._fetch(value);
|
|
3580
|
+
if (dictionary && dictionary.has('DescendantFonts')) {
|
|
3581
|
+
var descendant = dictionary.getArray('DescendantFonts'); // eslint-disable-line
|
|
3582
|
+
if (descendant && descendant.length > 0) {
|
|
3583
|
+
for (var i = 0; i < descendant.length; i++) {
|
|
3584
|
+
var descendantFont = descendant[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
|
|
3585
|
+
if (descendantFont && descendantFont instanceof _PdfDictionary && descendantFont.has('FontDescriptor')) {
|
|
3586
|
+
var fontDescriptor = descendantFont.get('FontDescriptor');
|
|
3587
|
+
if (fontDescriptor && fontDescriptor.has('FontFile2')) {
|
|
3588
|
+
var fontFile = fontDescriptor.get('FontFile2');
|
|
3589
|
+
if (fontFile && fontFile instanceof _PdfStream && fontFile.length > 0) {
|
|
3590
|
+
fontData = fontFile.getByteRange(fontFile.start, fontFile.end);
|
|
3591
|
+
if (fontData && fontData.length > 0) {
|
|
3592
|
+
annotation._hasData = true;
|
|
3593
|
+
}
|
|
3594
|
+
}
|
|
3595
|
+
}
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
});
|
|
3602
|
+
}
|
|
3603
|
+
}
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
return fontData;
|
|
3607
|
+
}
|
|
3608
|
+
/**
|
|
3609
|
+
* Gets the boolean if two arrays are equal.
|
|
3610
|
+
*
|
|
3611
|
+
* @param {Array<number[]>} inkPointsCollection Ink points collection.
|
|
3612
|
+
* @param {Array<number[]>} previousCollection Previous collection.
|
|
3613
|
+
* @returns {boolean} result.
|
|
3614
|
+
*/
|
|
3615
|
+
export function _checkInkPoints(inkPointsCollection, previousCollection) {
|
|
3616
|
+
if (inkPointsCollection.length !== previousCollection.length) {
|
|
3617
|
+
return false;
|
|
3618
|
+
}
|
|
3619
|
+
for (var i = 0; i < inkPointsCollection.length; i++) {
|
|
3620
|
+
if (!_areArrayEqual(inkPointsCollection[Number.parseInt(i.toString(), 10)], previousCollection[Number.parseInt(i.toString(), 10)])) {
|
|
3621
|
+
return false;
|
|
3622
|
+
}
|
|
3623
|
+
}
|
|
3624
|
+
return true;
|
|
3625
|
+
}
|