@syncfusion/ej2-pdf 1.0.22 → 23.1.36
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 +17 -0
- package/README.md +17 -0
- package/dist/ej2-pdf.umd.min.js +3 -13
- package/dist/ej2-pdf.umd.min.js.map +1 -11
- package/dist/es6/ej2-pdf.es2015.js +48245 -0
- package/dist/es6/ej2-pdf.es2015.js.map +1 -0
- package/dist/es6/ej2-pdf.es5.js +50124 -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 +57 -15
- 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 +744 -0
- package/src/pdf/core/annotations/annotation.d.ts +5845 -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 +31 -0
- package/src/pdf/core/graphics/images/image-decoder.js +130 -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 +678 -0
- package/src/pdf/core/utils.js +3607 -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 -17
- 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.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,2920 @@
|
|
|
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 { _XmlWriter } from './xml-writer';
|
|
15
|
+
import { PdfAnnotation, PdfFileLinkAnnotation, PdfTextWebLinkAnnotation, PdfDocumentLinkAnnotation, PdfUriAnnotation } from './../annotations/annotation';
|
|
16
|
+
import { PdfAnnotationFlag } from './../enumerator';
|
|
17
|
+
import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
|
|
18
|
+
import { _PdfBaseStream, _PdfContentStream } from './../base-stream';
|
|
19
|
+
import { _hexStringToByteArray, _stringToAnnotationFlags, _convertToColor, _bytesToString, _hexStringToString, _getSpecialCharacter, _getLatinCharacter, _getInheritableProperty, _getNewGuidString, _byteArrayToHexString, _stringToBytes, _annotationFlagsToString, _encode, _decode } from './../utils';
|
|
20
|
+
import { PdfCheckBoxField, PdfComboBoxField, PdfListBoxField, PdfRadioButtonListField, PdfTextBoxField, PdfListField } from './../form/field';
|
|
21
|
+
var _ExportHelper = /** @class */ (function () {
|
|
22
|
+
function _ExportHelper() {
|
|
23
|
+
this._asPerSpecification = false;
|
|
24
|
+
this._fileName = '';
|
|
25
|
+
this._formKey = '';
|
|
26
|
+
this._exportEmptyFields = false;
|
|
27
|
+
this._groupReferences = new Map();
|
|
28
|
+
this._groupHolders = [];
|
|
29
|
+
this._richTextPrefix = '<?xml version="1.0"?>';
|
|
30
|
+
this._table = new Map(); // eslint-disable-line
|
|
31
|
+
this._fields = new Map();
|
|
32
|
+
this._richTextValues = new Map();
|
|
33
|
+
this._jsonData = [];
|
|
34
|
+
this._openingBrace = 123;
|
|
35
|
+
this._openingBracket = 91;
|
|
36
|
+
this._closingBrace = 125;
|
|
37
|
+
this._closingBracket = 93;
|
|
38
|
+
this._colon = 58;
|
|
39
|
+
this._doubleQuotes = 34;
|
|
40
|
+
this._comma = 44;
|
|
41
|
+
this._space = 32;
|
|
42
|
+
this.fdfString = '';
|
|
43
|
+
this._xmlImport = false;
|
|
44
|
+
}
|
|
45
|
+
_ExportHelper.prototype._exportFormFieldsData = function (field) {
|
|
46
|
+
var textValue = '';
|
|
47
|
+
if (field !== null && typeof field !== 'undefined' && field.export) {
|
|
48
|
+
var type = _getInheritableProperty(field._dictionary, 'FT', false, true, 'Parent');
|
|
49
|
+
if (type && type.name !== null && typeof type.name !== 'undefined') {
|
|
50
|
+
var font = this._getEncodedFontDictionary(field._dictionary);
|
|
51
|
+
var fieldName = field.name;
|
|
52
|
+
if (font !== null && typeof font !== 'undefined') {
|
|
53
|
+
fieldName = this._getEncodedValue(fieldName, font);
|
|
54
|
+
}
|
|
55
|
+
var value = void 0; // eslint-disable-line
|
|
56
|
+
var selectedValue = void 0;
|
|
57
|
+
switch (type.name) {
|
|
58
|
+
case 'Tx':
|
|
59
|
+
textValue = _getInheritableProperty(field._dictionary, 'V', false, true, 'Parent');
|
|
60
|
+
if (textValue !== null && typeof textValue !== 'undefined') {
|
|
61
|
+
textValue = this._getEncodedValue(textValue, font);
|
|
62
|
+
this._table.set(fieldName, textValue);
|
|
63
|
+
}
|
|
64
|
+
else if (this._exportEmptyFields) {
|
|
65
|
+
textValue = '';
|
|
66
|
+
this._table.set(fieldName, textValue);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case 'Ch':
|
|
70
|
+
value = _getInheritableProperty(field._dictionary, 'V', true, true, 'Parent');
|
|
71
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
72
|
+
selectedValue = this._getExportValue(value);
|
|
73
|
+
}
|
|
74
|
+
if (!value && field._dictionary.has('I') && (field instanceof PdfListBoxField || field instanceof PdfComboBoxField)) {
|
|
75
|
+
selectedValue = field._obtainSelectedValue();
|
|
76
|
+
}
|
|
77
|
+
if (selectedValue !== null && typeof selectedValue !== 'undefined') {
|
|
78
|
+
if (typeof selectedValue === 'string' && selectedValue !== '') {
|
|
79
|
+
selectedValue = this._getEncodedValue(selectedValue, font);
|
|
80
|
+
textValue = selectedValue;
|
|
81
|
+
this._table.set(fieldName, textValue);
|
|
82
|
+
}
|
|
83
|
+
else if (selectedValue instanceof Array && selectedValue.length > 0) {
|
|
84
|
+
var values = [];
|
|
85
|
+
for (var i = 0; i < selectedValue.length; i++) {
|
|
86
|
+
values.push(this._getEncodedValue(selectedValue[Number.parseInt(i.toString(), 10)], font));
|
|
87
|
+
}
|
|
88
|
+
this._table.set(fieldName, values);
|
|
89
|
+
return values;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else if (this._exportEmptyFields) {
|
|
93
|
+
textValue = '';
|
|
94
|
+
this._table.set(fieldName, textValue);
|
|
95
|
+
}
|
|
96
|
+
break;
|
|
97
|
+
case 'Btn':
|
|
98
|
+
value = _getInheritableProperty(field._dictionary, 'V', false, true, 'Parent');
|
|
99
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
100
|
+
var text = this._getExportValue(value, field);
|
|
101
|
+
if (text !== null && typeof text !== 'undefined' && text !== '') {
|
|
102
|
+
var radioButton = void 0;
|
|
103
|
+
if (field instanceof PdfRadioButtonListField) {
|
|
104
|
+
radioButton = field;
|
|
105
|
+
}
|
|
106
|
+
if (!field._dictionary.has('Opt') ||
|
|
107
|
+
(radioButton !== null &&
|
|
108
|
+
typeof radioButton !== 'undefined'
|
|
109
|
+
&& radioButton.selectedIndex === -1)) {
|
|
110
|
+
text = this._getEncodedValue(text, font);
|
|
111
|
+
textValue = text;
|
|
112
|
+
this._table.set(fieldName, textValue);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
if (field._dictionary.has('Opt')) {
|
|
116
|
+
var options = field._dictionary.getArray('Opt');
|
|
117
|
+
var index = Number.parseInt(text, 10);
|
|
118
|
+
if (index === null || typeof index === 'undefined' || Number.isNaN(index)) {
|
|
119
|
+
index = 0;
|
|
120
|
+
}
|
|
121
|
+
if (options !== null && typeof options !== 'undefined') {
|
|
122
|
+
var current = void 0;
|
|
123
|
+
if (radioButton) {
|
|
124
|
+
current = options[radioButton.selectedIndex];
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
current = options[Number.parseInt(index.toString(), 10)];
|
|
128
|
+
}
|
|
129
|
+
if (current !== null && typeof current !== 'undefined') {
|
|
130
|
+
text = current;
|
|
131
|
+
}
|
|
132
|
+
if (text !== null && typeof text !== 'undefined' && text !== '') {
|
|
133
|
+
text = this._getEncodedValue(text, font);
|
|
134
|
+
textValue = text;
|
|
135
|
+
this._table.set(fieldName, textValue);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
else if (field instanceof PdfRadioButtonListField || field instanceof PdfCheckBoxField) {
|
|
142
|
+
if (this._exportEmptyFields) {
|
|
143
|
+
textValue = text;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
textValue = 'Off';
|
|
147
|
+
}
|
|
148
|
+
this._table.set(fieldName, textValue);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
if (field instanceof PdfRadioButtonListField) {
|
|
153
|
+
textValue = field._getAppearanceStateValue();
|
|
154
|
+
if (!textValue) {
|
|
155
|
+
if (this._exportEmptyFields) {
|
|
156
|
+
textValue = '';
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
textValue = 'Off';
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
this._table.set(fieldName, textValue);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
var widget = field.itemAt(field._defaultIndex);
|
|
166
|
+
var dictionary = void 0;
|
|
167
|
+
if (widget) {
|
|
168
|
+
dictionary = widget._dictionary;
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
dictionary = field._dictionary;
|
|
172
|
+
}
|
|
173
|
+
if (dictionary && dictionary.has('AS')) {
|
|
174
|
+
textValue = dictionary.get('AS').name;
|
|
175
|
+
this._table.set(fieldName, textValue);
|
|
176
|
+
}
|
|
177
|
+
else if (this._exportEmptyFields) {
|
|
178
|
+
textValue = '';
|
|
179
|
+
this._table.set(fieldName, textValue);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
return textValue;
|
|
188
|
+
};
|
|
189
|
+
_ExportHelper.prototype._exportFormFieldData = function (field) {
|
|
190
|
+
var type = _getInheritableProperty(field._dictionary, 'FT', false, true, 'Parent');
|
|
191
|
+
if (type && type.name !== null && typeof type.name !== 'undefined') {
|
|
192
|
+
var font = this._getEncodedFontDictionary(field._dictionary);
|
|
193
|
+
var fieldName = field.name;
|
|
194
|
+
if (font !== null && typeof font !== 'undefined') {
|
|
195
|
+
fieldName = this._getEncodedValue(fieldName, font);
|
|
196
|
+
}
|
|
197
|
+
var textValue = void 0;
|
|
198
|
+
var value = void 0; // eslint-disable-line
|
|
199
|
+
switch (type.name) {
|
|
200
|
+
case 'Tx':
|
|
201
|
+
textValue = _getInheritableProperty(field._dictionary, 'V', false, true, 'Parent');
|
|
202
|
+
if (this._asPerSpecification) {
|
|
203
|
+
if (field._dictionary.has('RV')) {
|
|
204
|
+
textValue = _getInheritableProperty(field._dictionary, 'RV', false, true, 'Parent');
|
|
205
|
+
if (textValue !== null && typeof textValue !== 'undefined') {
|
|
206
|
+
textValue += this._key;
|
|
207
|
+
this._formKey = this._key;
|
|
208
|
+
this._table.set(fieldName, textValue);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
else if (textValue !== null && typeof textValue !== 'undefined') {
|
|
212
|
+
textValue = this._getEncodedValue(textValue, font);
|
|
213
|
+
var replaceValue = textValue;
|
|
214
|
+
if (field instanceof PdfTextBoxField && field.multiLine) {
|
|
215
|
+
replaceValue = replaceValue.replace('\n', '');
|
|
216
|
+
replaceValue = replaceValue.replace('\r', '\r\n');
|
|
217
|
+
textValue = replaceValue;
|
|
218
|
+
}
|
|
219
|
+
this._table.set(fieldName, textValue);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
else {
|
|
223
|
+
if (textValue !== null && typeof textValue !== 'undefined') {
|
|
224
|
+
textValue = this._getEncodedValue(textValue, font);
|
|
225
|
+
this._table.set(fieldName, textValue);
|
|
226
|
+
}
|
|
227
|
+
else if (this._exportEmptyFields) {
|
|
228
|
+
this._table.set(fieldName, '');
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
break;
|
|
232
|
+
case 'Ch':
|
|
233
|
+
value = _getInheritableProperty(field._dictionary, 'V', true, true, 'Parent');
|
|
234
|
+
if (this._asPerSpecification) {
|
|
235
|
+
if (field instanceof PdfListField) {
|
|
236
|
+
if (Array.isArray(value)) {
|
|
237
|
+
this._table.set(fieldName, value);
|
|
238
|
+
}
|
|
239
|
+
else {
|
|
240
|
+
if (typeof value === 'string') {
|
|
241
|
+
value = this._getEncodedValue(value, font);
|
|
242
|
+
this._table.set(fieldName, value);
|
|
243
|
+
}
|
|
244
|
+
else if ((value === null || typeof value === 'undefined') && field._dictionary.has('I')) {
|
|
245
|
+
var selectedValue = field._obtainSelectedValue();
|
|
246
|
+
if (selectedValue !== null && typeof selectedValue !== 'undefined') {
|
|
247
|
+
if (typeof selectedValue === 'string' && selectedValue !== '') {
|
|
248
|
+
selectedValue = this._getEncodedValue(selectedValue, font);
|
|
249
|
+
this._table.set(fieldName, textValue);
|
|
250
|
+
}
|
|
251
|
+
else if (selectedValue instanceof Array && selectedValue.length > 0) {
|
|
252
|
+
var values = [];
|
|
253
|
+
for (var i = 0; i < selectedValue.length; i++) {
|
|
254
|
+
values.push(this._getEncodedValue(selectedValue[Number.parseInt(i.toString(), 10)], font));
|
|
255
|
+
}
|
|
256
|
+
this._table.set(fieldName, values);
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
var selectedValue = void 0;
|
|
265
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
266
|
+
selectedValue = this._getExportValue(value);
|
|
267
|
+
}
|
|
268
|
+
if (!value && field._dictionary.has('I') && (field instanceof PdfListBoxField || field instanceof PdfComboBoxField)) {
|
|
269
|
+
selectedValue = field._obtainSelectedValue();
|
|
270
|
+
}
|
|
271
|
+
if (selectedValue !== null && typeof selectedValue !== 'undefined') {
|
|
272
|
+
if (typeof selectedValue === 'string' && selectedValue !== '') {
|
|
273
|
+
selectedValue = this._getEncodedValue(selectedValue, font);
|
|
274
|
+
this._table.set(fieldName, selectedValue);
|
|
275
|
+
}
|
|
276
|
+
else if (selectedValue instanceof Array && selectedValue.length > 0) {
|
|
277
|
+
var values = [];
|
|
278
|
+
for (var i = 0; i < selectedValue.length; i++) {
|
|
279
|
+
values.push(this._getEncodedValue(selectedValue[Number.parseInt(i.toString(), 10)], font));
|
|
280
|
+
}
|
|
281
|
+
this._table.set(fieldName, values);
|
|
282
|
+
}
|
|
283
|
+
else if (this._exportEmptyFields) {
|
|
284
|
+
this._table.set(fieldName, '');
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
else if (this._exportEmptyFields) {
|
|
288
|
+
this._table.set(fieldName, '');
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
break;
|
|
292
|
+
case 'Btn':
|
|
293
|
+
value = _getInheritableProperty(field._dictionary, 'V', false, true, 'Parent');
|
|
294
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
295
|
+
var text = this._getExportValue(value, field);
|
|
296
|
+
if (text !== null && typeof text !== 'undefined' && text !== '') {
|
|
297
|
+
if (this._asPerSpecification && this._format !== 'XML') {
|
|
298
|
+
text = _hexStringToString(text);
|
|
299
|
+
}
|
|
300
|
+
var radioButton = void 0;
|
|
301
|
+
if (field instanceof PdfRadioButtonListField) {
|
|
302
|
+
radioButton = field;
|
|
303
|
+
}
|
|
304
|
+
if (!field._dictionary.has('Opt') ||
|
|
305
|
+
(radioButton !== null &&
|
|
306
|
+
typeof radioButton !== 'undefined'
|
|
307
|
+
&& radioButton.selectedIndex === -1)) {
|
|
308
|
+
text = this._getEncodedValue(text, font);
|
|
309
|
+
this._table.set(fieldName, text);
|
|
310
|
+
}
|
|
311
|
+
else {
|
|
312
|
+
if (field._dictionary.has('Opt')) {
|
|
313
|
+
var options = field._dictionary.getArray('Opt');
|
|
314
|
+
var index = Number.parseInt(text, 10);
|
|
315
|
+
if (index === null || typeof index === 'undefined' || Number.isNaN(index)) {
|
|
316
|
+
index = 0;
|
|
317
|
+
}
|
|
318
|
+
if (options !== null && typeof options !== 'undefined') {
|
|
319
|
+
var current = void 0;
|
|
320
|
+
if (radioButton) {
|
|
321
|
+
current = options[radioButton.selectedIndex];
|
|
322
|
+
}
|
|
323
|
+
else {
|
|
324
|
+
current = options[Number.parseInt(index.toString(), 10)];
|
|
325
|
+
}
|
|
326
|
+
if (current !== null && typeof current !== 'undefined') {
|
|
327
|
+
text = current;
|
|
328
|
+
}
|
|
329
|
+
if (text !== null && typeof text !== 'undefined' && text !== '') {
|
|
330
|
+
text = this._getEncodedValue(text, font);
|
|
331
|
+
this._table.set(fieldName, text);
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
else if (field instanceof PdfRadioButtonListField || field instanceof PdfCheckBoxField) {
|
|
338
|
+
if (this._exportEmptyFields) {
|
|
339
|
+
this._table.set(fieldName, text);
|
|
340
|
+
}
|
|
341
|
+
else {
|
|
342
|
+
this._table.set(fieldName, 'Off');
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
if (field instanceof PdfRadioButtonListField) {
|
|
348
|
+
var text = field._getAppearanceStateValue();
|
|
349
|
+
if (!text) {
|
|
350
|
+
if (this._exportEmptyFields) {
|
|
351
|
+
text = '';
|
|
352
|
+
}
|
|
353
|
+
else {
|
|
354
|
+
text = 'Off';
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
this._table.set(fieldName, text);
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
var widget = field.itemAt(field._defaultIndex);
|
|
361
|
+
var dictionary = void 0;
|
|
362
|
+
if (widget) {
|
|
363
|
+
dictionary = widget._dictionary;
|
|
364
|
+
}
|
|
365
|
+
else {
|
|
366
|
+
dictionary = field._dictionary;
|
|
367
|
+
}
|
|
368
|
+
if (dictionary && dictionary.has('AS')) {
|
|
369
|
+
this._table.set(fieldName, dictionary.get('AS').name);
|
|
370
|
+
}
|
|
371
|
+
else if (this._exportEmptyFields) {
|
|
372
|
+
this._table.set(fieldName, '');
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
break;
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
};
|
|
380
|
+
_ExportHelper.prototype._getAnnotationType = function (dictionary) {
|
|
381
|
+
var type = '';
|
|
382
|
+
if (dictionary.has('Subtype')) {
|
|
383
|
+
var subtype = dictionary.get('Subtype');
|
|
384
|
+
if (subtype) {
|
|
385
|
+
type = subtype.name;
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return type;
|
|
389
|
+
};
|
|
390
|
+
_ExportHelper.prototype._getValue = function (primitive, isJson) {
|
|
391
|
+
if (isJson === void 0) { isJson = false; }
|
|
392
|
+
var value = '';
|
|
393
|
+
if (typeof primitive !== 'undefined' && primitive !== null) {
|
|
394
|
+
if (primitive instanceof _PdfName) {
|
|
395
|
+
value = primitive.name;
|
|
396
|
+
}
|
|
397
|
+
else if (typeof primitive === 'boolean') {
|
|
398
|
+
value = primitive ? isJson ? 'true' : 'yes' : isJson ? 'false' : 'no';
|
|
399
|
+
}
|
|
400
|
+
else if (typeof primitive === 'string') {
|
|
401
|
+
value = this._getValidString(primitive);
|
|
402
|
+
}
|
|
403
|
+
else if (Array.isArray(primitive)) {
|
|
404
|
+
var colorArray = primitive; // eslint-disable-line
|
|
405
|
+
if (colorArray.length > 0) {
|
|
406
|
+
value = this._getValue(colorArray[0], isJson);
|
|
407
|
+
}
|
|
408
|
+
for (var i = 1; i < colorArray.length; i++) {
|
|
409
|
+
value += ',' + this._getValue(colorArray[Number.parseInt(i.toString(), 10)], isJson);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
else if (typeof primitive === 'number') {
|
|
413
|
+
value = primitive.toString();
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return value;
|
|
417
|
+
};
|
|
418
|
+
_ExportHelper.prototype._getColor = function (primitive) {
|
|
419
|
+
var color = '';
|
|
420
|
+
if (primitive && Array.isArray(primitive) && primitive.length >= 3) {
|
|
421
|
+
var r = Math.round(primitive[0] * 255).toString(16).toUpperCase();
|
|
422
|
+
var g = Math.round(primitive[1] * 255).toString(16).toUpperCase();
|
|
423
|
+
var b = Math.round(primitive[2] * 255).toString(16).toUpperCase();
|
|
424
|
+
color = '#' + (r.length === 1 ? ('0' + r) : r) + (g.length === 1 ? ('0' + g) : g) + (b.length === 1 ? ('0' + b) : b);
|
|
425
|
+
}
|
|
426
|
+
return color;
|
|
427
|
+
};
|
|
428
|
+
_ExportHelper.prototype._getValidString = function (value) {
|
|
429
|
+
if (value.indexOf('\n') !== -1) {
|
|
430
|
+
value = value.replace(/\n/g, '\\n');
|
|
431
|
+
}
|
|
432
|
+
if (value.indexOf('\r') !== -1) {
|
|
433
|
+
value = value.replace(/\r/g, '\\r');
|
|
434
|
+
}
|
|
435
|
+
return value;
|
|
436
|
+
};
|
|
437
|
+
_ExportHelper.prototype._getEncodedFontDictionary = function (source) {
|
|
438
|
+
var font;
|
|
439
|
+
var kids; // eslint-disable-line
|
|
440
|
+
if (source.has('Kids') && !source.has('AP')) {
|
|
441
|
+
kids = source.getArray('Kids');
|
|
442
|
+
}
|
|
443
|
+
if (source.has('AP') || (kids !== null && typeof kids !== 'undefined' && Array.isArray(kids))) {
|
|
444
|
+
var appearance = void 0;
|
|
445
|
+
if (kids !== null && typeof kids !== 'undefined' && kids.length > 0) {
|
|
446
|
+
var kid = kids[0];
|
|
447
|
+
if (kid !== null && typeof kid !== 'undefined' && kid.has('AP')) {
|
|
448
|
+
appearance = kid.get('AP');
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
else {
|
|
452
|
+
appearance = source.get('AP');
|
|
453
|
+
}
|
|
454
|
+
if (appearance !== null && typeof appearance !== 'undefined' && appearance.has('N')) {
|
|
455
|
+
var normal = appearance.get('N');
|
|
456
|
+
if (normal !== null && typeof normal !== 'undefined' && normal instanceof _PdfBaseStream && normal.dictionary.has('Resources')) {
|
|
457
|
+
var resource = normal.dictionary.get('Resources');
|
|
458
|
+
if (resource !== null && typeof resource !== 'undefined' && resource.has('Font')) {
|
|
459
|
+
font = resource.get('Font');
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
return font;
|
|
465
|
+
};
|
|
466
|
+
_ExportHelper.prototype._getEncodedValue = function (value, dictionary) {
|
|
467
|
+
var _this = this;
|
|
468
|
+
var text = value;
|
|
469
|
+
var structure;
|
|
470
|
+
if (this._encodeDictionary !== null && typeof this._encodeDictionary !== 'undefined') {
|
|
471
|
+
structure = new _FontStructure(this._encodeDictionary);
|
|
472
|
+
return this._replaceNotUsedCharacters(text, structure);
|
|
473
|
+
}
|
|
474
|
+
else {
|
|
475
|
+
var root = this._document.form._dictionary;
|
|
476
|
+
if (root !== null && typeof root !== 'undefined' && root.has('DR')) {
|
|
477
|
+
var resource = root.get('DR');
|
|
478
|
+
if (resource !== null && typeof resource !== 'undefined' && resource.has('Encoding')) {
|
|
479
|
+
var encoding = resource.get('Encoding');
|
|
480
|
+
if (encoding !== null && typeof encoding !== 'undefined' && encoding.has('PDFDocEncoding')) {
|
|
481
|
+
var pdfEncoding = encoding.get('PDFDocEncoding');
|
|
482
|
+
if (pdfEncoding !== null && typeof pdfEncoding !== 'undefined' && pdfEncoding.has('Differences')) {
|
|
483
|
+
var encodingDictionary = new _PdfDictionary(this._crossReference);
|
|
484
|
+
encodingDictionary.set('Differences', pdfEncoding.get('Differences'));
|
|
485
|
+
var reference = this._crossReference._getNextReference();
|
|
486
|
+
this._crossReference._cacheMap.set(reference, encodingDictionary);
|
|
487
|
+
var fontEncodeDictionary = new _PdfDictionary(this._crossReference);
|
|
488
|
+
fontEncodeDictionary.set('Subtype', _PdfName.get('Type1'));
|
|
489
|
+
fontEncodeDictionary.set('Encoding', reference);
|
|
490
|
+
structure = new _FontStructure(fontEncodeDictionary);
|
|
491
|
+
if (structure !== null &&
|
|
492
|
+
typeof structure !== 'undefined' &&
|
|
493
|
+
structure.differencesDictionary !== null &&
|
|
494
|
+
typeof structure.differencesDictionary !== 'undefined' &&
|
|
495
|
+
structure.differencesDictionary.size > 0) {
|
|
496
|
+
this._encodeDictionary = fontEncodeDictionary;
|
|
497
|
+
return this._replaceNotUsedCharacters(text, structure);
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
if (value !== null &&
|
|
504
|
+
typeof value !== 'undefined' &&
|
|
505
|
+
dictionary !== null &&
|
|
506
|
+
typeof dictionary !== 'undefined' &&
|
|
507
|
+
dictionary.size > 0) {
|
|
508
|
+
var result_1;
|
|
509
|
+
var isSkip_1 = false;
|
|
510
|
+
dictionary.forEach(function (key, value) {
|
|
511
|
+
if (!isSkip_1 && value !== null && typeof value !== 'undefined') {
|
|
512
|
+
var fontDictionary = void 0;
|
|
513
|
+
if (value instanceof _PdfDictionary) {
|
|
514
|
+
fontDictionary = value;
|
|
515
|
+
}
|
|
516
|
+
else if (value instanceof _PdfReference) {
|
|
517
|
+
var holder = _this._crossReference._fetch(value); // eslint-disable-line
|
|
518
|
+
if (holder !== null && typeof holder !== 'undefined' && holder instanceof _PdfDictionary) {
|
|
519
|
+
fontDictionary = holder;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
if (fontDictionary) {
|
|
523
|
+
structure = new _FontStructure(fontDictionary);
|
|
524
|
+
result_1 = _this._replaceNotUsedCharacters(text, structure);
|
|
525
|
+
isSkip_1 = true;
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
});
|
|
529
|
+
if (!isSkip_1) {
|
|
530
|
+
return result_1;
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return text;
|
|
534
|
+
}
|
|
535
|
+
};
|
|
536
|
+
_ExportHelper.prototype._replaceNotUsedCharacters = function (input, structure) {
|
|
537
|
+
var updatedString = '';
|
|
538
|
+
var differencesDictionary = structure.differencesDictionary;
|
|
539
|
+
for (var i = 0; i < input.length; i++) {
|
|
540
|
+
var text = input[Number.parseInt(i.toString(), 10)];
|
|
541
|
+
var code = input.charCodeAt(i);
|
|
542
|
+
if (differencesDictionary.has(text)) {
|
|
543
|
+
var difference = differencesDictionary.get(text);
|
|
544
|
+
if ((difference.length > 1 && structure._fontType !== 'Type3') ||
|
|
545
|
+
(code > 127 && code <= 255 && structure._fontType === 'Type1' &&
|
|
546
|
+
structure._baseFontEncoding !== 'WinAnsiEncoding' &&
|
|
547
|
+
structure._fontEncoding === 'Encoding' && structure._fontName === 'ZapfDingbats')) {
|
|
548
|
+
updatedString += text;
|
|
549
|
+
}
|
|
550
|
+
else {
|
|
551
|
+
updatedString += difference;
|
|
552
|
+
}
|
|
553
|
+
}
|
|
554
|
+
else {
|
|
555
|
+
updatedString += text;
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
return updatedString;
|
|
559
|
+
};
|
|
560
|
+
_ExportHelper.prototype._getExportValue = function (primitive, field) {
|
|
561
|
+
var value;
|
|
562
|
+
if (primitive !== null && typeof primitive !== 'undefined') {
|
|
563
|
+
if (field !== null && typeof field !== 'undefined') {
|
|
564
|
+
if (primitive instanceof _PdfName) {
|
|
565
|
+
value = primitive.name;
|
|
566
|
+
}
|
|
567
|
+
else if (typeof primitive === 'string') {
|
|
568
|
+
value = primitive;
|
|
569
|
+
}
|
|
570
|
+
if (value !== null &&
|
|
571
|
+
typeof value !== 'undefined' &&
|
|
572
|
+
value !== '' &&
|
|
573
|
+
field instanceof PdfRadioButtonListField &&
|
|
574
|
+
field.selectedIndex !== -1) {
|
|
575
|
+
var item = field.itemAt(field.selectedIndex);
|
|
576
|
+
if (item !== null && typeof item !== 'undefined' && item.value === value) {
|
|
577
|
+
value = item.value;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
else {
|
|
582
|
+
if (primitive instanceof _PdfName) {
|
|
583
|
+
value = primitive.name;
|
|
584
|
+
}
|
|
585
|
+
else if (typeof primitive === 'string') {
|
|
586
|
+
value = primitive;
|
|
587
|
+
}
|
|
588
|
+
else if (Array.isArray(primitive)) {
|
|
589
|
+
var values = [];
|
|
590
|
+
for (var i = 0; i < primitive.length; i++) {
|
|
591
|
+
var element = primitive[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
|
|
592
|
+
if (element instanceof _PdfName) {
|
|
593
|
+
values.push(element.name);
|
|
594
|
+
}
|
|
595
|
+
else if (typeof element === 'string') {
|
|
596
|
+
values.push(element);
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
return values;
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
return value;
|
|
604
|
+
};
|
|
605
|
+
_ExportHelper.prototype._addReferenceToGroup = function (reference, dictionary) {
|
|
606
|
+
var name = dictionary.get('NM');
|
|
607
|
+
if (name && name !== '') {
|
|
608
|
+
this._groupReferences.set(name, reference);
|
|
609
|
+
if (dictionary.has('IRT')) {
|
|
610
|
+
this._groupHolders.push(dictionary);
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
else if (!name && dictionary.has('IRT')) {
|
|
614
|
+
name = dictionary.get('IRT');
|
|
615
|
+
if (name && name !== '' && this._groupReferences.has(name)) {
|
|
616
|
+
dictionary.update('IRT', this._groupReferences.get(name));
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
};
|
|
620
|
+
_ExportHelper.prototype._handlePopup = function (annotations, reference, annotationDictionary, pageDictionary) {
|
|
621
|
+
if (annotationDictionary.has('Popup')) {
|
|
622
|
+
var popupReference = annotationDictionary.getRaw('Popup');
|
|
623
|
+
var popup = annotationDictionary.get('Popup');
|
|
624
|
+
if (popup instanceof _PdfDictionary) {
|
|
625
|
+
if (popupReference && popup) {
|
|
626
|
+
popup.update('Parent', reference);
|
|
627
|
+
}
|
|
628
|
+
var popupAnnotation = annotations._parseAnnotation(popup);
|
|
629
|
+
var index = annotations._annotations.length;
|
|
630
|
+
annotations._annotations.push(reference);
|
|
631
|
+
pageDictionary.set('Annots', annotations._annotations);
|
|
632
|
+
pageDictionary._updated = true;
|
|
633
|
+
annotations._parsedAnnotations.set(index, popupAnnotation);
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
};
|
|
637
|
+
_ExportHelper.prototype._importField = function () {
|
|
638
|
+
var _this = this;
|
|
639
|
+
var form = this._document.form;
|
|
640
|
+
var count = form.count;
|
|
641
|
+
if (count) {
|
|
642
|
+
this._fields.forEach(function (value, key) {
|
|
643
|
+
var richTextValue;
|
|
644
|
+
if (_this._richTextValues.size > 0 && _this._richTextValues.has(key)) {
|
|
645
|
+
richTextValue = _this._richTextValues.get(key);
|
|
646
|
+
}
|
|
647
|
+
var index = form._getFieldIndex(key);
|
|
648
|
+
if (index !== -1 && index < count) {
|
|
649
|
+
var field = form.fieldAt(index);
|
|
650
|
+
if (field && field !== null && typeof field !== 'undefined') {
|
|
651
|
+
if (richTextValue && richTextValue !== '') {
|
|
652
|
+
field._dictionary.update('RV', richTextValue);
|
|
653
|
+
}
|
|
654
|
+
_this._importFieldData(field, value);
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
};
|
|
660
|
+
_ExportHelper.prototype._importFieldData = function (field, values) {
|
|
661
|
+
if (values !== null &&
|
|
662
|
+
typeof values !== 'undefined' &&
|
|
663
|
+
values.length > 0 &&
|
|
664
|
+
field !== null &&
|
|
665
|
+
typeof field !== 'undefined' &&
|
|
666
|
+
!field.readOnly) {
|
|
667
|
+
var value = values[0];
|
|
668
|
+
if (field instanceof PdfTextBoxField) {
|
|
669
|
+
if (value !== null && typeof value !== 'undefined') {
|
|
670
|
+
if (field instanceof PdfTextBoxField && field.multiLine) {
|
|
671
|
+
value = value.replace('\r\n', '\r');
|
|
672
|
+
value = value.replace('\n', '\r');
|
|
673
|
+
}
|
|
674
|
+
field.text = value;
|
|
675
|
+
}
|
|
676
|
+
}
|
|
677
|
+
else if (field instanceof PdfListBoxField || field instanceof PdfComboBoxField) {
|
|
678
|
+
var selectedValues_1;
|
|
679
|
+
if (values.length > 1) {
|
|
680
|
+
selectedValues_1 = values;
|
|
681
|
+
}
|
|
682
|
+
else {
|
|
683
|
+
if (this._xmlImport) {
|
|
684
|
+
selectedValues_1 = (value.indexOf(',') !== -1 ? value.split(',') : [value]);
|
|
685
|
+
}
|
|
686
|
+
else {
|
|
687
|
+
selectedValues_1 = [value.indexOf(',') !== -1 ? value.split(',')[0] : value];
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
var indexes_1 = [];
|
|
691
|
+
var options_1 = field._options;
|
|
692
|
+
if (options_1 && options_1.length > 0) {
|
|
693
|
+
options_1.forEach(function (option) {
|
|
694
|
+
if (selectedValues_1.indexOf(option[0]) !== -1 || selectedValues_1.indexOf(option[1]) !== -1) {
|
|
695
|
+
indexes_1.push(options_1.indexOf(option));
|
|
696
|
+
}
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
if (indexes_1.length > 0) {
|
|
700
|
+
field.selectedIndex = indexes_1;
|
|
701
|
+
if (field instanceof PdfComboBoxField && this._asPerSpecification && field._dictionary.has('AP')) {
|
|
702
|
+
delete field._dictionary._map.AP;
|
|
703
|
+
field._dictionary._updated = true;
|
|
704
|
+
}
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
else if (field instanceof PdfCheckBoxField) {
|
|
708
|
+
var lowerCase = value.toLowerCase();
|
|
709
|
+
if (this._containsExportValue(value, field) || lowerCase === 'on' || lowerCase === 'yes') {
|
|
710
|
+
field.checked = true;
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
field.checked = false;
|
|
714
|
+
}
|
|
715
|
+
}
|
|
716
|
+
else if (field instanceof PdfRadioButtonListField) {
|
|
717
|
+
var index = -1;
|
|
718
|
+
for (var i = 0; i < field._kidsCount; i++) {
|
|
719
|
+
var item = field.itemAt(i);
|
|
720
|
+
if (item && item.value && item.value === value) {
|
|
721
|
+
index = i;
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
if (index !== -1 && field.selectedIndex !== index) {
|
|
726
|
+
field.selectedIndex = index;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
_ExportHelper.prototype._containsExportValue = function (value, field) {
|
|
732
|
+
var result = false;
|
|
733
|
+
if (field._kidsCount > 0) {
|
|
734
|
+
for (var i = 0; i < field._kidsCount; i++) {
|
|
735
|
+
var kid = field.itemAt(i);
|
|
736
|
+
if (kid && this._checkSelected(kid._dictionary, value)) {
|
|
737
|
+
return true;
|
|
738
|
+
}
|
|
739
|
+
}
|
|
740
|
+
}
|
|
741
|
+
else {
|
|
742
|
+
result = this._checkSelected(field._dictionary, value);
|
|
743
|
+
if (!result && this._asPerSpecification && field._dictionary.has('AS')) {
|
|
744
|
+
var asEntry = field._dictionary.get('AS');
|
|
745
|
+
if (asEntry && (asEntry.name === 'Off' || asEntry.name === 'No')) {
|
|
746
|
+
if (field._dictionary.has('Opt')) {
|
|
747
|
+
var options = field._dictionary.getArray('Opt');
|
|
748
|
+
if (options && options.length > 0) {
|
|
749
|
+
options.forEach(function (option) {
|
|
750
|
+
if (option === value) {
|
|
751
|
+
result = true;
|
|
752
|
+
}
|
|
753
|
+
});
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
}
|
|
757
|
+
else {
|
|
758
|
+
result = true;
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
return result;
|
|
763
|
+
};
|
|
764
|
+
_ExportHelper.prototype._checkSelected = function (dictionary, value) {
|
|
765
|
+
if (dictionary && dictionary.has('AP')) {
|
|
766
|
+
var appearance = dictionary.get('AP');
|
|
767
|
+
if (appearance && appearance instanceof _PdfDictionary && appearance.has('N')) {
|
|
768
|
+
var normalTemplate = appearance.get('N');
|
|
769
|
+
if (normalTemplate &&
|
|
770
|
+
normalTemplate instanceof _PdfDictionary &&
|
|
771
|
+
normalTemplate.has(value) &&
|
|
772
|
+
!(value.toLocaleLowerCase() === 'off' || value.toLocaleLowerCase() === 'no')) {
|
|
773
|
+
return true;
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
return false;
|
|
778
|
+
};
|
|
779
|
+
_ExportHelper.prototype._dispose = function () {
|
|
780
|
+
this.exportAppearance = undefined;
|
|
781
|
+
this._asPerSpecification = undefined;
|
|
782
|
+
this._skipBorderStyle = undefined;
|
|
783
|
+
this._fileName = undefined;
|
|
784
|
+
this._document = undefined;
|
|
785
|
+
this._crossReference = undefined;
|
|
786
|
+
this._isAnnotationExport = undefined;
|
|
787
|
+
this._isAnnotationImport = undefined;
|
|
788
|
+
this._key = undefined;
|
|
789
|
+
this._formKey = undefined;
|
|
790
|
+
this._exportEmptyFields = undefined;
|
|
791
|
+
this._groupReferences = undefined;
|
|
792
|
+
this._groupHolders = undefined;
|
|
793
|
+
this._encodeDictionary = undefined;
|
|
794
|
+
this._annotationTypes = undefined;
|
|
795
|
+
this._annotationAttributes = undefined;
|
|
796
|
+
this._xmlDocument = undefined;
|
|
797
|
+
this._parser = undefined;
|
|
798
|
+
this._table = undefined;
|
|
799
|
+
this._fields = undefined;
|
|
800
|
+
this._richTextValues = undefined;
|
|
801
|
+
this._jsonData = undefined;
|
|
802
|
+
};
|
|
803
|
+
return _ExportHelper;
|
|
804
|
+
}());
|
|
805
|
+
export { _ExportHelper };
|
|
806
|
+
var _XfdfDocument = /** @class */ (function (_super) {
|
|
807
|
+
__extends(_XfdfDocument, _super);
|
|
808
|
+
function _XfdfDocument(fileName) {
|
|
809
|
+
var _this = _super.call(this) || this;
|
|
810
|
+
if (fileName !== null && typeof fileName !== 'undefined') {
|
|
811
|
+
_this._fileName = fileName;
|
|
812
|
+
}
|
|
813
|
+
return _this;
|
|
814
|
+
}
|
|
815
|
+
// #region Export Annotations
|
|
816
|
+
_XfdfDocument.prototype._exportAnnotations = function (document) {
|
|
817
|
+
this._document = document;
|
|
818
|
+
this._crossReference = document._crossReference;
|
|
819
|
+
this._isAnnotationExport = true;
|
|
820
|
+
return this._save();
|
|
821
|
+
};
|
|
822
|
+
_XfdfDocument.prototype._exportFormFields = function (document) {
|
|
823
|
+
this._document = document;
|
|
824
|
+
this._crossReference = document._crossReference;
|
|
825
|
+
this._isAnnotationExport = false;
|
|
826
|
+
this._key = _getNewGuidString();
|
|
827
|
+
return this._save();
|
|
828
|
+
};
|
|
829
|
+
_XfdfDocument.prototype._save = function () {
|
|
830
|
+
var writer = new _XmlWriter();
|
|
831
|
+
writer._writeStartDocument();
|
|
832
|
+
writer._writeStartElement('xfdf');
|
|
833
|
+
writer._writeAttributeString(null, 'http://ns.adobe.com/xfdf/', 'xmlns', null);
|
|
834
|
+
writer._writeAttributeString('space', 'preserve', 'xml', null);
|
|
835
|
+
if (this._isAnnotationExport) {
|
|
836
|
+
writer._writeStartElement('annots');
|
|
837
|
+
if (this._document) {
|
|
838
|
+
for (var i = 0; i < this._document.pageCount; i++) {
|
|
839
|
+
var page = this._document.getPage(i);
|
|
840
|
+
var annotations = page.annotations;
|
|
841
|
+
for (var j = 0; j < annotations.count; j++) {
|
|
842
|
+
var annotation = annotations.at(j);
|
|
843
|
+
if (annotation && (!this._annotationTypes ||
|
|
844
|
+
this._annotationTypes.length === 0 ||
|
|
845
|
+
(this._annotationTypes && this._annotationTypes.length > 0 && this._checkAnnotationType(annotation)))) {
|
|
846
|
+
this._exportAnnotationData(annotation, writer, i);
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
}
|
|
850
|
+
}
|
|
851
|
+
writer._writeEndElement();
|
|
852
|
+
}
|
|
853
|
+
else {
|
|
854
|
+
var form = this._document.form;
|
|
855
|
+
if (form !== null && typeof form !== 'undefined') {
|
|
856
|
+
this._exportEmptyFields = form.exportEmptyFields;
|
|
857
|
+
var count = this._document.form.count;
|
|
858
|
+
for (var i = 0; i < count; i++) {
|
|
859
|
+
var field = this._document.form.fieldAt(i);
|
|
860
|
+
if (field !== null && typeof field !== 'undefined' && field.export) {
|
|
861
|
+
this._exportFormFieldData(field);
|
|
862
|
+
}
|
|
863
|
+
}
|
|
864
|
+
this._writeFormFieldData(writer, this._asPerSpecification);
|
|
865
|
+
}
|
|
866
|
+
}
|
|
867
|
+
if (!this._asPerSpecification) {
|
|
868
|
+
writer._writeStartElement('f');
|
|
869
|
+
writer._writeAttributeString('href', this._fileName);
|
|
870
|
+
}
|
|
871
|
+
var result = writer._save();
|
|
872
|
+
writer._destroy();
|
|
873
|
+
return result;
|
|
874
|
+
};
|
|
875
|
+
_XfdfDocument.prototype._writeFormFieldData = function (writer, isAcrobat) {
|
|
876
|
+
var _this = this;
|
|
877
|
+
if (isAcrobat === void 0) { isAcrobat = false; }
|
|
878
|
+
if (isAcrobat) {
|
|
879
|
+
writer._writeStartElement('f');
|
|
880
|
+
writer._writeAttributeString('href', this._fileName);
|
|
881
|
+
writer._writeEndElement();
|
|
882
|
+
var elements = this._getElements(this._table); // eslint-disable-line
|
|
883
|
+
if (elements && elements.size > 0) {
|
|
884
|
+
writer._writeStartElement('fields');
|
|
885
|
+
var flag_1 = false;
|
|
886
|
+
elements.forEach(function (value, key) {
|
|
887
|
+
writer._writeStartElement('field');
|
|
888
|
+
writer._writeAttributeString('name', key.toString());
|
|
889
|
+
if (Array.isArray(value)) {
|
|
890
|
+
value.forEach(function (item) {
|
|
891
|
+
writer._writeStartElement('value');
|
|
892
|
+
writer._writeString(item.toString());
|
|
893
|
+
writer._writeEndElement();
|
|
894
|
+
flag_1 = true;
|
|
895
|
+
});
|
|
896
|
+
}
|
|
897
|
+
if (value instanceof Map) {
|
|
898
|
+
_this._writeFieldName(value, writer);
|
|
899
|
+
}
|
|
900
|
+
else if (!flag_1 && !value.toString().endsWith(_this._formKey) || (!flag_1 && _this._formKey === '')) {
|
|
901
|
+
writer._writeStartElement('value');
|
|
902
|
+
writer._writeString(value.toString());
|
|
903
|
+
writer._writeEndElement();
|
|
904
|
+
}
|
|
905
|
+
else if (_this._formKey !== '' && value.toString().endsWith(_this._formKey)) {
|
|
906
|
+
writer._writeStartElement('value-richtext');
|
|
907
|
+
var text = value.toString();
|
|
908
|
+
if (text.startsWith('<?xml version="1.0"?>')) {
|
|
909
|
+
text = text.substring(21);
|
|
910
|
+
}
|
|
911
|
+
var start = text.length - _this._formKey.length;
|
|
912
|
+
text = text.substring(0, start) + text.substring(start + _this._formKey.length);
|
|
913
|
+
writer._writeRaw(text);
|
|
914
|
+
writer._writeEndElement();
|
|
915
|
+
}
|
|
916
|
+
writer._writeEndElement();
|
|
917
|
+
flag_1 = false;
|
|
918
|
+
});
|
|
919
|
+
writer._writeEndElement();
|
|
920
|
+
}
|
|
921
|
+
writer._writeStartElement('ids');
|
|
922
|
+
var hasId = false;
|
|
923
|
+
if (this._crossReference._root.has('ID')) {
|
|
924
|
+
var id = this._crossReference._root.getArray('ID');
|
|
925
|
+
if (id && id.length >= 1) {
|
|
926
|
+
writer._writeAttributeString('original', id[0]);
|
|
927
|
+
writer._writeAttributeString('modified', id[1]);
|
|
928
|
+
hasId = true;
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
if (!hasId) {
|
|
932
|
+
writer._writeAttributeString('original', '');
|
|
933
|
+
writer._writeAttributeString('modified', '');
|
|
934
|
+
}
|
|
935
|
+
writer._writeEndElement();
|
|
936
|
+
}
|
|
937
|
+
else {
|
|
938
|
+
writer._writeStartElement('fields');
|
|
939
|
+
this._table.forEach(function (value, key) {
|
|
940
|
+
writer._writeStartElement('field');
|
|
941
|
+
writer._writeAttributeString('name', key.toString());
|
|
942
|
+
if (Array.isArray(value)) {
|
|
943
|
+
value.forEach(function (item) {
|
|
944
|
+
writer._writeStartElement('value');
|
|
945
|
+
writer._writeString(item.toString());
|
|
946
|
+
writer._writeEndElement();
|
|
947
|
+
});
|
|
948
|
+
}
|
|
949
|
+
else {
|
|
950
|
+
writer._writeStartElement('value');
|
|
951
|
+
writer._writeString(value.toString());
|
|
952
|
+
writer._writeEndElement();
|
|
953
|
+
}
|
|
954
|
+
writer._writeEndElement();
|
|
955
|
+
});
|
|
956
|
+
writer._writeEndElement();
|
|
957
|
+
}
|
|
958
|
+
};
|
|
959
|
+
_XfdfDocument.prototype._writeFieldName = function (value, writer) {
|
|
960
|
+
var _this = this;
|
|
961
|
+
value.forEach(function (value, key) {
|
|
962
|
+
if (value instanceof Map) {
|
|
963
|
+
writer._writeStartElement('field');
|
|
964
|
+
writer._writeAttributeString('name', key.toString());
|
|
965
|
+
_this._writeFieldName(value, writer);
|
|
966
|
+
writer._writeEndElement();
|
|
967
|
+
}
|
|
968
|
+
else {
|
|
969
|
+
writer._writeStartElement('field');
|
|
970
|
+
writer._writeAttributeString('name', key.toString());
|
|
971
|
+
if (Array.isArray(value)) {
|
|
972
|
+
value.forEach(function (item) {
|
|
973
|
+
writer._writeStartElement('value');
|
|
974
|
+
writer._writeString(item.toString());
|
|
975
|
+
writer._writeEndElement();
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
else {
|
|
979
|
+
if (!value.toString().endsWith(_this._formKey) || _this._formKey === '') {
|
|
980
|
+
writer._writeStartElement('value');
|
|
981
|
+
writer._writeString(value.toString());
|
|
982
|
+
}
|
|
983
|
+
else {
|
|
984
|
+
writer._writeStartElement('value-richtext');
|
|
985
|
+
var text = value.toString();
|
|
986
|
+
if (text.startsWith('<?xml version="1.0"?>')) {
|
|
987
|
+
text = text.substring(21);
|
|
988
|
+
}
|
|
989
|
+
var start = text.length - _this._formKey.length;
|
|
990
|
+
text = text.substring(0, start) + text.substring(start + _this._formKey.length);
|
|
991
|
+
writer._writeRaw(text);
|
|
992
|
+
}
|
|
993
|
+
writer._writeEndElement();
|
|
994
|
+
}
|
|
995
|
+
writer._writeEndElement();
|
|
996
|
+
}
|
|
997
|
+
});
|
|
998
|
+
};
|
|
999
|
+
_XfdfDocument.prototype._getElements = function (table) {
|
|
1000
|
+
var _this = this;
|
|
1001
|
+
var elements = new Map(); // eslint-disable-line
|
|
1002
|
+
table.forEach(function (value, key) {
|
|
1003
|
+
var parentElements = elements; // eslint-disable-line
|
|
1004
|
+
if (key.toString().indexOf('.') !== -1) {
|
|
1005
|
+
var values = key.toString().split('.');
|
|
1006
|
+
for (var i = 0; i < values.length; i++) {
|
|
1007
|
+
var element = values[Number.parseInt(i.toString(), 10)];
|
|
1008
|
+
if (parentElements.has(element)) {
|
|
1009
|
+
_this._getElements(parentElements[element]); // eslint-disable-line
|
|
1010
|
+
parentElements = parentElements[element]; // eslint-disable-line
|
|
1011
|
+
}
|
|
1012
|
+
else {
|
|
1013
|
+
if (i === values.length - 1) {
|
|
1014
|
+
parentElements.set(element, value);
|
|
1015
|
+
}
|
|
1016
|
+
else {
|
|
1017
|
+
var newTable = new Map(); // eslint-disable-line
|
|
1018
|
+
parentElements.set(element, newTable);
|
|
1019
|
+
parentElements = newTable;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
else {
|
|
1025
|
+
parentElements.set(key, value);
|
|
1026
|
+
}
|
|
1027
|
+
});
|
|
1028
|
+
return elements;
|
|
1029
|
+
};
|
|
1030
|
+
_XfdfDocument.prototype._checkAnnotationType = function (annotation) {
|
|
1031
|
+
return (typeof annotation._type !== 'undefined' && this._annotationTypes.indexOf(annotation._type) !== -1);
|
|
1032
|
+
};
|
|
1033
|
+
_XfdfDocument.prototype._exportAnnotationData = function (annotation, writer, pageIndex) {
|
|
1034
|
+
if (annotation._dictionary &&
|
|
1035
|
+
!(annotation instanceof PdfFileLinkAnnotation ||
|
|
1036
|
+
annotation instanceof PdfTextWebLinkAnnotation ||
|
|
1037
|
+
annotation instanceof PdfDocumentLinkAnnotation ||
|
|
1038
|
+
annotation instanceof PdfUriAnnotation)) {
|
|
1039
|
+
this._writeAnnotationData(writer, pageIndex, annotation);
|
|
1040
|
+
}
|
|
1041
|
+
};
|
|
1042
|
+
_XfdfDocument.prototype._writeAnnotationData = function (writer, pageIndex, source) {
|
|
1043
|
+
var hasAppearance = false;
|
|
1044
|
+
var annotation;
|
|
1045
|
+
var dictionary;
|
|
1046
|
+
if (source instanceof PdfAnnotation) {
|
|
1047
|
+
annotation = source;
|
|
1048
|
+
dictionary = source._dictionary;
|
|
1049
|
+
}
|
|
1050
|
+
else {
|
|
1051
|
+
dictionary = source;
|
|
1052
|
+
}
|
|
1053
|
+
var type = this._getAnnotationType(dictionary);
|
|
1054
|
+
this._skipBorderStyle = false;
|
|
1055
|
+
if (type && type !== '') {
|
|
1056
|
+
if (!this._annotationAttributes) {
|
|
1057
|
+
this._annotationAttributes = [];
|
|
1058
|
+
}
|
|
1059
|
+
writer._writeStartElement(type.toLowerCase());
|
|
1060
|
+
writer._writeAttributeString('page', pageIndex.toString());
|
|
1061
|
+
var lineAnnotation = void 0;
|
|
1062
|
+
var points = void 0;
|
|
1063
|
+
switch (type) {
|
|
1064
|
+
case 'Line':
|
|
1065
|
+
lineAnnotation = annotation;
|
|
1066
|
+
points = lineAnnotation.linePoints;
|
|
1067
|
+
writer._writeAttributeString('start', points[0].toString() + ',' + points[1].toString());
|
|
1068
|
+
writer._writeAttributeString('end', points[2].toString() + ',' + points[3].toString());
|
|
1069
|
+
break;
|
|
1070
|
+
case 'Stamp':
|
|
1071
|
+
hasAppearance = true;
|
|
1072
|
+
break;
|
|
1073
|
+
case 'Square':
|
|
1074
|
+
hasAppearance = true;
|
|
1075
|
+
break;
|
|
1076
|
+
}
|
|
1077
|
+
if (dictionary && dictionary.has('BE') && dictionary.has('BS')) {
|
|
1078
|
+
var borderEffect = dictionary.get('BE');
|
|
1079
|
+
if (borderEffect && borderEffect.has('S')) {
|
|
1080
|
+
this._skipBorderStyle = true;
|
|
1081
|
+
}
|
|
1082
|
+
}
|
|
1083
|
+
this._writeDictionary(dictionary, pageIndex, writer, hasAppearance);
|
|
1084
|
+
writer._writeEndElement();
|
|
1085
|
+
this._annotationAttributes = [];
|
|
1086
|
+
}
|
|
1087
|
+
};
|
|
1088
|
+
_XfdfDocument.prototype._writeDictionary = function (dictionary, pageIndex, writer, hasAppearance) {
|
|
1089
|
+
var _this = this;
|
|
1090
|
+
var isBorderStyle = false;
|
|
1091
|
+
if (dictionary.has('Type')) {
|
|
1092
|
+
var type = dictionary.get('Type');
|
|
1093
|
+
isBorderStyle = (type && type.name === 'Border' && this._skipBorderStyle);
|
|
1094
|
+
}
|
|
1095
|
+
dictionary.forEach(function (key, value) {
|
|
1096
|
+
if (!((!hasAppearance && key === 'AP') || key === 'P' || key === 'Parent')) {
|
|
1097
|
+
var entry = void 0; // eslint-disable-line
|
|
1098
|
+
if (value instanceof _PdfReference) {
|
|
1099
|
+
entry = dictionary.get(key);
|
|
1100
|
+
}
|
|
1101
|
+
if (entry && entry instanceof _PdfDictionary) {
|
|
1102
|
+
switch (key) {
|
|
1103
|
+
case 'BS':
|
|
1104
|
+
_this._writeDictionary(entry, pageIndex, writer, false);
|
|
1105
|
+
break;
|
|
1106
|
+
case 'BE':
|
|
1107
|
+
_this._writeDictionary(entry, pageIndex, writer, false);
|
|
1108
|
+
break;
|
|
1109
|
+
case 'IRT':
|
|
1110
|
+
if (entry.has('NM')) {
|
|
1111
|
+
writer._writeAttributeString('inreplyto', _this._getValue(entry.get('NM')));
|
|
1112
|
+
}
|
|
1113
|
+
break;
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
else if (value instanceof _PdfDictionary) {
|
|
1117
|
+
_this._writeDictionary(value, pageIndex, writer, false);
|
|
1118
|
+
}
|
|
1119
|
+
else if ((!isBorderStyle) || (isBorderStyle && key !== 'S')) {
|
|
1120
|
+
_this._writeAttribute(writer, key, value);
|
|
1121
|
+
}
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
if ((this.exportAppearance || hasAppearance) && dictionary.has('AP')) {
|
|
1125
|
+
var stream = this._getAppearanceString(dictionary.get('AP'));
|
|
1126
|
+
if (stream && stream.length > 0) {
|
|
1127
|
+
writer._writeStartElement('appearance');
|
|
1128
|
+
writer._writeRaw(_encode(stream));
|
|
1129
|
+
writer._writeEndElement();
|
|
1130
|
+
}
|
|
1131
|
+
}
|
|
1132
|
+
if (dictionary.has('Measure')) {
|
|
1133
|
+
this._exportMeasureDictionary(dictionary.get('Measure'), writer);
|
|
1134
|
+
}
|
|
1135
|
+
if (dictionary.has('Sound')) {
|
|
1136
|
+
var sound = dictionary.get('Sound');
|
|
1137
|
+
if (sound && sound.dictionary) {
|
|
1138
|
+
var soundDictionary = sound.dictionary;
|
|
1139
|
+
if (soundDictionary.has('B')) {
|
|
1140
|
+
writer._writeAttributeString('bits', this._getValue(soundDictionary.get('B')));
|
|
1141
|
+
}
|
|
1142
|
+
if (soundDictionary.has('C')) {
|
|
1143
|
+
writer._writeAttributeString('channels', this._getValue(soundDictionary.get('C')));
|
|
1144
|
+
}
|
|
1145
|
+
if (soundDictionary.has('E')) {
|
|
1146
|
+
writer._writeAttributeString('encoding', this._getValue(soundDictionary.get('E')));
|
|
1147
|
+
}
|
|
1148
|
+
if (soundDictionary.has('R')) {
|
|
1149
|
+
writer._writeAttributeString('rate', this._getValue(soundDictionary.get('R')));
|
|
1150
|
+
}
|
|
1151
|
+
if (soundDictionary.has('Length') && soundDictionary.get('Length') > 0) {
|
|
1152
|
+
var data = _byteArrayToHexString(sound.getBytes());
|
|
1153
|
+
if (data && data !== '') {
|
|
1154
|
+
writer._writeStartElement('data');
|
|
1155
|
+
writer._writeAttributeString('MODE', 'raw');
|
|
1156
|
+
writer._writeAttributeString('encoding', 'hex');
|
|
1157
|
+
if (soundDictionary.has('Length')) {
|
|
1158
|
+
writer._writeAttributeString('length', this._getValue(soundDictionary.get('Length')));
|
|
1159
|
+
}
|
|
1160
|
+
if (soundDictionary.has('Filter')) {
|
|
1161
|
+
writer._writeAttributeString('filter', this._getValue(soundDictionary.get('Filter')));
|
|
1162
|
+
}
|
|
1163
|
+
writer._writeRaw(data);
|
|
1164
|
+
writer._writeEndElement();
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
else if (dictionary.has('FS')) {
|
|
1170
|
+
var fsDictionary = dictionary.get('FS');
|
|
1171
|
+
if (fsDictionary) {
|
|
1172
|
+
if (fsDictionary.has('F')) {
|
|
1173
|
+
writer._writeAttributeString('file', this._getValue(fsDictionary.get('F')));
|
|
1174
|
+
}
|
|
1175
|
+
if (fsDictionary.has('EF')) {
|
|
1176
|
+
var efDictionary = fsDictionary.get('EF');
|
|
1177
|
+
if (efDictionary && efDictionary.has('F')) {
|
|
1178
|
+
var fStream = efDictionary.get('F');
|
|
1179
|
+
if (fStream && fStream.dictionary) {
|
|
1180
|
+
var fDictionary = fStream.dictionary;
|
|
1181
|
+
if (fDictionary.has('Params')) {
|
|
1182
|
+
var paramsDictionary = fDictionary.get('Params');
|
|
1183
|
+
if (paramsDictionary) {
|
|
1184
|
+
if (paramsDictionary.has('CreationDate')) {
|
|
1185
|
+
var value = this._getValue(paramsDictionary.get('CreationDate'));
|
|
1186
|
+
writer._writeAttributeString('creation', value);
|
|
1187
|
+
}
|
|
1188
|
+
if (paramsDictionary.has('ModificationDate')) {
|
|
1189
|
+
var value = this._getValue(paramsDictionary.get('ModificationDate'));
|
|
1190
|
+
writer._writeAttributeString('modification', value);
|
|
1191
|
+
}
|
|
1192
|
+
if (paramsDictionary.has('Size')) {
|
|
1193
|
+
writer._writeAttributeString('size', this._getValue(paramsDictionary.get('Size')));
|
|
1194
|
+
}
|
|
1195
|
+
if (paramsDictionary.has('CheckSum')) {
|
|
1196
|
+
var value = this._getValue(paramsDictionary.get('CheckSum'));
|
|
1197
|
+
var checksum = _stringToBytes(value);
|
|
1198
|
+
var hexString = _byteArrayToHexString(checksum);
|
|
1199
|
+
writer._writeAttributeString('checksum', hexString);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
var data = _byteArrayToHexString(fStream.getBytes());
|
|
1204
|
+
if (data && data !== '') {
|
|
1205
|
+
writer._writeStartElement('data');
|
|
1206
|
+
writer._writeAttributeString('MODE', 'raw');
|
|
1207
|
+
writer._writeAttributeString('encoding', 'hex');
|
|
1208
|
+
if (fDictionary.has('Length')) {
|
|
1209
|
+
writer._writeAttributeString('length', this._getValue(fDictionary.get('Length')));
|
|
1210
|
+
}
|
|
1211
|
+
if (fDictionary.has('Filter')) {
|
|
1212
|
+
writer._writeAttributeString('filter', this._getValue(fDictionary.get('Filter')));
|
|
1213
|
+
}
|
|
1214
|
+
writer._writeRaw(data);
|
|
1215
|
+
writer._writeEndElement();
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
}
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
}
|
|
1222
|
+
if (dictionary.has('Vertices')) {
|
|
1223
|
+
writer._writeStartElement('vertices');
|
|
1224
|
+
var vertices = dictionary.getArray('Vertices');
|
|
1225
|
+
if (vertices && vertices.length > 0) {
|
|
1226
|
+
var elementCount = vertices.length;
|
|
1227
|
+
if (elementCount % 2 === 0) {
|
|
1228
|
+
var value = '';
|
|
1229
|
+
for (var i = 0; i < elementCount - 1; i++) {
|
|
1230
|
+
value += this._getValue(vertices[Number.parseInt(i.toString(), 10)]) + (i % 2 !== 0 ? ';' : ',');
|
|
1231
|
+
}
|
|
1232
|
+
value += this._getValue(vertices[elementCount - 1]);
|
|
1233
|
+
if (value && value !== '') {
|
|
1234
|
+
writer._writeRaw(value);
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
writer._writeEndElement();
|
|
1239
|
+
}
|
|
1240
|
+
if (dictionary.has('Popup')) {
|
|
1241
|
+
var popup = dictionary.get('Popup');
|
|
1242
|
+
if (popup) {
|
|
1243
|
+
this._writeAnnotationData(writer, pageIndex, popup);
|
|
1244
|
+
}
|
|
1245
|
+
}
|
|
1246
|
+
if (dictionary.has('DA')) {
|
|
1247
|
+
var defaultAppearance = dictionary.get('DA');
|
|
1248
|
+
if (defaultAppearance) {
|
|
1249
|
+
this._writeRawData(writer, 'defaultappearance', defaultAppearance);
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
if (dictionary.has('DS')) {
|
|
1253
|
+
var defaultStyle = dictionary.get('DS');
|
|
1254
|
+
if (defaultStyle) {
|
|
1255
|
+
this._writeRawData(writer, 'defaultstyle', defaultStyle);
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
if (dictionary.has('InkList')) {
|
|
1259
|
+
var inkList = dictionary.getArray('InkList');
|
|
1260
|
+
if (inkList && inkList.length > 0) {
|
|
1261
|
+
writer._writeStartElement('inklist');
|
|
1262
|
+
for (var j = 0; j < inkList.length; j++) {
|
|
1263
|
+
writer._writeElementString('gesture', this._getValue(inkList[Number.parseInt(j.toString(), 10)]));
|
|
1264
|
+
}
|
|
1265
|
+
writer._writeEndElement();
|
|
1266
|
+
}
|
|
1267
|
+
}
|
|
1268
|
+
if (dictionary.has('RC')) {
|
|
1269
|
+
var value = dictionary.get('RC');
|
|
1270
|
+
if (value && value !== '') {
|
|
1271
|
+
var index = value.indexOf('<body');
|
|
1272
|
+
if (index > 0) {
|
|
1273
|
+
value = value.substring(index);
|
|
1274
|
+
}
|
|
1275
|
+
this._writeRawData(writer, 'contents-richtext', value);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
if (dictionary.has('Contents')) {
|
|
1279
|
+
var value = dictionary.get('Contents');
|
|
1280
|
+
if (value && value.length > 0) {
|
|
1281
|
+
writer._writeStartElement('contents');
|
|
1282
|
+
writer._writeString(value);
|
|
1283
|
+
writer._writeEndElement();
|
|
1284
|
+
}
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
_XfdfDocument.prototype._getAppearanceString = function (appearance) {
|
|
1288
|
+
var textWriter = new _XmlWriter(true);
|
|
1289
|
+
textWriter._writeStartElement('DICT');
|
|
1290
|
+
textWriter._writeAttributeString('KEY', 'AP');
|
|
1291
|
+
this._writeAppearanceDictionary(textWriter, appearance);
|
|
1292
|
+
textWriter._writeEndElement();
|
|
1293
|
+
var buffer = textWriter.buffer;
|
|
1294
|
+
textWriter._destroy();
|
|
1295
|
+
return buffer;
|
|
1296
|
+
};
|
|
1297
|
+
_XfdfDocument.prototype._writeAppearanceDictionary = function (writer, dictionary) {
|
|
1298
|
+
var _this = this;
|
|
1299
|
+
if (dictionary && dictionary.size > 0) {
|
|
1300
|
+
dictionary.forEach(function (key, value) {
|
|
1301
|
+
_this._writeObject(writer, value instanceof _PdfReference ? dictionary.get(key) : value, dictionary, key);
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
};
|
|
1305
|
+
_XfdfDocument.prototype._writeObject = function (writer, primitive, dictionary, key) {
|
|
1306
|
+
if (primitive) {
|
|
1307
|
+
if (primitive instanceof _PdfName) {
|
|
1308
|
+
this._writePrefix(writer, 'NAME', key);
|
|
1309
|
+
writer._writeAttributeString('VAL', primitive.name);
|
|
1310
|
+
writer._writeEndElement();
|
|
1311
|
+
}
|
|
1312
|
+
else if (Array.isArray(primitive)) {
|
|
1313
|
+
this._writePrefix(writer, 'ARRAY', key);
|
|
1314
|
+
this._writeArray(writer, dictionary.getArray(key), dictionary);
|
|
1315
|
+
writer._writeEndElement();
|
|
1316
|
+
}
|
|
1317
|
+
else if (typeof primitive === 'string') {
|
|
1318
|
+
this._writePrefix(writer, 'STRING', key);
|
|
1319
|
+
writer._writeAttributeString('VAL', primitive);
|
|
1320
|
+
writer._writeEndElement();
|
|
1321
|
+
}
|
|
1322
|
+
else if (typeof primitive === 'number') {
|
|
1323
|
+
if (Number.isInteger(primitive)) {
|
|
1324
|
+
this._writePrefix(writer, 'INT', key);
|
|
1325
|
+
writer._writeAttributeString('VAL', primitive.toString());
|
|
1326
|
+
}
|
|
1327
|
+
else {
|
|
1328
|
+
this._writePrefix(writer, 'FIXED', key);
|
|
1329
|
+
writer._writeAttributeString('VAL', primitive.toFixed(6));
|
|
1330
|
+
}
|
|
1331
|
+
writer._writeEndElement();
|
|
1332
|
+
}
|
|
1333
|
+
else if (typeof primitive === 'boolean') {
|
|
1334
|
+
this._writePrefix(writer, 'BOOL', key);
|
|
1335
|
+
writer._writeAttributeString('VAL', primitive ? 'true' : 'false');
|
|
1336
|
+
writer._writeEndElement();
|
|
1337
|
+
}
|
|
1338
|
+
else if (primitive instanceof _PdfDictionary) {
|
|
1339
|
+
this._writePrefix(writer, 'DICT', key);
|
|
1340
|
+
this._writeAppearanceDictionary(writer, primitive);
|
|
1341
|
+
writer._writeEndElement();
|
|
1342
|
+
}
|
|
1343
|
+
else if (primitive === null) {
|
|
1344
|
+
this._writePrefix(writer, 'NULL', key);
|
|
1345
|
+
writer._writeEndElement();
|
|
1346
|
+
}
|
|
1347
|
+
else if (primitive instanceof _PdfBaseStream && primitive.dictionary) {
|
|
1348
|
+
var streamDictionary = primitive.dictionary;
|
|
1349
|
+
this._writePrefix(writer, 'STREAM', key);
|
|
1350
|
+
writer._writeAttributeString('DEFINE', '');
|
|
1351
|
+
this._writeAppearanceDictionary(writer, streamDictionary);
|
|
1352
|
+
writer._writeStartElement('DATA');
|
|
1353
|
+
var length_1 = streamDictionary.get('Length');
|
|
1354
|
+
if (length_1 > 0 && (streamDictionary.has('Subtype') &&
|
|
1355
|
+
this._getValue(streamDictionary.get('Subtype')) === 'Image') ||
|
|
1356
|
+
(!streamDictionary.has('Type') && !streamDictionary.has('Subtype'))) {
|
|
1357
|
+
writer._writeAttributeString('MODE', 'RAW');
|
|
1358
|
+
writer._writeAttributeString('ENCODING', 'HEX');
|
|
1359
|
+
var data = primitive.getString();
|
|
1360
|
+
if (data && data !== '') {
|
|
1361
|
+
writer._writeRaw(data);
|
|
1362
|
+
}
|
|
1363
|
+
}
|
|
1364
|
+
else if (length_1 > 0) {
|
|
1365
|
+
writer._writeAttributeString('MODE', 'FILTERED');
|
|
1366
|
+
writer._writeAttributeString('ENCODING', 'ASCII');
|
|
1367
|
+
var data = primitive.getString();
|
|
1368
|
+
if (data && data !== '') {
|
|
1369
|
+
writer._writeRaw(data);
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
writer._writeEndElement();
|
|
1373
|
+
writer._writeEndElement();
|
|
1374
|
+
}
|
|
1375
|
+
else if (primitive instanceof _PdfReference && this._crossReference) {
|
|
1376
|
+
this._writeObject(writer, this._crossReference._fetch(primitive), dictionary, key);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
};
|
|
1380
|
+
_XfdfDocument.prototype._writePrefix = function (writer, name, key) {
|
|
1381
|
+
writer._writeStartElement(name);
|
|
1382
|
+
if (key) {
|
|
1383
|
+
writer._writeAttributeString('KEY', key);
|
|
1384
|
+
}
|
|
1385
|
+
};
|
|
1386
|
+
_XfdfDocument.prototype._writeArray = function (writer, array, dictionary) {
|
|
1387
|
+
var _this = this;
|
|
1388
|
+
array.forEach(function (entry) {
|
|
1389
|
+
_this._writeObject(writer, entry, dictionary);
|
|
1390
|
+
});
|
|
1391
|
+
};
|
|
1392
|
+
_XfdfDocument.prototype._getFormatedString = function (value, isParsing) {
|
|
1393
|
+
if (isParsing === void 0) { isParsing = false; }
|
|
1394
|
+
if (isParsing) {
|
|
1395
|
+
value = value.replace('&', '&');
|
|
1396
|
+
value = value.replace('<', '<');
|
|
1397
|
+
value = value.replace('>', '>');
|
|
1398
|
+
}
|
|
1399
|
+
else {
|
|
1400
|
+
value = value.replace('&', '&');
|
|
1401
|
+
value = value.replace('<', '<');
|
|
1402
|
+
value = value.replace('>', '>');
|
|
1403
|
+
}
|
|
1404
|
+
return value;
|
|
1405
|
+
};
|
|
1406
|
+
_XfdfDocument.prototype._writeAttribute = function (writer, key, primitive) {
|
|
1407
|
+
if (this._annotationAttributes && this._annotationAttributes.indexOf(key) === -1) {
|
|
1408
|
+
switch (key) {
|
|
1409
|
+
case 'C':
|
|
1410
|
+
this._writeColor(writer, primitive, 'color', 'c');
|
|
1411
|
+
break;
|
|
1412
|
+
case 'IC':
|
|
1413
|
+
this._writeColor(writer, primitive, 'interior-color');
|
|
1414
|
+
break;
|
|
1415
|
+
case 'M':
|
|
1416
|
+
this._writeAttributeString(writer, 'date', primitive);
|
|
1417
|
+
break;
|
|
1418
|
+
case 'NM':
|
|
1419
|
+
this._writeAttributeString(writer, 'name', primitive);
|
|
1420
|
+
break;
|
|
1421
|
+
case 'Name':
|
|
1422
|
+
this._writeAttributeString(writer, 'icon', primitive);
|
|
1423
|
+
break;
|
|
1424
|
+
case 'Subj':
|
|
1425
|
+
this._writeAttributeString(writer, 'subject', primitive);
|
|
1426
|
+
break;
|
|
1427
|
+
case 'T':
|
|
1428
|
+
this._writeAttributeString(writer, 'title', primitive);
|
|
1429
|
+
break;
|
|
1430
|
+
case 'Rotate':
|
|
1431
|
+
this._writeAttributeString(writer, 'rotation', primitive);
|
|
1432
|
+
break;
|
|
1433
|
+
case 'W':
|
|
1434
|
+
this._writeAttributeString(writer, 'width', primitive);
|
|
1435
|
+
break;
|
|
1436
|
+
case 'LE':
|
|
1437
|
+
if (primitive && Array.isArray(primitive)) {
|
|
1438
|
+
if (primitive.length === 2) {
|
|
1439
|
+
writer._writeAttributeString('head', this._getValue(primitive[0]));
|
|
1440
|
+
writer._writeAttributeString('tail', this._getValue(primitive[1]));
|
|
1441
|
+
}
|
|
1442
|
+
}
|
|
1443
|
+
else if (primitive instanceof _PdfName) {
|
|
1444
|
+
this._writeAttributeString(writer, 'head', primitive);
|
|
1445
|
+
}
|
|
1446
|
+
break;
|
|
1447
|
+
case 'S':
|
|
1448
|
+
if (this._annotationAttributes.indexOf('style') === -1) {
|
|
1449
|
+
switch (this._getValue(primitive)) {
|
|
1450
|
+
case 'D':
|
|
1451
|
+
writer._writeAttributeString('style', 'dash');
|
|
1452
|
+
break;
|
|
1453
|
+
case 'C':
|
|
1454
|
+
writer._writeAttributeString('style', 'cloudy');
|
|
1455
|
+
break;
|
|
1456
|
+
case 'S':
|
|
1457
|
+
writer._writeAttributeString('style', 'solid');
|
|
1458
|
+
break;
|
|
1459
|
+
case 'B':
|
|
1460
|
+
writer._writeAttributeString('style', 'bevelled');
|
|
1461
|
+
break;
|
|
1462
|
+
case 'I':
|
|
1463
|
+
writer._writeAttributeString('style', 'inset');
|
|
1464
|
+
break;
|
|
1465
|
+
case 'U':
|
|
1466
|
+
writer._writeAttributeString('style', 'underline');
|
|
1467
|
+
break;
|
|
1468
|
+
}
|
|
1469
|
+
this._annotationAttributes.push('style');
|
|
1470
|
+
}
|
|
1471
|
+
break;
|
|
1472
|
+
case 'D':
|
|
1473
|
+
this._writeAttributeString(writer, 'dashes', primitive);
|
|
1474
|
+
break;
|
|
1475
|
+
case 'I':
|
|
1476
|
+
this._writeAttributeString(writer, 'intensity', primitive);
|
|
1477
|
+
break;
|
|
1478
|
+
case 'RD':
|
|
1479
|
+
this._writeAttributeString(writer, 'fringe', primitive);
|
|
1480
|
+
break;
|
|
1481
|
+
case 'IT':
|
|
1482
|
+
this._writeAttributeString(writer, 'IT', primitive);
|
|
1483
|
+
break;
|
|
1484
|
+
case 'RT':
|
|
1485
|
+
this._writeAttributeString(writer, 'replyType', primitive, true);
|
|
1486
|
+
break;
|
|
1487
|
+
case 'LL':
|
|
1488
|
+
this._writeAttributeString(writer, 'leaderLength', primitive);
|
|
1489
|
+
break;
|
|
1490
|
+
case 'LLE':
|
|
1491
|
+
this._writeAttributeString(writer, 'leaderExtend', primitive);
|
|
1492
|
+
break;
|
|
1493
|
+
case 'Cap':
|
|
1494
|
+
this._writeAttributeString(writer, 'caption', primitive);
|
|
1495
|
+
break;
|
|
1496
|
+
case 'Q':
|
|
1497
|
+
this._writeAttributeString(writer, 'justification', primitive);
|
|
1498
|
+
break;
|
|
1499
|
+
case 'CP':
|
|
1500
|
+
this._writeAttributeString(writer, 'caption-style', primitive);
|
|
1501
|
+
break;
|
|
1502
|
+
case 'CL':
|
|
1503
|
+
this._writeAttributeString(writer, 'callout', primitive);
|
|
1504
|
+
break;
|
|
1505
|
+
case 'QuadPoints':
|
|
1506
|
+
this._writeAttributeString(writer, 'coords', primitive);
|
|
1507
|
+
break;
|
|
1508
|
+
case 'CA':
|
|
1509
|
+
this._writeAttributeString(writer, 'opacity', primitive);
|
|
1510
|
+
break;
|
|
1511
|
+
case 'F':
|
|
1512
|
+
if (typeof primitive === 'number' && this._annotationAttributes.indexOf('flags') === -1) {
|
|
1513
|
+
var flag = _annotationFlagsToString(primitive);
|
|
1514
|
+
writer._writeAttributeString('flags', flag);
|
|
1515
|
+
this._annotationAttributes.push('flags');
|
|
1516
|
+
}
|
|
1517
|
+
break;
|
|
1518
|
+
case 'InkList':
|
|
1519
|
+
case 'Type':
|
|
1520
|
+
case 'Subtype':
|
|
1521
|
+
case 'P':
|
|
1522
|
+
case 'Parent':
|
|
1523
|
+
case 'L':
|
|
1524
|
+
case 'Contents':
|
|
1525
|
+
case 'RC':
|
|
1526
|
+
case 'DA':
|
|
1527
|
+
case 'DS':
|
|
1528
|
+
case 'FS':
|
|
1529
|
+
case 'MeasurementTypes':
|
|
1530
|
+
case 'Vertices':
|
|
1531
|
+
case 'GroupNesting':
|
|
1532
|
+
case 'ITEx':
|
|
1533
|
+
break;
|
|
1534
|
+
default:
|
|
1535
|
+
this._writeAttributeString(writer, key.toLowerCase(), primitive);
|
|
1536
|
+
break;
|
|
1537
|
+
}
|
|
1538
|
+
}
|
|
1539
|
+
};
|
|
1540
|
+
_XfdfDocument.prototype._writeAttributeString = function (writer, attribute, primitive, isLowerCase) {
|
|
1541
|
+
if (isLowerCase === void 0) { isLowerCase = false; }
|
|
1542
|
+
if (this._annotationAttributes.indexOf(attribute) === -1) {
|
|
1543
|
+
var value = this._getValue(primitive);
|
|
1544
|
+
writer._writeAttributeString(attribute, isLowerCase ? value.toLowerCase() : value);
|
|
1545
|
+
this._annotationAttributes.push(attribute);
|
|
1546
|
+
}
|
|
1547
|
+
};
|
|
1548
|
+
_XfdfDocument.prototype._writeRawData = function (writer, name, value) {
|
|
1549
|
+
if (value && value !== '') {
|
|
1550
|
+
writer._writeStartElement(name);
|
|
1551
|
+
writer._writeRaw(value);
|
|
1552
|
+
writer._writeEndElement();
|
|
1553
|
+
}
|
|
1554
|
+
};
|
|
1555
|
+
_XfdfDocument.prototype._writeColor = function (writer, primitive, attribute, tag) {
|
|
1556
|
+
var color = this._getColor(primitive);
|
|
1557
|
+
if (typeof primitive === 'number' && tag) {
|
|
1558
|
+
var c = this._getValue(primitive);
|
|
1559
|
+
if (c && c !== '' && this._annotationAttributes.indexOf(tag) === -1) {
|
|
1560
|
+
writer._writeAttributeString(tag, c);
|
|
1561
|
+
this._annotationAttributes.push(tag);
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
if (color && color !== '' && this._annotationAttributes.indexOf(attribute) === -1) {
|
|
1565
|
+
writer._writeAttributeString(attribute, color);
|
|
1566
|
+
this._annotationAttributes.push(attribute);
|
|
1567
|
+
}
|
|
1568
|
+
};
|
|
1569
|
+
_XfdfDocument.prototype._exportMeasureDictionary = function (dictionary, writer) {
|
|
1570
|
+
writer._writeStartElement('measure');
|
|
1571
|
+
if (dictionary) {
|
|
1572
|
+
if (dictionary.has('R')) {
|
|
1573
|
+
writer._writeAttributeString('rateValue', this._getValue(dictionary.get('R')));
|
|
1574
|
+
}
|
|
1575
|
+
if (dictionary.has('A')) {
|
|
1576
|
+
var array = dictionary.getArray('A');
|
|
1577
|
+
writer._writeStartElement('area');
|
|
1578
|
+
this._exportMeasureFormatDetails(array[0], writer);
|
|
1579
|
+
writer._writeEndElement();
|
|
1580
|
+
}
|
|
1581
|
+
if (dictionary.has('D')) {
|
|
1582
|
+
var array = dictionary.getArray('D');
|
|
1583
|
+
writer._writeStartElement('distance');
|
|
1584
|
+
this._exportMeasureFormatDetails(array[0], writer);
|
|
1585
|
+
writer._writeEndElement();
|
|
1586
|
+
}
|
|
1587
|
+
if (dictionary.has('X')) {
|
|
1588
|
+
var array = dictionary.getArray('X');
|
|
1589
|
+
writer._writeStartElement('xformat');
|
|
1590
|
+
this._exportMeasureFormatDetails(array[0], writer);
|
|
1591
|
+
writer._writeEndElement();
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
writer._writeEndElement();
|
|
1595
|
+
};
|
|
1596
|
+
_XfdfDocument.prototype._exportMeasureFormatDetails = function (measurementDetails, writer) {
|
|
1597
|
+
if (measurementDetails.has('C')) {
|
|
1598
|
+
writer._writeAttributeString('c', this._getValue(measurementDetails.get('C')));
|
|
1599
|
+
}
|
|
1600
|
+
if (measurementDetails.has('F')) {
|
|
1601
|
+
writer._writeAttributeString('f', this._getValue(measurementDetails.get('F')));
|
|
1602
|
+
}
|
|
1603
|
+
if (measurementDetails.has('D')) {
|
|
1604
|
+
writer._writeAttributeString('d', this._getValue(measurementDetails.get('D')));
|
|
1605
|
+
}
|
|
1606
|
+
if (measurementDetails.has('RD')) {
|
|
1607
|
+
writer._writeAttributeString('rd', this._getValue(measurementDetails.get('RD')));
|
|
1608
|
+
}
|
|
1609
|
+
if (measurementDetails.has('U')) {
|
|
1610
|
+
writer._writeAttributeString('u', this._getValue(measurementDetails.get('U')));
|
|
1611
|
+
}
|
|
1612
|
+
if (measurementDetails.has('RT')) {
|
|
1613
|
+
writer._writeAttributeString('rt', this._getValue(measurementDetails.get('RT')));
|
|
1614
|
+
}
|
|
1615
|
+
if (measurementDetails.has('SS')) {
|
|
1616
|
+
writer._writeAttributeString('ss', this._getValue(measurementDetails.get('SS')));
|
|
1617
|
+
}
|
|
1618
|
+
if (measurementDetails.has('FD')) {
|
|
1619
|
+
writer._writeAttributeString('fd', this._getValue(measurementDetails.get('FD')));
|
|
1620
|
+
}
|
|
1621
|
+
};
|
|
1622
|
+
//#endregion Export Annotations
|
|
1623
|
+
//#region Import Annotations
|
|
1624
|
+
_XfdfDocument.prototype._importAnnotations = function (document, data) {
|
|
1625
|
+
this._document = document;
|
|
1626
|
+
this._crossReference = document._crossReference;
|
|
1627
|
+
this._isAnnotationExport = false;
|
|
1628
|
+
var xml = _bytesToString(data);
|
|
1629
|
+
this._xmlDocument = (new DOMParser()).parseFromString(xml, 'text/xml');
|
|
1630
|
+
this._isAnnotationImport = true;
|
|
1631
|
+
this._readXmlData(this._xmlDocument.documentElement);
|
|
1632
|
+
};
|
|
1633
|
+
_XfdfDocument.prototype._importFormData = function (document, data) {
|
|
1634
|
+
this._document = document;
|
|
1635
|
+
this._crossReference = document._crossReference;
|
|
1636
|
+
this._isAnnotationExport = false;
|
|
1637
|
+
this._xmlDocument = (new DOMParser()).parseFromString(_bytesToString(data), 'text/xml');
|
|
1638
|
+
this._readXmlData(this._xmlDocument.documentElement);
|
|
1639
|
+
};
|
|
1640
|
+
_XfdfDocument.prototype._readXmlData = function (root) {
|
|
1641
|
+
if (root && root.nodeType === 1) {
|
|
1642
|
+
this._checkXfdf(root);
|
|
1643
|
+
if (this._isAnnotationImport) {
|
|
1644
|
+
var xList = root.getElementsByTagName('annots');
|
|
1645
|
+
if (xList && xList.length > 0) {
|
|
1646
|
+
for (var i = 0; i < xList.length; i++) {
|
|
1647
|
+
var child = xList.item(i);
|
|
1648
|
+
if (child && child.localName === 'annots' && child.hasChildNodes()) {
|
|
1649
|
+
var childeNodes = child.childNodes;
|
|
1650
|
+
for (var j = 0; j < childeNodes.length; j++) {
|
|
1651
|
+
var childNode = childeNodes.item(j);
|
|
1652
|
+
if (childNode && childNode.nodeType === 1) {
|
|
1653
|
+
var element = childNode;
|
|
1654
|
+
if (element && element.nodeType === 1) {
|
|
1655
|
+
this._parseAnnotationData(element);
|
|
1656
|
+
}
|
|
1657
|
+
}
|
|
1658
|
+
}
|
|
1659
|
+
}
|
|
1660
|
+
}
|
|
1661
|
+
}
|
|
1662
|
+
if (this._groupHolders.length > 0) {
|
|
1663
|
+
for (var i = 0; i < this._groupHolders.length; i++) {
|
|
1664
|
+
var dictionary = this._groupHolders[Number.parseInt(i.toString(), 10)];
|
|
1665
|
+
var inReplyTo = dictionary.get('IRT');
|
|
1666
|
+
if (inReplyTo && inReplyTo !== '') {
|
|
1667
|
+
if (this._groupReferences.has(inReplyTo)) {
|
|
1668
|
+
dictionary.update('IRT', this._groupReferences.get(inReplyTo));
|
|
1669
|
+
}
|
|
1670
|
+
else {
|
|
1671
|
+
delete dictionary._map.IRT;
|
|
1672
|
+
}
|
|
1673
|
+
}
|
|
1674
|
+
}
|
|
1675
|
+
}
|
|
1676
|
+
this._groupHolders = [];
|
|
1677
|
+
this._groupReferences = new Map();
|
|
1678
|
+
}
|
|
1679
|
+
else {
|
|
1680
|
+
this._parseFormData(root);
|
|
1681
|
+
}
|
|
1682
|
+
}
|
|
1683
|
+
this._dispose();
|
|
1684
|
+
};
|
|
1685
|
+
_XfdfDocument.prototype._checkXfdf = function (element) {
|
|
1686
|
+
if (element.nodeName !== 'xfdf') {
|
|
1687
|
+
throw new Error('Invalid XFDF file.');
|
|
1688
|
+
}
|
|
1689
|
+
};
|
|
1690
|
+
_XfdfDocument.prototype._parseFormData = function (root) {
|
|
1691
|
+
var list = root.getElementsByTagName('f');
|
|
1692
|
+
if (list && list.length > 0) {
|
|
1693
|
+
var fileNameElement = list.item(0);
|
|
1694
|
+
if (fileNameElement && fileNameElement.localName === 'f' && fileNameElement.hasAttribute('href')) {
|
|
1695
|
+
var fileName = fileNameElement.getAttribute('href');
|
|
1696
|
+
if (fileName && fileName !== '') {
|
|
1697
|
+
this._fileName = fileName;
|
|
1698
|
+
}
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1701
|
+
list = root.getElementsByTagName('ids');
|
|
1702
|
+
if (list && list.length > 0) {
|
|
1703
|
+
this._asPerSpecification = true;
|
|
1704
|
+
}
|
|
1705
|
+
var child = root.childNodes;
|
|
1706
|
+
if (child && child.length > 0) {
|
|
1707
|
+
for (var i = 0; i < child.length; i++) {
|
|
1708
|
+
var childNode = child.item(i);
|
|
1709
|
+
if (childNode && childNode.nodeType === 1) {
|
|
1710
|
+
var element = childNode;
|
|
1711
|
+
if (element && element.localName === 'fields' && element.hasChildNodes()) {
|
|
1712
|
+
var fieldList = element.childNodes;
|
|
1713
|
+
var elements = [];
|
|
1714
|
+
for (var j = 0; j < fieldList.length; j++) {
|
|
1715
|
+
var field = fieldList.item(j);
|
|
1716
|
+
if (field && field.nodeType === 1) {
|
|
1717
|
+
var filedElement = field;
|
|
1718
|
+
if (filedElement && filedElement.localName === 'field') {
|
|
1719
|
+
elements.push(filedElement);
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
this._importFormNodes(elements);
|
|
1724
|
+
}
|
|
1725
|
+
}
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
this._importField();
|
|
1729
|
+
};
|
|
1730
|
+
_XfdfDocument.prototype._importFormNodes = function (list) {
|
|
1731
|
+
for (var i = 0; i < list.length; i++) {
|
|
1732
|
+
var child = list[Number.parseInt(i.toString(), 10)];
|
|
1733
|
+
var fieldName = '';
|
|
1734
|
+
if (child) {
|
|
1735
|
+
if (child.hasAttribute('name')) {
|
|
1736
|
+
fieldName = child.getAttribute('name');
|
|
1737
|
+
}
|
|
1738
|
+
if (fieldName && fieldName !== '') {
|
|
1739
|
+
var values = child.getElementsByTagName('value');
|
|
1740
|
+
if (values && values.length > 0) {
|
|
1741
|
+
var node = child;
|
|
1742
|
+
var textName = '';
|
|
1743
|
+
while (node.localName !== 'fields') {
|
|
1744
|
+
if (textName.length > 0) {
|
|
1745
|
+
textName = '.' + textName;
|
|
1746
|
+
}
|
|
1747
|
+
var skip = false;
|
|
1748
|
+
if (node.hasAttribute('name')) {
|
|
1749
|
+
var name_1 = node.getAttribute('name');
|
|
1750
|
+
if (name_1 && name_1 !== '') {
|
|
1751
|
+
textName = name_1 + textName;
|
|
1752
|
+
skip = true;
|
|
1753
|
+
}
|
|
1754
|
+
}
|
|
1755
|
+
if (!skip) {
|
|
1756
|
+
textName += node.localName;
|
|
1757
|
+
}
|
|
1758
|
+
node = node.parentElement;
|
|
1759
|
+
}
|
|
1760
|
+
fieldName = textName;
|
|
1761
|
+
var dataValues = void 0;
|
|
1762
|
+
if (this._fields.has(fieldName)) {
|
|
1763
|
+
dataValues = this._fields.get(fieldName);
|
|
1764
|
+
}
|
|
1765
|
+
else {
|
|
1766
|
+
dataValues = [];
|
|
1767
|
+
}
|
|
1768
|
+
for (var j = 0; j < values.length; j++) {
|
|
1769
|
+
dataValues.push(values.item(j).textContent);
|
|
1770
|
+
}
|
|
1771
|
+
this._fields.set(fieldName, dataValues);
|
|
1772
|
+
}
|
|
1773
|
+
else {
|
|
1774
|
+
values = child.getElementsByTagName('value-richtext');
|
|
1775
|
+
if (values && values.length > 0) {
|
|
1776
|
+
var element = values.item(0);
|
|
1777
|
+
if (element) {
|
|
1778
|
+
var node = child;
|
|
1779
|
+
var textName = '';
|
|
1780
|
+
while (node.localName !== 'fields') {
|
|
1781
|
+
if (textName.length > 0) {
|
|
1782
|
+
textName = '.' + textName;
|
|
1783
|
+
}
|
|
1784
|
+
var skip = false;
|
|
1785
|
+
if (node.hasAttribute('name')) {
|
|
1786
|
+
var name_2 = node.getAttribute('name');
|
|
1787
|
+
if (name_2 && name_2 !== '') {
|
|
1788
|
+
textName = name_2 + textName;
|
|
1789
|
+
skip = true;
|
|
1790
|
+
}
|
|
1791
|
+
}
|
|
1792
|
+
if (!skip) {
|
|
1793
|
+
textName += node.localName;
|
|
1794
|
+
}
|
|
1795
|
+
node = node.parentElement;
|
|
1796
|
+
}
|
|
1797
|
+
fieldName = textName;
|
|
1798
|
+
var richText = element.textContent;
|
|
1799
|
+
if (element.childNodes && element.childNodes.length > 0) {
|
|
1800
|
+
var childNode = element.childNodes[0];
|
|
1801
|
+
if (childNode && childNode.hasChildNodes()) {
|
|
1802
|
+
richText = '';
|
|
1803
|
+
var childNodes = childNode.childNodes;
|
|
1804
|
+
for (var j = void 0; j < childNodes.length; j++) {
|
|
1805
|
+
richText += childNodes.item(j).textContent + '\r';
|
|
1806
|
+
}
|
|
1807
|
+
if (richText.length > 0) {
|
|
1808
|
+
richText = richText.substring(0, richText.length - 1);
|
|
1809
|
+
}
|
|
1810
|
+
else {
|
|
1811
|
+
richText = element.textContent;
|
|
1812
|
+
}
|
|
1813
|
+
}
|
|
1814
|
+
}
|
|
1815
|
+
var dataValues = void 0;
|
|
1816
|
+
if (this._fields.has(fieldName)) {
|
|
1817
|
+
dataValues = this._fields.get(fieldName);
|
|
1818
|
+
}
|
|
1819
|
+
else {
|
|
1820
|
+
dataValues = [];
|
|
1821
|
+
}
|
|
1822
|
+
for (var j = 0; j < values.length; j++) {
|
|
1823
|
+
dataValues.push(richText);
|
|
1824
|
+
}
|
|
1825
|
+
this._fields.set(fieldName, dataValues);
|
|
1826
|
+
if (!this._richTextValues.has(fieldName)) {
|
|
1827
|
+
this._richTextValues.set(fieldName, element.innerHTML);
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
};
|
|
1836
|
+
_XfdfDocument.prototype._parseAnnotationData = function (element) {
|
|
1837
|
+
if (element) {
|
|
1838
|
+
var pageIndex = -1;
|
|
1839
|
+
if (element.hasAttributes && element.hasAttribute('page')) {
|
|
1840
|
+
pageIndex = Number.parseInt(element.getAttribute('page'), 10);
|
|
1841
|
+
if (pageIndex >= 0 && pageIndex < this._document.pageCount) {
|
|
1842
|
+
var page = this._document.getPage(pageIndex);
|
|
1843
|
+
var annotationDictionary = this._getAnnotationDictionary(page, element);
|
|
1844
|
+
if (annotationDictionary && annotationDictionary.size > 0) {
|
|
1845
|
+
var pageDictionary = page._pageDictionary;
|
|
1846
|
+
if (pageDictionary) {
|
|
1847
|
+
var annotations = page.annotations;
|
|
1848
|
+
var annotation = annotations._parseAnnotation(annotationDictionary);
|
|
1849
|
+
if (annotation) {
|
|
1850
|
+
var reference = this._crossReference._getNextReference();
|
|
1851
|
+
this._crossReference._cacheMap.set(reference, annotationDictionary);
|
|
1852
|
+
if (annotationDictionary.has('NM') || annotationDictionary.has('IRT')) {
|
|
1853
|
+
this._addReferenceToGroup(reference, annotationDictionary);
|
|
1854
|
+
}
|
|
1855
|
+
annotation._ref = reference;
|
|
1856
|
+
var index = annotations._annotations.length;
|
|
1857
|
+
annotations._annotations.push(reference);
|
|
1858
|
+
pageDictionary.set('Annots', annotations._annotations);
|
|
1859
|
+
pageDictionary._updated = true;
|
|
1860
|
+
annotations._parsedAnnotations.set(index, annotation);
|
|
1861
|
+
this._handlePopup(annotations, reference, annotationDictionary, pageDictionary);
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
};
|
|
1869
|
+
_XfdfDocument.prototype._getAnnotationDictionary = function (page, element) {
|
|
1870
|
+
var dictionary = new _PdfDictionary(this._crossReference);
|
|
1871
|
+
dictionary.update('Type', _PdfName.get('Annot'));
|
|
1872
|
+
var isValidType = true;
|
|
1873
|
+
switch (element.localName.toLowerCase()) {
|
|
1874
|
+
case 'line':
|
|
1875
|
+
dictionary.update('Subtype', _PdfName.get('Line'));
|
|
1876
|
+
if (element.hasAttribute('start') && element.hasAttribute('end')) {
|
|
1877
|
+
var points_1 = [];
|
|
1878
|
+
element.getAttribute('start').split(',').forEach(function (value) {
|
|
1879
|
+
points_1.push(Number.parseFloat(value));
|
|
1880
|
+
});
|
|
1881
|
+
element.getAttribute('end').split(',').forEach(function (value) {
|
|
1882
|
+
points_1.push(Number.parseFloat(value));
|
|
1883
|
+
});
|
|
1884
|
+
if (points_1.length === 4) {
|
|
1885
|
+
dictionary.update('L', points_1);
|
|
1886
|
+
}
|
|
1887
|
+
}
|
|
1888
|
+
this._addLineEndStyle(dictionary, element);
|
|
1889
|
+
break;
|
|
1890
|
+
case 'circle':
|
|
1891
|
+
dictionary.update('Subtype', _PdfName.get('Circle'));
|
|
1892
|
+
break;
|
|
1893
|
+
case 'square':
|
|
1894
|
+
dictionary.update('Subtype', _PdfName.get('Square'));
|
|
1895
|
+
break;
|
|
1896
|
+
case 'polyline':
|
|
1897
|
+
dictionary.update('Subtype', _PdfName.get('PolyLine'));
|
|
1898
|
+
this._addLineEndStyle(dictionary, element);
|
|
1899
|
+
break;
|
|
1900
|
+
case 'polygon':
|
|
1901
|
+
dictionary.update('Subtype', _PdfName.get('Polygon'));
|
|
1902
|
+
this._addLineEndStyle(dictionary, element);
|
|
1903
|
+
break;
|
|
1904
|
+
case 'ink':
|
|
1905
|
+
dictionary.update('Subtype', _PdfName.get('Ink'));
|
|
1906
|
+
break;
|
|
1907
|
+
case 'popup':
|
|
1908
|
+
dictionary.update('Subtype', _PdfName.get('Popup'));
|
|
1909
|
+
break;
|
|
1910
|
+
case 'text':
|
|
1911
|
+
dictionary.update('Subtype', _PdfName.get('Text'));
|
|
1912
|
+
break;
|
|
1913
|
+
case 'freetext':
|
|
1914
|
+
dictionary.update('Subtype', _PdfName.get('FreeText'));
|
|
1915
|
+
this._addLineEndStyle(dictionary, element);
|
|
1916
|
+
break;
|
|
1917
|
+
case 'stamp':
|
|
1918
|
+
dictionary.update('Subtype', _PdfName.get('Stamp'));
|
|
1919
|
+
break;
|
|
1920
|
+
case 'highlight':
|
|
1921
|
+
dictionary.update('Subtype', _PdfName.get('Highlight'));
|
|
1922
|
+
break;
|
|
1923
|
+
case 'squiggly':
|
|
1924
|
+
dictionary.update('Subtype', _PdfName.get('Squiggly'));
|
|
1925
|
+
break;
|
|
1926
|
+
case 'underline':
|
|
1927
|
+
dictionary.update('Subtype', _PdfName.get('Underline'));
|
|
1928
|
+
break;
|
|
1929
|
+
case 'strikeout':
|
|
1930
|
+
dictionary.update('Subtype', _PdfName.get('StrikeOut'));
|
|
1931
|
+
break;
|
|
1932
|
+
case 'fileattachment':
|
|
1933
|
+
dictionary.update('Subtype', _PdfName.get('FileAttachment'));
|
|
1934
|
+
break;
|
|
1935
|
+
case 'sound':
|
|
1936
|
+
dictionary.update('Subtype', _PdfName.get('Sound'));
|
|
1937
|
+
break;
|
|
1938
|
+
case 'caret':
|
|
1939
|
+
dictionary.update('Subtype', _PdfName.get('Caret'));
|
|
1940
|
+
break;
|
|
1941
|
+
case 'redact':
|
|
1942
|
+
dictionary.update('Subtype', _PdfName.get('Redact'));
|
|
1943
|
+
break;
|
|
1944
|
+
default:
|
|
1945
|
+
isValidType = false;
|
|
1946
|
+
break;
|
|
1947
|
+
}
|
|
1948
|
+
if (isValidType) {
|
|
1949
|
+
this._addAnnotationData(dictionary, element, page);
|
|
1950
|
+
}
|
|
1951
|
+
return dictionary;
|
|
1952
|
+
};
|
|
1953
|
+
_XfdfDocument.prototype._addAnnotationData = function (dictionary, element, page) {
|
|
1954
|
+
this._addBorderStyle(dictionary, element);
|
|
1955
|
+
this._applyAttributeValues(dictionary, element.attributes);
|
|
1956
|
+
this._parseInnerElements(dictionary, element, page);
|
|
1957
|
+
this._addMeasureDictionary(dictionary, element);
|
|
1958
|
+
};
|
|
1959
|
+
_XfdfDocument.prototype._addBorderStyle = function (dictionary, element) {
|
|
1960
|
+
var borderEffectDictionary = new _PdfDictionary(this._crossReference);
|
|
1961
|
+
var borderStyleDictionary = new _PdfDictionary(this._crossReference);
|
|
1962
|
+
if (element.hasAttribute('width')) {
|
|
1963
|
+
borderStyleDictionary.update('W', Number.parseFloat(element.getAttribute('width')));
|
|
1964
|
+
}
|
|
1965
|
+
var isBasicStyle = true;
|
|
1966
|
+
if (element.hasAttribute('style')) {
|
|
1967
|
+
var style = '';
|
|
1968
|
+
switch (element.getAttribute('style')) {
|
|
1969
|
+
case 'dash':
|
|
1970
|
+
style = 'D';
|
|
1971
|
+
break;
|
|
1972
|
+
case 'solid':
|
|
1973
|
+
style = 'S';
|
|
1974
|
+
break;
|
|
1975
|
+
case 'bevelled':
|
|
1976
|
+
style = 'B';
|
|
1977
|
+
break;
|
|
1978
|
+
case 'inset':
|
|
1979
|
+
style = 'I';
|
|
1980
|
+
break;
|
|
1981
|
+
case 'underline':
|
|
1982
|
+
style = 'U';
|
|
1983
|
+
break;
|
|
1984
|
+
case 'cloudy':
|
|
1985
|
+
style = 'C';
|
|
1986
|
+
isBasicStyle = false;
|
|
1987
|
+
break;
|
|
1988
|
+
}
|
|
1989
|
+
if (style !== '') {
|
|
1990
|
+
(isBasicStyle ? borderStyleDictionary : borderEffectDictionary).update('S', _PdfName.get(style));
|
|
1991
|
+
if (!isBasicStyle && element.hasAttribute('intensity')) {
|
|
1992
|
+
borderEffectDictionary.update('I', Number.parseFloat(element.getAttribute('intensity')));
|
|
1993
|
+
}
|
|
1994
|
+
else if (element.hasAttribute('dashes')) {
|
|
1995
|
+
var dashes_1 = [];
|
|
1996
|
+
element.getAttribute('dashes').split(',').forEach(function (value) {
|
|
1997
|
+
dashes_1.push(Number.parseFloat(value));
|
|
1998
|
+
});
|
|
1999
|
+
borderStyleDictionary.update('D', dashes_1);
|
|
2000
|
+
}
|
|
2001
|
+
}
|
|
2002
|
+
}
|
|
2003
|
+
if (borderEffectDictionary.size > 0) {
|
|
2004
|
+
dictionary.update('BE', borderEffectDictionary);
|
|
2005
|
+
}
|
|
2006
|
+
if (borderStyleDictionary.size > 0) {
|
|
2007
|
+
borderStyleDictionary.update('Type', 'Border');
|
|
2008
|
+
dictionary.update('BS', borderStyleDictionary);
|
|
2009
|
+
}
|
|
2010
|
+
};
|
|
2011
|
+
_XfdfDocument.prototype._applyAttributeValues = function (dictionary, attributes) {
|
|
2012
|
+
for (var i = 0; i < attributes.length; i++) {
|
|
2013
|
+
var attribute = attributes[Number.parseInt(i.toString(), 10)];
|
|
2014
|
+
var value = attribute.value;
|
|
2015
|
+
var values = void 0;
|
|
2016
|
+
var leaderExtend = void 0;
|
|
2017
|
+
switch (attribute.name.toLowerCase()) {
|
|
2018
|
+
case 'page':
|
|
2019
|
+
case 'start':
|
|
2020
|
+
case 'end':
|
|
2021
|
+
case 'width':
|
|
2022
|
+
case 'head':
|
|
2023
|
+
case 'tail':
|
|
2024
|
+
case 'style':
|
|
2025
|
+
case 'intensity':
|
|
2026
|
+
case 'itex':
|
|
2027
|
+
break;
|
|
2028
|
+
case 'state':
|
|
2029
|
+
this._addString(dictionary, 'State', value);
|
|
2030
|
+
break;
|
|
2031
|
+
case 'statemodel':
|
|
2032
|
+
this._addString(dictionary, 'StateModel', value);
|
|
2033
|
+
break;
|
|
2034
|
+
case 'replytype':
|
|
2035
|
+
if (value === 'group') {
|
|
2036
|
+
dictionary.update('RT', _PdfName.get('Group'));
|
|
2037
|
+
}
|
|
2038
|
+
break;
|
|
2039
|
+
case 'inreplyto':
|
|
2040
|
+
this._addString(dictionary, 'IRT', value);
|
|
2041
|
+
break;
|
|
2042
|
+
case 'rect':
|
|
2043
|
+
values = this._obtainPoints(value);
|
|
2044
|
+
if (values && values.length === 4) {
|
|
2045
|
+
dictionary.update('Rect', values);
|
|
2046
|
+
}
|
|
2047
|
+
break;
|
|
2048
|
+
case 'color':
|
|
2049
|
+
values = _convertToColor(value);
|
|
2050
|
+
if (values && values.length === 3) {
|
|
2051
|
+
dictionary.update('C', [values[0] / 255, values[1] / 255, values[2] / 255]);
|
|
2052
|
+
}
|
|
2053
|
+
break;
|
|
2054
|
+
case 'interior-color':
|
|
2055
|
+
values = _convertToColor(value);
|
|
2056
|
+
if (values && values.length === 3) {
|
|
2057
|
+
dictionary.update('IC', [values[0] / 255, values[1] / 255, values[2] / 255]);
|
|
2058
|
+
}
|
|
2059
|
+
break;
|
|
2060
|
+
case 'date':
|
|
2061
|
+
this._addString(dictionary, 'M', value);
|
|
2062
|
+
break;
|
|
2063
|
+
case 'creationdate':
|
|
2064
|
+
this._addString(dictionary, 'CreationDate', value);
|
|
2065
|
+
break;
|
|
2066
|
+
case 'name':
|
|
2067
|
+
this._addString(dictionary, 'NM', value);
|
|
2068
|
+
break;
|
|
2069
|
+
case 'icon':
|
|
2070
|
+
if (value && value !== '') {
|
|
2071
|
+
dictionary.update('Name', _PdfName.get(value));
|
|
2072
|
+
}
|
|
2073
|
+
break;
|
|
2074
|
+
case 'subject':
|
|
2075
|
+
this._addString(dictionary, 'Subj', this._getFormatedString(value, true));
|
|
2076
|
+
break;
|
|
2077
|
+
case 'title':
|
|
2078
|
+
this._addString(dictionary, 'T', this._getFormatedString(value, true));
|
|
2079
|
+
break;
|
|
2080
|
+
case 'rotation':
|
|
2081
|
+
this._addInt(dictionary, 'Rotate', value);
|
|
2082
|
+
break;
|
|
2083
|
+
case 'justification':
|
|
2084
|
+
this._addInt(dictionary, 'Q', value);
|
|
2085
|
+
break;
|
|
2086
|
+
case 'fringe':
|
|
2087
|
+
this._addFloatPoints(dictionary, this._obtainPoints(value), 'RD');
|
|
2088
|
+
break;
|
|
2089
|
+
case 'it':
|
|
2090
|
+
if (value && value !== '') {
|
|
2091
|
+
dictionary.update('IT', _PdfName.get(value));
|
|
2092
|
+
}
|
|
2093
|
+
break;
|
|
2094
|
+
case 'leaderlength':
|
|
2095
|
+
this._addFloat(dictionary, 'LL', value);
|
|
2096
|
+
break;
|
|
2097
|
+
case 'leaderextend':
|
|
2098
|
+
leaderExtend = Number.parseFloat(value);
|
|
2099
|
+
if (typeof leaderExtend !== 'undefined') {
|
|
2100
|
+
dictionary.update('LLE', leaderExtend);
|
|
2101
|
+
}
|
|
2102
|
+
break;
|
|
2103
|
+
case 'caption':
|
|
2104
|
+
if (value && value !== '') {
|
|
2105
|
+
dictionary.update('Cap', value.toLowerCase() === 'yes' ? true : false);
|
|
2106
|
+
}
|
|
2107
|
+
break;
|
|
2108
|
+
case 'caption-style':
|
|
2109
|
+
if (value && value !== '') {
|
|
2110
|
+
dictionary.update('CP', _PdfName.get(value));
|
|
2111
|
+
}
|
|
2112
|
+
break;
|
|
2113
|
+
case 'callout':
|
|
2114
|
+
this._addFloatPoints(dictionary, this._obtainPoints(value), 'CL');
|
|
2115
|
+
break;
|
|
2116
|
+
case 'coords':
|
|
2117
|
+
this._addFloatPoints(dictionary, this._obtainPoints(value), 'QuadPoints');
|
|
2118
|
+
break;
|
|
2119
|
+
case 'border':
|
|
2120
|
+
this._addFloatPoints(dictionary, this._obtainPoints(value), 'Border');
|
|
2121
|
+
break;
|
|
2122
|
+
case 'opacity':
|
|
2123
|
+
this._addFloat(dictionary, 'CA', value);
|
|
2124
|
+
break;
|
|
2125
|
+
case 'flags':
|
|
2126
|
+
if (value && value !== '') {
|
|
2127
|
+
var annotFlag = PdfAnnotationFlag.default;
|
|
2128
|
+
var flags = value.split(',');
|
|
2129
|
+
for (var i_1 = 0; i_1 < flags.length; i_1++) {
|
|
2130
|
+
var flagType = _stringToAnnotationFlags(flags[Number.parseInt(i_1.toString(), 10)]);
|
|
2131
|
+
if (i_1 === 0) {
|
|
2132
|
+
annotFlag = flagType;
|
|
2133
|
+
}
|
|
2134
|
+
else {
|
|
2135
|
+
annotFlag |= flagType;
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
dictionary.update('F', annotFlag);
|
|
2139
|
+
}
|
|
2140
|
+
break;
|
|
2141
|
+
case 'open':
|
|
2142
|
+
if (value && value !== '') {
|
|
2143
|
+
dictionary.update('Open', (value === 'true' || value === 'yes') ? true : false);
|
|
2144
|
+
}
|
|
2145
|
+
break;
|
|
2146
|
+
case 'calibrate':
|
|
2147
|
+
this._addString(dictionary, 'Calibrate', value);
|
|
2148
|
+
break;
|
|
2149
|
+
case 'customdata':
|
|
2150
|
+
this._addString(dictionary, 'CustomData', value);
|
|
2151
|
+
break;
|
|
2152
|
+
case 'overlaytext':
|
|
2153
|
+
dictionary.update('OverlayText', value);
|
|
2154
|
+
break;
|
|
2155
|
+
case 'repeat':
|
|
2156
|
+
dictionary.update('Repeat', (value === 'true' || value === 'yes') ? true : false);
|
|
2157
|
+
break;
|
|
2158
|
+
default:
|
|
2159
|
+
if (this._document._allowImportCustomData) {
|
|
2160
|
+
this._addString(dictionary, attribute.name, value);
|
|
2161
|
+
}
|
|
2162
|
+
break;
|
|
2163
|
+
}
|
|
2164
|
+
}
|
|
2165
|
+
};
|
|
2166
|
+
_XfdfDocument.prototype._obtainPoints = function (value) {
|
|
2167
|
+
var points = [];
|
|
2168
|
+
value.split(',').forEach(function (value) {
|
|
2169
|
+
points.push(Number.parseFloat(value));
|
|
2170
|
+
});
|
|
2171
|
+
return points;
|
|
2172
|
+
};
|
|
2173
|
+
_XfdfDocument.prototype._parseInnerElements = function (dictionary, element, page) {
|
|
2174
|
+
if (element.hasChildNodes) {
|
|
2175
|
+
var children = element.childNodes;
|
|
2176
|
+
var _loop_1 = function (index) {
|
|
2177
|
+
var child = children[Number.parseInt(index.toString(), 10)];
|
|
2178
|
+
if (child.nodeType === 1) {
|
|
2179
|
+
var childElement = child;
|
|
2180
|
+
var textContent = child.textContent;
|
|
2181
|
+
var innerHTML = childElement.innerHTML;
|
|
2182
|
+
switch (child.nodeName.toLowerCase()) {
|
|
2183
|
+
case 'popup':
|
|
2184
|
+
if (childElement && childElement.hasAttributes) {
|
|
2185
|
+
var popupDictionary = this_1._getAnnotationDictionary(page, childElement);
|
|
2186
|
+
if (popupDictionary.size > 0) {
|
|
2187
|
+
var reference = this_1._crossReference._getNextReference();
|
|
2188
|
+
this_1._crossReference._cacheMap.set(reference, popupDictionary);
|
|
2189
|
+
dictionary.update('Popup', reference);
|
|
2190
|
+
if (popupDictionary.has('NM')) {
|
|
2191
|
+
this_1._addReferenceToGroup(reference, popupDictionary);
|
|
2192
|
+
}
|
|
2193
|
+
}
|
|
2194
|
+
}
|
|
2195
|
+
break;
|
|
2196
|
+
case 'contents':
|
|
2197
|
+
if (textContent && textContent !== '') {
|
|
2198
|
+
dictionary.update('Contents', this_1._getFormatedString(textContent, true));
|
|
2199
|
+
}
|
|
2200
|
+
break;
|
|
2201
|
+
case 'contents-richtext':
|
|
2202
|
+
if (innerHTML && innerHTML !== '') {
|
|
2203
|
+
dictionary.update('RC', this_1._richTextPrefix + innerHTML);
|
|
2204
|
+
}
|
|
2205
|
+
break;
|
|
2206
|
+
case 'defaultstyle':
|
|
2207
|
+
this_1._addString(dictionary, 'DS', textContent);
|
|
2208
|
+
break;
|
|
2209
|
+
case 'defaultappearance':
|
|
2210
|
+
this_1._addString(dictionary, 'DA', textContent);
|
|
2211
|
+
break;
|
|
2212
|
+
case 'vertices':
|
|
2213
|
+
if (textContent && textContent !== '') {
|
|
2214
|
+
var vertices_1 = [];
|
|
2215
|
+
textContent.split(',').forEach(function (value) {
|
|
2216
|
+
if (value.indexOf(';') !== -1) {
|
|
2217
|
+
value.split(';').forEach(function (innerValue) {
|
|
2218
|
+
vertices_1.push(innerValue);
|
|
2219
|
+
});
|
|
2220
|
+
}
|
|
2221
|
+
else {
|
|
2222
|
+
vertices_1.push(value);
|
|
2223
|
+
}
|
|
2224
|
+
});
|
|
2225
|
+
if (vertices_1.length > 0) {
|
|
2226
|
+
var verticesArray_1 = [];
|
|
2227
|
+
vertices_1.forEach(function (value) {
|
|
2228
|
+
verticesArray_1.push(Number.parseFloat(value));
|
|
2229
|
+
});
|
|
2230
|
+
dictionary.update('Vertices', verticesArray_1);
|
|
2231
|
+
}
|
|
2232
|
+
}
|
|
2233
|
+
break;
|
|
2234
|
+
case 'appearance':
|
|
2235
|
+
this_1._addAppearanceData(child, dictionary);
|
|
2236
|
+
break;
|
|
2237
|
+
case 'inklist':
|
|
2238
|
+
if (child.hasChildNodes) {
|
|
2239
|
+
var inkListCollection = [];
|
|
2240
|
+
var childNodes = child.childNodes;
|
|
2241
|
+
var _loop_2 = function (i) {
|
|
2242
|
+
var inkChild = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2243
|
+
if (inkChild && inkChild.nodeType === 1) {
|
|
2244
|
+
var inkChildElement = inkChild;
|
|
2245
|
+
if (inkChildElement.nodeName.toLowerCase() === 'gesture') {
|
|
2246
|
+
if (inkChildElement.textContent && inkChildElement.textContent !== '') {
|
|
2247
|
+
var points_2 = [];
|
|
2248
|
+
inkChildElement.textContent.split(',').forEach(function (value) {
|
|
2249
|
+
if (value.indexOf(';') !== -1) {
|
|
2250
|
+
value.split(';').forEach(function (innerValue) {
|
|
2251
|
+
points_2.push(innerValue);
|
|
2252
|
+
});
|
|
2253
|
+
}
|
|
2254
|
+
else {
|
|
2255
|
+
points_2.push(value);
|
|
2256
|
+
}
|
|
2257
|
+
});
|
|
2258
|
+
if (points_2.length > 0) {
|
|
2259
|
+
var pointsArray_1 = [];
|
|
2260
|
+
points_2.forEach(function (value) {
|
|
2261
|
+
pointsArray_1.push(Number.parseFloat(value));
|
|
2262
|
+
});
|
|
2263
|
+
inkListCollection.push(pointsArray_1);
|
|
2264
|
+
}
|
|
2265
|
+
}
|
|
2266
|
+
}
|
|
2267
|
+
}
|
|
2268
|
+
};
|
|
2269
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2270
|
+
_loop_2(i);
|
|
2271
|
+
}
|
|
2272
|
+
dictionary.update('InkList', inkListCollection);
|
|
2273
|
+
}
|
|
2274
|
+
break;
|
|
2275
|
+
case 'data':
|
|
2276
|
+
this_1._addStreamData(child, dictionary, element);
|
|
2277
|
+
break;
|
|
2278
|
+
}
|
|
2279
|
+
}
|
|
2280
|
+
};
|
|
2281
|
+
var this_1 = this;
|
|
2282
|
+
for (var index = 0; index < children.length; index++) {
|
|
2283
|
+
_loop_1(index);
|
|
2284
|
+
}
|
|
2285
|
+
}
|
|
2286
|
+
};
|
|
2287
|
+
_XfdfDocument.prototype._addStreamData = function (child, dictionary, parent) {
|
|
2288
|
+
if (child && child.textContent && child.textContent !== '') {
|
|
2289
|
+
var raw = _hexStringToByteArray(child.textContent, true);
|
|
2290
|
+
if (raw && raw.length > 0) {
|
|
2291
|
+
if (dictionary.has('Subtype')) {
|
|
2292
|
+
var subtype = dictionary.get('Subtype');
|
|
2293
|
+
if (subtype && subtype.name === 'FileAttachment') {
|
|
2294
|
+
this._addFileAttachment(dictionary, parent, raw);
|
|
2295
|
+
}
|
|
2296
|
+
else if (subtype && subtype.name === 'Sound') {
|
|
2297
|
+
this._addSound(dictionary, parent, raw);
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
};
|
|
2303
|
+
_XfdfDocument.prototype._addSound = function (dictionary, element, raw) {
|
|
2304
|
+
var soundStream = new _PdfContentStream(raw);
|
|
2305
|
+
soundStream.dictionary._crossReference = this._crossReference;
|
|
2306
|
+
soundStream.dictionary.update('Type', _PdfName.get('Sound'));
|
|
2307
|
+
if (element.hasAttribute('bits')) {
|
|
2308
|
+
this._addInt(soundStream.dictionary, 'B', element.getAttribute('bits'));
|
|
2309
|
+
}
|
|
2310
|
+
if (element.hasAttribute('rate')) {
|
|
2311
|
+
this._addInt(soundStream.dictionary, 'R', element.getAttribute('rate'));
|
|
2312
|
+
}
|
|
2313
|
+
if (element.hasAttribute('channels')) {
|
|
2314
|
+
this._addInt(soundStream.dictionary, 'C', element.getAttribute('channels'));
|
|
2315
|
+
}
|
|
2316
|
+
if (element.hasAttribute('encoding')) {
|
|
2317
|
+
var value = element.getAttribute('encoding');
|
|
2318
|
+
if (value && value !== '') {
|
|
2319
|
+
soundStream.dictionary.update('E', _PdfName.get(value));
|
|
2320
|
+
}
|
|
2321
|
+
}
|
|
2322
|
+
if (element.hasAttribute('filter')) {
|
|
2323
|
+
soundStream.dictionary.update('Filter', _PdfName.get('FlateDecode'));
|
|
2324
|
+
}
|
|
2325
|
+
var soundReference = this._crossReference._getNextReference();
|
|
2326
|
+
this._crossReference._cacheMap.set(soundReference, soundStream);
|
|
2327
|
+
dictionary.update('Sound', soundReference);
|
|
2328
|
+
};
|
|
2329
|
+
_XfdfDocument.prototype._addFileAttachment = function (dictionary, element, raw) {
|
|
2330
|
+
var fileDictionary = new _PdfDictionary(this._crossReference);
|
|
2331
|
+
fileDictionary.update('Type', _PdfName.get('Filespec'));
|
|
2332
|
+
if (element.hasAttribute('file')) {
|
|
2333
|
+
var value = element.getAttribute('file');
|
|
2334
|
+
this._addString(fileDictionary, 'F', value);
|
|
2335
|
+
this._addString(fileDictionary, 'UF', value);
|
|
2336
|
+
}
|
|
2337
|
+
var fileStream = new _PdfContentStream(raw);
|
|
2338
|
+
fileStream.dictionary._crossReference = this._crossReference;
|
|
2339
|
+
var param = new _PdfDictionary(this._crossReference);
|
|
2340
|
+
if (element.hasAttribute('size')) {
|
|
2341
|
+
var size = Number.parseInt(element.getAttribute('size'), 10);
|
|
2342
|
+
if (typeof size !== 'undefined') {
|
|
2343
|
+
param.update('Size', size);
|
|
2344
|
+
fileStream.dictionary.update('DL', size);
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
if (element.hasAttribute('modification')) {
|
|
2348
|
+
this._addString(param, 'ModDate', element.getAttribute('modification'));
|
|
2349
|
+
}
|
|
2350
|
+
if (element.hasAttribute('creation')) {
|
|
2351
|
+
this._addString(param, 'CreationDate', element.getAttribute('creation'));
|
|
2352
|
+
}
|
|
2353
|
+
fileStream.dictionary.update('Params', param);
|
|
2354
|
+
if (element.hasAttribute('mimetype')) {
|
|
2355
|
+
this._addString(fileStream.dictionary, 'Subtype', element.getAttribute('mimetype'));
|
|
2356
|
+
}
|
|
2357
|
+
fileStream.dictionary.update('Filter', _PdfName.get('FlateDecode'));
|
|
2358
|
+
var embeddedFile = new _PdfDictionary(this._crossReference);
|
|
2359
|
+
var reference = this._crossReference._getNextReference();
|
|
2360
|
+
this._crossReference._cacheMap.set(reference, fileStream);
|
|
2361
|
+
embeddedFile.update('F', reference);
|
|
2362
|
+
fileDictionary.update('EF', embeddedFile);
|
|
2363
|
+
var fileReference = this._crossReference._getNextReference();
|
|
2364
|
+
this._crossReference._cacheMap.set(fileReference, fileDictionary);
|
|
2365
|
+
dictionary.update('FS', fileReference);
|
|
2366
|
+
};
|
|
2367
|
+
_XfdfDocument.prototype._addAppearanceData = function (element, dictionary) {
|
|
2368
|
+
var innerText = element.textContent;
|
|
2369
|
+
if (innerText && innerText !== '') {
|
|
2370
|
+
var appearanceArray = _decode(innerText);
|
|
2371
|
+
if (appearanceArray && appearanceArray.length > 0) {
|
|
2372
|
+
var document_1 = (new DOMParser()).parseFromString(_bytesToString(appearanceArray), 'text/xml');
|
|
2373
|
+
if (document_1 && document_1.hasChildNodes) {
|
|
2374
|
+
var childNodes = document_1.childNodes;
|
|
2375
|
+
if (childNodes && childNodes.length === 1) {
|
|
2376
|
+
var rootNode = childNodes[0];
|
|
2377
|
+
if (rootNode && rootNode.nodeType === 1) {
|
|
2378
|
+
var rootElement = rootNode;
|
|
2379
|
+
if (rootElement.nodeName.toLowerCase() === 'DICT' && rootElement.hasAttribute('KEY')) {
|
|
2380
|
+
var key = rootElement.getAttribute('KEY');
|
|
2381
|
+
if (key && key === 'AP' && rootElement.hasChildNodes) {
|
|
2382
|
+
var appearance = new _PdfDictionary(this._crossReference);
|
|
2383
|
+
childNodes = rootElement.childNodes;
|
|
2384
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2385
|
+
this._getAppearance(appearance, childNodes[Number.parseInt(i.toString(), 10)]);
|
|
2386
|
+
}
|
|
2387
|
+
if (appearance.size > 0) {
|
|
2388
|
+
dictionary.update('AP', appearance);
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
}
|
|
2394
|
+
}
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
};
|
|
2398
|
+
_XfdfDocument.prototype._getAppearance = function (source, child) {
|
|
2399
|
+
var appearance = source instanceof _PdfDictionary ? source : source.dictionary;
|
|
2400
|
+
if (child && child.nodeType === 1) {
|
|
2401
|
+
var element = child;
|
|
2402
|
+
if (element && element.localName) {
|
|
2403
|
+
var stream = void 0;
|
|
2404
|
+
var dictionary = void 0;
|
|
2405
|
+
var data = void 0;
|
|
2406
|
+
switch (element.localName) {
|
|
2407
|
+
case 'STREAM':
|
|
2408
|
+
stream = this._getStream(element);
|
|
2409
|
+
if (stream) {
|
|
2410
|
+
var reference = this._crossReference._getNextReference();
|
|
2411
|
+
this._crossReference._cacheMap.set(reference, stream);
|
|
2412
|
+
this._addKey(reference, appearance, element);
|
|
2413
|
+
}
|
|
2414
|
+
break;
|
|
2415
|
+
case 'DICT':
|
|
2416
|
+
dictionary = this._getDictionary(element);
|
|
2417
|
+
if (dictionary) {
|
|
2418
|
+
var reference = this._crossReference._getNextReference();
|
|
2419
|
+
this._crossReference._cacheMap.set(reference, stream);
|
|
2420
|
+
this._addKey(reference, appearance, element);
|
|
2421
|
+
}
|
|
2422
|
+
break;
|
|
2423
|
+
case 'ARRAY':
|
|
2424
|
+
this._addKey(this._getArray(element), appearance, element);
|
|
2425
|
+
break;
|
|
2426
|
+
case 'FIXED':
|
|
2427
|
+
this._addKey(this._getFixed(element), appearance, element);
|
|
2428
|
+
break;
|
|
2429
|
+
case 'INT':
|
|
2430
|
+
this._addKey(this._getInt(element), appearance, element);
|
|
2431
|
+
break;
|
|
2432
|
+
case 'STRING':
|
|
2433
|
+
this._addKey(this._getString(element), appearance, element);
|
|
2434
|
+
break;
|
|
2435
|
+
case 'NAME':
|
|
2436
|
+
this._addKey(this._getName(element), appearance, element);
|
|
2437
|
+
break;
|
|
2438
|
+
case 'BOOL':
|
|
2439
|
+
this._addKey(this._getBoolean(element), appearance, element);
|
|
2440
|
+
break;
|
|
2441
|
+
case 'DATA':
|
|
2442
|
+
data = this._getData(element);
|
|
2443
|
+
if (data && data.length > 0 && source instanceof _PdfContentStream) {
|
|
2444
|
+
source._bytes = data;
|
|
2445
|
+
}
|
|
2446
|
+
break;
|
|
2447
|
+
}
|
|
2448
|
+
}
|
|
2449
|
+
}
|
|
2450
|
+
};
|
|
2451
|
+
_XfdfDocument.prototype._getStream = function (element) {
|
|
2452
|
+
var stream = new _PdfContentStream([]);
|
|
2453
|
+
stream.dictionary._crossReference = this._crossReference;
|
|
2454
|
+
if (element.hasChildNodes) {
|
|
2455
|
+
var childNodes = element.childNodes;
|
|
2456
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2457
|
+
var child = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2458
|
+
if (child && child.nodeType === 1) {
|
|
2459
|
+
this._getAppearance(stream, child);
|
|
2460
|
+
}
|
|
2461
|
+
}
|
|
2462
|
+
}
|
|
2463
|
+
return stream;
|
|
2464
|
+
};
|
|
2465
|
+
_XfdfDocument.prototype._getDictionary = function (element) {
|
|
2466
|
+
var dictionary = new _PdfDictionary(this._crossReference);
|
|
2467
|
+
if (element.hasChildNodes) {
|
|
2468
|
+
var childNodes = element.childNodes;
|
|
2469
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2470
|
+
var child = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2471
|
+
if (child && child.nodeType === 1) {
|
|
2472
|
+
this._getAppearance(dictionary, child);
|
|
2473
|
+
}
|
|
2474
|
+
}
|
|
2475
|
+
}
|
|
2476
|
+
return dictionary;
|
|
2477
|
+
};
|
|
2478
|
+
_XfdfDocument.prototype._getArray = function (element) {
|
|
2479
|
+
var array = []; // eslint-disable-line
|
|
2480
|
+
if (element.hasChildNodes) {
|
|
2481
|
+
var childNodes = element.childNodes;
|
|
2482
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2483
|
+
var child = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2484
|
+
if (child && child.nodeType === 1) {
|
|
2485
|
+
this._addArrayElements(array, child);
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
return array;
|
|
2490
|
+
};
|
|
2491
|
+
_XfdfDocument.prototype._getData = function (element) {
|
|
2492
|
+
var data = [];
|
|
2493
|
+
if (element && element.textContent &&
|
|
2494
|
+
element.textContent !== '' &&
|
|
2495
|
+
element.hasAttribute('MODE') && element.hasAttribute('ENCODING')) {
|
|
2496
|
+
var mode = element.getAttribute('MODE');
|
|
2497
|
+
var encoding = element.getAttribute('ENCODING');
|
|
2498
|
+
if (mode && encoding) {
|
|
2499
|
+
var innerText = this._getFormatedString(element.textContent, true);
|
|
2500
|
+
if (mode === 'FILTERED' && encoding === 'ASCII') {
|
|
2501
|
+
data = _stringToBytes(innerText, true);
|
|
2502
|
+
}
|
|
2503
|
+
else if (mode === 'RAW' && encoding === 'HEX') {
|
|
2504
|
+
data = _hexStringToByteArray(innerText, true);
|
|
2505
|
+
}
|
|
2506
|
+
}
|
|
2507
|
+
}
|
|
2508
|
+
return data;
|
|
2509
|
+
};
|
|
2510
|
+
_XfdfDocument.prototype._addArrayElements = function (array, child) {
|
|
2511
|
+
if (child && child.nodeType === 1) {
|
|
2512
|
+
var element = child;
|
|
2513
|
+
var stream = void 0;
|
|
2514
|
+
var dictionary = void 0;
|
|
2515
|
+
var value = void 0; // eslint-disable-line
|
|
2516
|
+
var floatValue = void 0;
|
|
2517
|
+
var intValue = void 0;
|
|
2518
|
+
var name_3;
|
|
2519
|
+
var bool = void 0;
|
|
2520
|
+
switch (element.localName) {
|
|
2521
|
+
case 'STREAM':
|
|
2522
|
+
stream = this._getStream(element);
|
|
2523
|
+
if (stream) {
|
|
2524
|
+
var reference = this._crossReference._getNextReference();
|
|
2525
|
+
stream.reference = reference;
|
|
2526
|
+
this._crossReference._cacheMap.set(reference, stream);
|
|
2527
|
+
array.push(reference);
|
|
2528
|
+
}
|
|
2529
|
+
break;
|
|
2530
|
+
case 'DICT':
|
|
2531
|
+
dictionary = this._getDictionary(element);
|
|
2532
|
+
if (dictionary) {
|
|
2533
|
+
var reference = this._crossReference._getNextReference();
|
|
2534
|
+
this._crossReference._cacheMap.set(reference, dictionary);
|
|
2535
|
+
array.push(reference);
|
|
2536
|
+
}
|
|
2537
|
+
break;
|
|
2538
|
+
case 'ARRAY':
|
|
2539
|
+
value = this._getArray(element);
|
|
2540
|
+
if (value) {
|
|
2541
|
+
array.push(value);
|
|
2542
|
+
}
|
|
2543
|
+
break;
|
|
2544
|
+
case 'FIXED':
|
|
2545
|
+
floatValue = this._getFixed(element);
|
|
2546
|
+
if (typeof floatValue !== 'undefined' && !isNaN(floatValue)) {
|
|
2547
|
+
array.push(floatValue);
|
|
2548
|
+
}
|
|
2549
|
+
break;
|
|
2550
|
+
case 'INT':
|
|
2551
|
+
intValue = this._getInt(element);
|
|
2552
|
+
if (typeof intValue !== 'undefined' && !isNaN(intValue)) {
|
|
2553
|
+
array.push(intValue);
|
|
2554
|
+
}
|
|
2555
|
+
break;
|
|
2556
|
+
case 'NAME':
|
|
2557
|
+
name_3 = this._getName(element);
|
|
2558
|
+
if (name_3) {
|
|
2559
|
+
array.push(name_3);
|
|
2560
|
+
}
|
|
2561
|
+
break;
|
|
2562
|
+
case 'BOOL':
|
|
2563
|
+
bool = this._getBoolean(element);
|
|
2564
|
+
if (typeof bool !== 'undefined' && bool !== null) {
|
|
2565
|
+
array.push(bool);
|
|
2566
|
+
}
|
|
2567
|
+
break;
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
};
|
|
2571
|
+
_XfdfDocument.prototype._getFixed = function (element) {
|
|
2572
|
+
var value;
|
|
2573
|
+
if (element && element.hasAttribute('VAL')) {
|
|
2574
|
+
value = Number.parseFloat(element.getAttribute('VAL'));
|
|
2575
|
+
}
|
|
2576
|
+
return value;
|
|
2577
|
+
};
|
|
2578
|
+
_XfdfDocument.prototype._getInt = function (element) {
|
|
2579
|
+
var value;
|
|
2580
|
+
if (element && element.hasAttribute('VAL')) {
|
|
2581
|
+
value = Number.parseInt(element.getAttribute('VAL'), 10);
|
|
2582
|
+
}
|
|
2583
|
+
return value;
|
|
2584
|
+
};
|
|
2585
|
+
_XfdfDocument.prototype._getString = function (element) {
|
|
2586
|
+
var value;
|
|
2587
|
+
if (element && element.hasAttribute('VAL')) {
|
|
2588
|
+
value = element.getAttribute('VAL');
|
|
2589
|
+
}
|
|
2590
|
+
return value;
|
|
2591
|
+
};
|
|
2592
|
+
_XfdfDocument.prototype._getName = function (element) {
|
|
2593
|
+
var value;
|
|
2594
|
+
if (element && element.hasAttribute('VAL')) {
|
|
2595
|
+
value = _PdfName.get(element.getAttribute('VAL'));
|
|
2596
|
+
}
|
|
2597
|
+
return value;
|
|
2598
|
+
};
|
|
2599
|
+
_XfdfDocument.prototype._getBoolean = function (element) {
|
|
2600
|
+
var value;
|
|
2601
|
+
if (element && element.hasAttribute('VAL')) {
|
|
2602
|
+
value = element.getAttribute('VAL') === 'true' ? true : false;
|
|
2603
|
+
}
|
|
2604
|
+
return value;
|
|
2605
|
+
};
|
|
2606
|
+
_XfdfDocument.prototype._addMeasureDictionary = function (dictionary, element) {
|
|
2607
|
+
var measurement;
|
|
2608
|
+
var area;
|
|
2609
|
+
var distance;
|
|
2610
|
+
var xformat;
|
|
2611
|
+
if (element.hasChildNodes) {
|
|
2612
|
+
var childNodes = element.childNodes;
|
|
2613
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2614
|
+
var childElement = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2615
|
+
if (childElement && childElement.localName === 'measure') {
|
|
2616
|
+
measurement = childElement;
|
|
2617
|
+
break;
|
|
2618
|
+
}
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
var measureDictionary = new _PdfDictionary(this._crossReference);
|
|
2622
|
+
var dDict = new _PdfDictionary(this._crossReference);
|
|
2623
|
+
var aDict = new _PdfDictionary(this._crossReference);
|
|
2624
|
+
var xDict = new _PdfDictionary(this._crossReference);
|
|
2625
|
+
var dArray = [];
|
|
2626
|
+
var aArray = [];
|
|
2627
|
+
var xArray = [];
|
|
2628
|
+
if (measurement) {
|
|
2629
|
+
measureDictionary.update('Type', _PdfName.get('Measure'));
|
|
2630
|
+
if (measurement.hasAttribute('rateValue')) {
|
|
2631
|
+
var attribute = measurement.getAttribute['rateValue'];
|
|
2632
|
+
if (attribute && attribute !== '') {
|
|
2633
|
+
measureDictionary.update('R', attribute);
|
|
2634
|
+
}
|
|
2635
|
+
}
|
|
2636
|
+
if (measurement.hasChildNodes) {
|
|
2637
|
+
var childNodes = measurement.childNodes;
|
|
2638
|
+
for (var i = 0; i < childNodes.length; i++) {
|
|
2639
|
+
var child = childNodes[Number.parseInt(i.toString(), 10)];
|
|
2640
|
+
if (child && child.nodeType === 1) {
|
|
2641
|
+
var childElement = child;
|
|
2642
|
+
switch (childElement.nodeName.toLowerCase()) {
|
|
2643
|
+
case 'distance':
|
|
2644
|
+
distance = childElement;
|
|
2645
|
+
break;
|
|
2646
|
+
case 'area':
|
|
2647
|
+
area = childElement;
|
|
2648
|
+
break;
|
|
2649
|
+
case 'xformat':
|
|
2650
|
+
xformat = childElement;
|
|
2651
|
+
break;
|
|
2652
|
+
}
|
|
2653
|
+
}
|
|
2654
|
+
}
|
|
2655
|
+
}
|
|
2656
|
+
}
|
|
2657
|
+
if (xformat) {
|
|
2658
|
+
this._addElements(xformat, xDict);
|
|
2659
|
+
xArray.push(xDict);
|
|
2660
|
+
}
|
|
2661
|
+
if (distance) {
|
|
2662
|
+
this._addElements(distance, dDict);
|
|
2663
|
+
dArray.push(dDict);
|
|
2664
|
+
}
|
|
2665
|
+
if (area) {
|
|
2666
|
+
this._addElements(area, aDict);
|
|
2667
|
+
aArray.push(aDict);
|
|
2668
|
+
}
|
|
2669
|
+
measureDictionary.set('A', aArray);
|
|
2670
|
+
measureDictionary.set('D', dArray);
|
|
2671
|
+
measureDictionary.set('X', xArray);
|
|
2672
|
+
if (measureDictionary.size > 0 && measureDictionary.has('Type')) {
|
|
2673
|
+
var reference = this._crossReference._getNextReference();
|
|
2674
|
+
this._crossReference._cacheMap.set(reference, measureDictionary);
|
|
2675
|
+
dictionary.update('Measure', reference);
|
|
2676
|
+
}
|
|
2677
|
+
};
|
|
2678
|
+
_XfdfDocument.prototype._addElements = function (element, dictionary) {
|
|
2679
|
+
if (element.hasAttribute('d')) {
|
|
2680
|
+
this._addFloat(dictionary, 'D', element.getAttribute('d'));
|
|
2681
|
+
}
|
|
2682
|
+
if (element.hasAttribute('c')) {
|
|
2683
|
+
this._addFloat(dictionary, 'C', element.getAttribute('c'));
|
|
2684
|
+
}
|
|
2685
|
+
if (element.hasAttribute('rt')) {
|
|
2686
|
+
dictionary.update('RT', element.getAttribute('rt'));
|
|
2687
|
+
}
|
|
2688
|
+
if (element.hasAttribute('rd')) {
|
|
2689
|
+
dictionary.update('RD', element.getAttribute('rt'));
|
|
2690
|
+
}
|
|
2691
|
+
if (element.hasAttribute('ss')) {
|
|
2692
|
+
dictionary.update('SS', element.getAttribute('ss'));
|
|
2693
|
+
}
|
|
2694
|
+
if (element.hasAttribute('u')) {
|
|
2695
|
+
dictionary.update('U', element.getAttribute('u'));
|
|
2696
|
+
}
|
|
2697
|
+
if (element.hasAttribute('f')) {
|
|
2698
|
+
dictionary.update('F', _PdfName.get(element.getAttribute('f')));
|
|
2699
|
+
}
|
|
2700
|
+
if (element.hasAttribute('fd')) {
|
|
2701
|
+
dictionary.update('FD', element.getAttribute('fd') === 'yes' ? true : false);
|
|
2702
|
+
}
|
|
2703
|
+
};
|
|
2704
|
+
_XfdfDocument.prototype._addString = function (dictionary, key, value) {
|
|
2705
|
+
if (value && value !== '') {
|
|
2706
|
+
dictionary.update(key, value);
|
|
2707
|
+
}
|
|
2708
|
+
};
|
|
2709
|
+
_XfdfDocument.prototype._addInt = function (dictionary, key, value) {
|
|
2710
|
+
var intValue = Number.parseInt(value, 10);
|
|
2711
|
+
if (typeof intValue !== 'undefined') {
|
|
2712
|
+
dictionary.update(key, intValue);
|
|
2713
|
+
}
|
|
2714
|
+
};
|
|
2715
|
+
_XfdfDocument.prototype._addFloat = function (dictionary, key, value) {
|
|
2716
|
+
var floatValue = Number.parseFloat(value);
|
|
2717
|
+
if (typeof floatValue !== 'undefined') {
|
|
2718
|
+
dictionary.update(key, floatValue);
|
|
2719
|
+
}
|
|
2720
|
+
};
|
|
2721
|
+
_XfdfDocument.prototype._addFloatPoints = function (dictionary, points, key) {
|
|
2722
|
+
if (points && points.length > 0) {
|
|
2723
|
+
dictionary.update(key, points);
|
|
2724
|
+
}
|
|
2725
|
+
};
|
|
2726
|
+
_XfdfDocument.prototype._addKey = function (primitive, dictionary, element) {
|
|
2727
|
+
if (typeof primitive !== 'undefined' && primitive !== null && element.hasAttribute('KEY')) {
|
|
2728
|
+
dictionary.update(element.getAttribute('KEY'), primitive);
|
|
2729
|
+
}
|
|
2730
|
+
};
|
|
2731
|
+
_XfdfDocument.prototype._addLineEndStyle = function (dictionary, element) {
|
|
2732
|
+
var beginLineStyle = '';
|
|
2733
|
+
if (element.hasAttribute('head')) {
|
|
2734
|
+
beginLineStyle = element.getAttribute('head');
|
|
2735
|
+
}
|
|
2736
|
+
var endLineStyle = '';
|
|
2737
|
+
if (element.hasAttribute('tail')) {
|
|
2738
|
+
endLineStyle = element.getAttribute('tail');
|
|
2739
|
+
}
|
|
2740
|
+
if (beginLineStyle && beginLineStyle !== '') {
|
|
2741
|
+
if (endLineStyle && endLineStyle !== '') {
|
|
2742
|
+
var lineEndingStyles = [];
|
|
2743
|
+
lineEndingStyles.push(_PdfName.get(beginLineStyle));
|
|
2744
|
+
lineEndingStyles.push(_PdfName.get(endLineStyle));
|
|
2745
|
+
dictionary.update('LE', lineEndingStyles);
|
|
2746
|
+
}
|
|
2747
|
+
else {
|
|
2748
|
+
dictionary.update('LE', _PdfName.get(beginLineStyle));
|
|
2749
|
+
}
|
|
2750
|
+
}
|
|
2751
|
+
else if (endLineStyle && endLineStyle !== '') {
|
|
2752
|
+
dictionary.update('LE', _PdfName.get(endLineStyle));
|
|
2753
|
+
}
|
|
2754
|
+
};
|
|
2755
|
+
return _XfdfDocument;
|
|
2756
|
+
}(_ExportHelper));
|
|
2757
|
+
export { _XfdfDocument };
|
|
2758
|
+
var _FontStructure = /** @class */ (function () {
|
|
2759
|
+
function _FontStructure(dictionary) {
|
|
2760
|
+
this._baseFontEncoding = '';
|
|
2761
|
+
this._dictionary = dictionary;
|
|
2762
|
+
this._fontType = this._dictionary.get('Subtype').name;
|
|
2763
|
+
}
|
|
2764
|
+
Object.defineProperty(_FontStructure.prototype, "differencesDictionary", {
|
|
2765
|
+
get: function () {
|
|
2766
|
+
if (!this._differencesDictionary) {
|
|
2767
|
+
this._differencesDictionary = this._getDifferencesDictionary();
|
|
2768
|
+
}
|
|
2769
|
+
return this._differencesDictionary;
|
|
2770
|
+
},
|
|
2771
|
+
enumerable: true,
|
|
2772
|
+
configurable: true
|
|
2773
|
+
});
|
|
2774
|
+
Object.defineProperty(_FontStructure.prototype, "baseFontEncoding", {
|
|
2775
|
+
get: function () {
|
|
2776
|
+
return this._baseFontEncoding;
|
|
2777
|
+
},
|
|
2778
|
+
enumerable: true,
|
|
2779
|
+
configurable: true
|
|
2780
|
+
});
|
|
2781
|
+
Object.defineProperty(_FontStructure.prototype, "fontEncoding", {
|
|
2782
|
+
get: function () {
|
|
2783
|
+
if (!this._fontEncoding) {
|
|
2784
|
+
this._fontEncoding = this._getFontEncoding();
|
|
2785
|
+
}
|
|
2786
|
+
return this._fontEncoding;
|
|
2787
|
+
},
|
|
2788
|
+
enumerable: true,
|
|
2789
|
+
configurable: true
|
|
2790
|
+
});
|
|
2791
|
+
Object.defineProperty(_FontStructure.prototype, "fontName", {
|
|
2792
|
+
get: function () {
|
|
2793
|
+
if (!this._fontName) {
|
|
2794
|
+
this._fontName = this._getFontName();
|
|
2795
|
+
}
|
|
2796
|
+
return this._fontName;
|
|
2797
|
+
},
|
|
2798
|
+
enumerable: true,
|
|
2799
|
+
configurable: true
|
|
2800
|
+
});
|
|
2801
|
+
_FontStructure.prototype._getFontEncoding = function () {
|
|
2802
|
+
var encoding = '';
|
|
2803
|
+
if (this._dictionary !== null && typeof this._dictionary !== 'undefined' && this._dictionary.has('Encoding')) {
|
|
2804
|
+
var baseFont = this._dictionary.get('Encoding'); // eslint-disable-line
|
|
2805
|
+
if (baseFont instanceof _PdfName) {
|
|
2806
|
+
encoding = baseFont.name;
|
|
2807
|
+
}
|
|
2808
|
+
else if (baseFont instanceof _PdfDictionary) {
|
|
2809
|
+
if (baseFont.has('BaseEncoding')) {
|
|
2810
|
+
var baseFontEncoding = baseFont.get('BaseEncoding');
|
|
2811
|
+
if (baseFontEncoding && baseFontEncoding instanceof _PdfName) {
|
|
2812
|
+
this._baseFontEncoding = baseFontEncoding.name;
|
|
2813
|
+
}
|
|
2814
|
+
}
|
|
2815
|
+
if (baseFont.has('Type')) {
|
|
2816
|
+
var fontEncoding = baseFont.get('Type');
|
|
2817
|
+
if (fontEncoding !== null && typeof fontEncoding !== 'undefined') {
|
|
2818
|
+
encoding = fontEncoding.name;
|
|
2819
|
+
}
|
|
2820
|
+
}
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
if (encoding.toString() === 'identity#2dh' || encoding === 'CMap') {
|
|
2824
|
+
encoding = 'Identity-H';
|
|
2825
|
+
}
|
|
2826
|
+
return encoding;
|
|
2827
|
+
};
|
|
2828
|
+
_FontStructure.prototype._getDifferencesDictionary = function () {
|
|
2829
|
+
var result = new Map();
|
|
2830
|
+
if (this._dictionary !== null && typeof this._dictionary !== 'undefined' && this._dictionary.has('Encoding')) {
|
|
2831
|
+
var encoding = this._dictionary.get('Encoding');
|
|
2832
|
+
if (encoding !== null &&
|
|
2833
|
+
typeof encoding !== 'undefined' &&
|
|
2834
|
+
encoding instanceof _PdfDictionary &&
|
|
2835
|
+
encoding.has('Differences')) {
|
|
2836
|
+
var differences = encoding.getArray('Differences'); // eslint-disable-line
|
|
2837
|
+
var count = 0;
|
|
2838
|
+
if (differences !== null && typeof differences !== 'undefined') {
|
|
2839
|
+
for (var i = 0; i < differences.length; i++) {
|
|
2840
|
+
var text = '';
|
|
2841
|
+
var item = differences[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
|
|
2842
|
+
if (typeof item === 'number') {
|
|
2843
|
+
text = item.toString();
|
|
2844
|
+
count = Number.parseInt(text, 10);
|
|
2845
|
+
}
|
|
2846
|
+
else if (item instanceof _PdfName) {
|
|
2847
|
+
text = item.name;
|
|
2848
|
+
if (this._fontType === 'Type1' && text === '.notdef') {
|
|
2849
|
+
text = ' ';
|
|
2850
|
+
result.set(count.toString(), _getLatinCharacter(text));
|
|
2851
|
+
}
|
|
2852
|
+
else {
|
|
2853
|
+
text = _getLatinCharacter(text);
|
|
2854
|
+
text = _getSpecialCharacter(text);
|
|
2855
|
+
if (!result.has(count.toString())) {
|
|
2856
|
+
result.set(count.toString(), _getLatinCharacter(text));
|
|
2857
|
+
}
|
|
2858
|
+
count++;
|
|
2859
|
+
}
|
|
2860
|
+
}
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2863
|
+
}
|
|
2864
|
+
}
|
|
2865
|
+
return result;
|
|
2866
|
+
};
|
|
2867
|
+
_FontStructure.prototype._getFontName = function () {
|
|
2868
|
+
var fontName = '';
|
|
2869
|
+
if (this._dictionary !== null && typeof this._dictionary !== 'undefined' && this._dictionary.has('BaseFont')) {
|
|
2870
|
+
var baseFont = this._dictionary.get('BaseFont');
|
|
2871
|
+
var font = baseFont.name;
|
|
2872
|
+
if (font.indexOf('#20') !== -1 && font.indexOf('+') === -1) {
|
|
2873
|
+
var index = font.lastIndexOf('#20');
|
|
2874
|
+
font = font.substring(0, index);
|
|
2875
|
+
font += '+';
|
|
2876
|
+
}
|
|
2877
|
+
if (baseFont.name.indexOf('+') !== -1) {
|
|
2878
|
+
fontName = baseFont.name.split('+')[1];
|
|
2879
|
+
}
|
|
2880
|
+
else {
|
|
2881
|
+
fontName = baseFont.name;
|
|
2882
|
+
}
|
|
2883
|
+
if (fontName.indexOf('-') !== -1) {
|
|
2884
|
+
fontName = fontName.split('-')[0];
|
|
2885
|
+
}
|
|
2886
|
+
else if (fontName.indexOf(',') !== -1) {
|
|
2887
|
+
fontName = fontName.split(',')[0];
|
|
2888
|
+
}
|
|
2889
|
+
if (fontName.indexOf('MT') !== -1) {
|
|
2890
|
+
fontName = fontName.replace('MT', '');
|
|
2891
|
+
}
|
|
2892
|
+
if (fontName.indexOf('#20') !== -1) {
|
|
2893
|
+
fontName = fontName.replace('#20', ' ');
|
|
2894
|
+
}
|
|
2895
|
+
if (fontName.indexOf('#') !== -1) {
|
|
2896
|
+
fontName = this._decodeHexFontName(fontName);
|
|
2897
|
+
}
|
|
2898
|
+
}
|
|
2899
|
+
return fontName;
|
|
2900
|
+
};
|
|
2901
|
+
_FontStructure.prototype._decodeHexFontName = function (fontName) {
|
|
2902
|
+
var result = fontName;
|
|
2903
|
+
for (var i = 0; i < fontName.length; i++) {
|
|
2904
|
+
if (fontName[Number.parseInt(i.toString(), 10)] === '#') {
|
|
2905
|
+
var hexValue = fontName[i + 1] + fontName[i + 2];
|
|
2906
|
+
var value = Number.parseInt(hexValue, 16);
|
|
2907
|
+
if (value !== 0) {
|
|
2908
|
+
result = result.replace("#" + hexValue, String.fromCharCode(value));
|
|
2909
|
+
i += 2;
|
|
2910
|
+
}
|
|
2911
|
+
if (result.indexOf('#') === -1) {
|
|
2912
|
+
break;
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
}
|
|
2916
|
+
return result;
|
|
2917
|
+
};
|
|
2918
|
+
return _FontStructure;
|
|
2919
|
+
}());
|
|
2920
|
+
export { _FontStructure };
|