@syncfusion/ej2-pdf 1.0.23 → 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 +4 -14
- 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 +58 -16
- package/pdf.d.ts +4 -0
- package/pdf.js +4 -0
- package/src/global.js +1 -0
- package/src/index.d.ts +45 -98
- package/src/index.js +45 -96
- package/src/pdf/core/annotations/annotation-collection.d.ts +289 -0
- package/src/pdf/core/annotations/annotation-collection.js +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 -13
- package/dist/es6/implementation/actions/action.js +0 -44
- package/dist/es6/implementation/actions/index.js +0 -2
- package/dist/es6/implementation/actions/uri-action.js +0 -38
- package/dist/es6/implementation/annotations/action-link-annotation.js +0 -29
- package/dist/es6/implementation/annotations/annotation-collection.js +0 -93
- package/dist/es6/implementation/annotations/annotation.js +0 -156
- package/dist/es6/implementation/annotations/document-link-annotation.js +0 -48
- package/dist/es6/implementation/annotations/index.js +0 -7
- package/dist/es6/implementation/annotations/link-annotation.js +0 -31
- package/dist/es6/implementation/annotations/pdf-text-web-link.js +0 -178
- package/dist/es6/implementation/annotations/uri-annotation.js +0 -64
- package/dist/es6/implementation/collections/dictionary.js +0 -71
- package/dist/es6/implementation/collections/index.js +0 -3
- package/dist/es6/implementation/collections/object-object-pair/dictionary.js +0 -84
- package/dist/es6/implementation/collections/object-object-pair/index.js +0 -1
- package/dist/es6/implementation/collections/utils.js +0 -8
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -17
- package/dist/es6/implementation/document/automatic-fields/automatic-field-info.js +0 -68
- package/dist/es6/implementation/document/automatic-fields/automatic-field.js +0 -145
- package/dist/es6/implementation/document/automatic-fields/composite-field.js +0 -61
- package/dist/es6/implementation/document/automatic-fields/index.js +0 -7
- package/dist/es6/implementation/document/automatic-fields/multiple-value-field.js +0 -36
- package/dist/es6/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/dist/es6/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -91
- package/dist/es6/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/dist/es6/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -34
- package/dist/es6/implementation/document/automatic-fields/single-value-field.js +0 -47
- package/dist/es6/implementation/document/index.js +0 -11
- package/dist/es6/implementation/document/pdf-catalog.js +0 -38
- package/dist/es6/implementation/document/pdf-document-base.js +0 -71
- package/dist/es6/implementation/document/pdf-document-template.js +0 -204
- package/dist/es6/implementation/document/pdf-document.js +0 -175
- package/dist/es6/implementation/drawing/index.js +0 -1
- package/dist/es6/implementation/drawing/pdf-drawing.js +0 -80
- package/dist/es6/implementation/general/enum.js +0 -6
- package/dist/es6/implementation/general/index.js +0 -3
- package/dist/es6/implementation/general/pdf-cache-collection.js +0 -24
- package/dist/es6/implementation/general/pdf-collection.js +0 -26
- package/dist/es6/implementation/general/pdf-destination.js +0 -107
- package/dist/es6/implementation/graphics/brushes/index.js +0 -2
- package/dist/es6/implementation/graphics/brushes/pdf-brush.js +0 -6
- package/dist/es6/implementation/graphics/brushes/pdf-solid-brush.js +0 -53
- package/dist/es6/implementation/graphics/constants.js +0 -11
- package/dist/es6/implementation/graphics/enum.js +0 -100
- package/dist/es6/implementation/graphics/figures/base/element-layouter.js +0 -154
- package/dist/es6/implementation/graphics/figures/base/graphics-element.js +0 -18
- package/dist/es6/implementation/graphics/figures/base/index.js +0 -3
- package/dist/es6/implementation/graphics/figures/base/pdf-shape-element.js +0 -32
- package/dist/es6/implementation/graphics/figures/base/shape-layouter.js +0 -55
- package/dist/es6/implementation/graphics/figures/base/text-layouter.js +0 -123
- package/dist/es6/implementation/graphics/figures/enum.js +0 -11
- package/dist/es6/implementation/graphics/figures/index.js +0 -5
- package/dist/es6/implementation/graphics/figures/layout-element.js +0 -41
- package/dist/es6/implementation/graphics/figures/pdf-template.js +0 -110
- package/dist/es6/implementation/graphics/figures/text-element.js +0 -298
- package/dist/es6/implementation/graphics/fonts/enum.js +0 -45
- package/dist/es6/implementation/graphics/fonts/pdf-font-metrics.js +0 -122
- package/dist/es6/implementation/graphics/fonts/pdf-font.js +0 -159
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -357
- package/dist/es6/implementation/graphics/fonts/pdf-standard-font.js +0 -124
- package/dist/es6/implementation/graphics/fonts/pdf-string-format.js +0 -239
- package/dist/es6/implementation/graphics/fonts/string-layouter.js +0 -335
- package/dist/es6/implementation/graphics/fonts/string-tokenizer.js +0 -162
- package/dist/es6/implementation/graphics/images/byte-array.js +0 -82
- package/dist/es6/implementation/graphics/images/image-decoder.js +0 -167
- package/dist/es6/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/dist/es6/implementation/graphics/images/pdf-image.js +0 -68
- package/dist/es6/implementation/graphics/index.js +0 -20
- package/dist/es6/implementation/graphics/pdf-color.js +0 -205
- package/dist/es6/implementation/graphics/pdf-graphics.js +0 -1034
- package/dist/es6/implementation/graphics/pdf-margins.js +0 -75
- package/dist/es6/implementation/graphics/pdf-pen.js +0 -180
- package/dist/es6/implementation/graphics/pdf-resources.js +0 -223
- package/dist/es6/implementation/graphics/pdf-transformation-matrix.js +0 -134
- package/dist/es6/implementation/graphics/pdf-transparency.js +0 -22
- package/dist/es6/implementation/graphics/unit-convertor.js +0 -33
- package/dist/es6/implementation/index.js +0 -85
- package/dist/es6/implementation/input-output/cross-table.js +0 -6
- package/dist/es6/implementation/input-output/enum.js +0 -5
- package/dist/es6/implementation/input-output/index.js +0 -8
- package/dist/es6/implementation/input-output/pdf-cross-table.js +0 -346
- package/dist/es6/implementation/input-output/pdf-dictionary-properties.js +0 -60
- package/dist/es6/implementation/input-output/pdf-main-object-collection.js +0 -115
- package/dist/es6/implementation/input-output/pdf-operators.js +0 -75
- package/dist/es6/implementation/input-output/pdf-stream-writer.js +0 -364
- package/dist/es6/implementation/input-output/pdf-writer.js +0 -44
- package/dist/es6/implementation/pages/enum.js +0 -51
- package/dist/es6/implementation/pages/index.js +0 -13
- package/dist/es6/implementation/pages/page-added-event-arguments.js +0 -19
- package/dist/es6/implementation/pages/pdf-document-page-collection.js +0 -120
- package/dist/es6/implementation/pages/pdf-page-base.js +0 -104
- package/dist/es6/implementation/pages/pdf-page-layer-collection.js +0 -115
- package/dist/es6/implementation/pages/pdf-page-layer.js +0 -160
- package/dist/es6/implementation/pages/pdf-page-settings.js +0 -126
- package/dist/es6/implementation/pages/pdf-page-size.js +0 -36
- package/dist/es6/implementation/pages/pdf-page-template-element.js +0 -510
- package/dist/es6/implementation/pages/pdf-page.js +0 -130
- package/dist/es6/implementation/pages/pdf-section-collection.js +0 -95
- package/dist/es6/implementation/pages/pdf-section-page-collection.js +0 -30
- package/dist/es6/implementation/pages/pdf-section-templates.js +0 -71
- package/dist/es6/implementation/pages/pdf-section.js +0 -388
- package/dist/es6/implementation/primitives/index.js +0 -8
- package/dist/es6/implementation/primitives/pdf-array.js +0 -199
- package/dist/es6/implementation/primitives/pdf-boolean.js +0 -66
- package/dist/es6/implementation/primitives/pdf-dictionary.js +0 -220
- package/dist/es6/implementation/primitives/pdf-name.js +0 -102
- package/dist/es6/implementation/primitives/pdf-number.js +0 -94
- package/dist/es6/implementation/primitives/pdf-reference.js +0 -195
- package/dist/es6/implementation/primitives/pdf-stream.js +0 -149
- package/dist/es6/implementation/primitives/pdf-string.js +0 -143
- package/dist/es6/implementation/structured-elements/grid/index.js +0 -1
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-cell.js +0 -512
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-column.js +0 -125
- package/dist/es6/implementation/structured-elements/grid/pdf-grid-row.js +0 -244
- package/dist/es6/implementation/structured-elements/grid/pdf-grid.js +0 -989
- package/dist/es6/implementation/structured-elements/grid/styles/index.js +0 -2
- package/dist/es6/implementation/structured-elements/grid/styles/pdf-borders.js +0 -145
- package/dist/es6/implementation/structured-elements/grid/styles/style.js +0 -267
- package/dist/es6/implementation/structured-elements/index.js +0 -1
- package/dist/es6/implementation/structured-elements/tables/light-tables/enum.js +0 -5
- package/dist/es6/index.js +0 -89
- package/dist/es6/interfaces/i-pdf-cache.js +0 -1
- package/dist/es6/interfaces/i-pdf-changable.js +0 -1
- package/dist/es6/interfaces/i-pdf-primitives.js +0 -1
- package/dist/es6/interfaces/i-pdf-wrapper.js +0 -1
- package/dist/es6/interfaces/i-pdf-writer.js +0 -1
- package/dist/es6/interfaces/index.js +0 -1
- package/dist/global/ej2-pdf-export.js +0 -15979
- package/implementation.d.ts +0 -4
- package/implementation.js +0 -8
- package/interfaces.d.ts +0 -4
- package/interfaces.js +0 -4
- package/src/implementation/actions/action.d.ts +0 -50
- package/src/implementation/actions/action.js +0 -44
- package/src/implementation/actions/index.d.ts +0 -6
- package/src/implementation/actions/index.js +0 -9
- package/src/implementation/actions/uri-action.d.ts +0 -33
- package/src/implementation/actions/uri-action.js +0 -39
- package/src/implementation/annotations/action-link-annotation.d.ts +0 -30
- package/src/implementation/annotations/action-link-annotation.js +0 -32
- package/src/implementation/annotations/annotation-collection.d.ts +0 -77
- package/src/implementation/annotations/annotation-collection.js +0 -91
- package/src/implementation/annotations/annotation.d.ts +0 -152
- package/src/implementation/annotations/annotation.js +0 -146
- package/src/implementation/annotations/document-link-annotation.d.ts +0 -89
- package/src/implementation/annotations/document-link-annotation.js +0 -51
- package/src/implementation/annotations/index.d.ts +0 -11
- package/src/implementation/annotations/index.js +0 -14
- package/src/implementation/annotations/link-annotation.d.ts +0 -23
- package/src/implementation/annotations/link-annotation.js +0 -33
- package/src/implementation/annotations/pdf-text-web-link.d.ts +0 -118
- package/src/implementation/annotations/pdf-text-web-link.js +0 -173
- package/src/implementation/annotations/uri-annotation.d.ts +0 -48
- package/src/implementation/annotations/uri-annotation.js +0 -65
- package/src/implementation/collections/dictionary.d.ts +0 -76
- package/src/implementation/collections/dictionary.js +0 -74
- package/src/implementation/collections/index.d.ts +0 -7
- package/src/implementation/collections/index.js +0 -10
- package/src/implementation/collections/object-object-pair/dictionary.d.ts +0 -62
- package/src/implementation/collections/object-object-pair/dictionary.js +0 -88
- package/src/implementation/collections/object-object-pair/index.d.ts +0 -5
- package/src/implementation/collections/object-object-pair/index.js +0 -8
- package/src/implementation/collections/utils.d.ts +0 -27
- package/src/implementation/collections/utils.js +0 -13
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.d.ts +0 -31
- package/src/implementation/document/automatic-fields/automatic-field-info-collection.js +0 -21
- package/src/implementation/document/automatic-fields/automatic-field-info.d.ts +0 -67
- package/src/implementation/document/automatic-fields/automatic-field-info.js +0 -70
- package/src/implementation/document/automatic-fields/automatic-field.d.ts +0 -41
- package/src/implementation/document/automatic-fields/automatic-field.js +0 -143
- package/src/implementation/document/automatic-fields/composite-field.d.ts +0 -46
- package/src/implementation/document/automatic-fields/composite-field.js +0 -64
- package/src/implementation/document/automatic-fields/index.d.ts +0 -11
- package/src/implementation/document/automatic-fields/index.js +0 -14
- package/src/implementation/document/automatic-fields/multiple-value-field.d.ts +0 -18
- package/src/implementation/document/automatic-fields/multiple-value-field.js +0 -35
- package/src/implementation/document/automatic-fields/page-count-field.d.ts +0 -44
- package/src/implementation/document/automatic-fields/page-count-field.js +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.d.ts +0 -53
- package/src/implementation/document/automatic-fields/pdf-numbers-convertor.js +0 -94
- package/src/implementation/document/automatic-fields/pdf-page-number-field.d.ts +0 -51
- package/src/implementation/document/automatic-fields/pdf-page-number-field.js +0 -56
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.d.ts +0 -38
- package/src/implementation/document/automatic-fields/pdf-template-value-pair.js +0 -38
- package/src/implementation/document/automatic-fields/single-value-field.d.ts +0 -15
- package/src/implementation/document/automatic-fields/single-value-field.js +0 -46
- package/src/implementation/document/index.d.ts +0 -15
- package/src/implementation/document/index.js +0 -18
- package/src/implementation/document/pdf-catalog.d.ts +0 -32
- package/src/implementation/document/pdf-catalog.js +0 -38
- package/src/implementation/document/pdf-document-base.d.ts +0 -117
- package/src/implementation/document/pdf-document-base.js +0 -72
- package/src/implementation/document/pdf-document-template.d.ts +0 -166
- package/src/implementation/document/pdf-document-template.js +0 -207
- package/src/implementation/document/pdf-document.d.ts +0 -206
- package/src/implementation/document/pdf-document.js +0 -166
- package/src/implementation/drawing/index.d.ts +0 -5
- package/src/implementation/drawing/index.js +0 -8
- package/src/implementation/drawing/pdf-drawing.d.ts +0 -93
- package/src/implementation/drawing/pdf-drawing.js +0 -84
- package/src/implementation/general/enum.d.ts +0 -21
- package/src/implementation/general/enum.js +0 -10
- package/src/implementation/general/index.d.ts +0 -7
- package/src/implementation/general/index.js +0 -10
- package/src/implementation/general/pdf-cache-collection.d.ts +0 -33
- package/src/implementation/general/pdf-cache-collection.js +0 -27
- package/src/implementation/general/pdf-collection.d.ts +0 -26
- package/src/implementation/general/pdf-collection.js +0 -30
- package/src/implementation/general/pdf-destination.d.ts +0 -103
- package/src/implementation/general/pdf-destination.js +0 -103
- package/src/implementation/graphics/brushes/index.d.ts +0 -6
- package/src/implementation/graphics/brushes/index.js +0 -9
- package/src/implementation/graphics/brushes/pdf-brush.d.ts +0 -55
- package/src/implementation/graphics/brushes/pdf-brush.js +0 -10
- package/src/implementation/graphics/brushes/pdf-solid-brush.d.ts +0 -77
- package/src/implementation/graphics/brushes/pdf-solid-brush.js +0 -54
- package/src/implementation/graphics/constants.d.ts +0 -31
- package/src/implementation/graphics/constants.js +0 -15
- package/src/implementation/graphics/enum.d.ts +0 -392
- package/src/implementation/graphics/enum.js +0 -104
- package/src/implementation/graphics/figures/base/element-layouter.d.ts +0 -160
- package/src/implementation/graphics/figures/base/element-layouter.js +0 -156
- package/src/implementation/graphics/figures/base/graphics-element.d.ts +0 -16
- package/src/implementation/graphics/figures/base/graphics-element.js +0 -22
- package/src/implementation/graphics/figures/base/index.d.ts +0 -7
- package/src/implementation/graphics/figures/base/index.js +0 -10
- package/src/implementation/graphics/figures/base/pdf-shape-element.d.ts +0 -28
- package/src/implementation/graphics/figures/base/pdf-shape-element.js +0 -34
- package/src/implementation/graphics/figures/base/shape-layouter.d.ts +0 -80
- package/src/implementation/graphics/figures/base/shape-layouter.js +0 -57
- package/src/implementation/graphics/figures/base/text-layouter.d.ts +0 -107
- package/src/implementation/graphics/figures/base/text-layouter.js +0 -121
- package/src/implementation/graphics/figures/enum.d.ts +0 -37
- package/src/implementation/graphics/figures/enum.js +0 -15
- package/src/implementation/graphics/figures/index.d.ts +0 -9
- package/src/implementation/graphics/figures/index.js +0 -12
- package/src/implementation/graphics/figures/layout-element.d.ts +0 -57
- package/src/implementation/graphics/figures/layout-element.js +0 -43
- package/src/implementation/graphics/figures/pdf-template.d.ts +0 -113
- package/src/implementation/graphics/figures/pdf-template.js +0 -106
- package/src/implementation/graphics/figures/text-element.d.ts +0 -213
- package/src/implementation/graphics/figures/text-element.js +0 -289
- package/src/implementation/graphics/fonts/enum.d.ts +0 -179
- package/src/implementation/graphics/fonts/enum.js +0 -49
- package/src/implementation/graphics/fonts/index.d.ts +0 -12
- package/src/implementation/graphics/fonts/index.js +0 -15
- package/src/implementation/graphics/fonts/pdf-font-metrics.d.ts +0 -160
- package/src/implementation/graphics/fonts/pdf-font-metrics.js +0 -123
- package/src/implementation/graphics/fonts/pdf-font.d.ts +0 -187
- package/src/implementation/graphics/fonts/pdf-font.js +0 -158
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.d.ts +0 -301
- package/src/implementation/graphics/fonts/pdf-standard-font-metrics-factory.js +0 -359
- package/src/implementation/graphics/fonts/pdf-standard-font.d.ts +0 -143
- package/src/implementation/graphics/fonts/pdf-standard-font.js +0 -121
- package/src/implementation/graphics/fonts/pdf-string-format.d.ts +0 -319
- package/src/implementation/graphics/fonts/pdf-string-format.js +0 -241
- package/src/implementation/graphics/fonts/string-layouter.d.ts +0 -255
- package/src/implementation/graphics/fonts/string-layouter.js +0 -336
- package/src/implementation/graphics/fonts/string-tokenizer.d.ts +0 -107
- package/src/implementation/graphics/fonts/string-tokenizer.js +0 -166
- package/src/implementation/graphics/images/byte-array.d.ts +0 -68
- package/src/implementation/graphics/images/byte-array.js +0 -86
- package/src/implementation/graphics/images/image-decoder.d.ts +0 -227
- package/src/implementation/graphics/images/image-decoder.js +0 -164
- package/src/implementation/graphics/images/index.js +0 -11
- package/src/implementation/graphics/images/pdf-bitmap.d.ts +0 -90
- package/src/implementation/graphics/images/pdf-bitmap.js +0 -41
- package/src/implementation/graphics/images/pdf-image.d.ts +0 -88
- package/src/implementation/graphics/images/pdf-image.js +0 -69
- package/src/implementation/graphics/index.d.ts +0 -24
- package/src/implementation/graphics/index.js +0 -27
- package/src/implementation/graphics/pdf-color.d.ts +0 -170
- package/src/implementation/graphics/pdf-color.js +0 -204
- package/src/implementation/graphics/pdf-graphics.d.ts +0 -1085
- package/src/implementation/graphics/pdf-graphics.js +0 -1017
- package/src/implementation/graphics/pdf-margins.d.ts +0 -82
- package/src/implementation/graphics/pdf-margins.js +0 -79
- package/src/implementation/graphics/pdf-pen.d.ts +0 -237
- package/src/implementation/graphics/pdf-pen.js +0 -181
- package/src/implementation/graphics/pdf-resources.d.ts +0 -147
- package/src/implementation/graphics/pdf-resources.js +0 -215
- package/src/implementation/graphics/pdf-transformation-matrix.d.ts +0 -143
- package/src/implementation/graphics/pdf-transformation-matrix.js +0 -136
- package/src/implementation/graphics/pdf-transparency.d.ts +0 -34
- package/src/implementation/graphics/pdf-transparency.js +0 -22
- package/src/implementation/graphics/unit-convertor.d.ts +0 -72
- package/src/implementation/graphics/unit-convertor.js +0 -37
- package/src/implementation/index.d.ts +0 -89
- package/src/implementation/index.js +0 -92
- package/src/implementation/input-output/cross-table.d.ts +0 -21
- package/src/implementation/input-output/cross-table.js +0 -10
- package/src/implementation/input-output/enum.d.ts +0 -16
- package/src/implementation/input-output/enum.js +0 -9
- package/src/implementation/input-output/index.d.ts +0 -12
- package/src/implementation/input-output/index.js +0 -15
- package/src/implementation/input-output/pdf-cross-table.d.ts +0 -249
- package/src/implementation/input-output/pdf-cross-table.js +0 -340
- package/src/implementation/input-output/pdf-dictionary-properties.d.ts +0 -283
- package/src/implementation/input-output/pdf-dictionary-properties.js +0 -64
- package/src/implementation/input-output/pdf-main-object-collection.d.ts +0 -120
- package/src/implementation/input-output/pdf-main-object-collection.js +0 -117
- package/src/implementation/input-output/pdf-operators.d.ts +0 -352
- package/src/implementation/input-output/pdf-operators.js +0 -79
- package/src/implementation/input-output/pdf-stream-writer.d.ts +0 -314
- package/src/implementation/input-output/pdf-stream-writer.js +0 -363
- package/src/implementation/input-output/pdf-writer.d.ts +0 -68
- package/src/implementation/input-output/pdf-writer.js +0 -48
- package/src/implementation/pages/enum.d.ts +0 -201
- package/src/implementation/pages/enum.js +0 -55
- package/src/implementation/pages/index.d.ts +0 -17
- package/src/implementation/pages/index.js +0 -20
- package/src/implementation/pages/page-added-event-arguments.d.ts +0 -30
- package/src/implementation/pages/page-added-event-arguments.js +0 -23
- package/src/implementation/pages/pdf-document-page-collection.d.ts +0 -92
- package/src/implementation/pages/pdf-document-page-collection.js +0 -121
- package/src/implementation/pages/pdf-page-base.d.ts +0 -121
- package/src/implementation/pages/pdf-page-base.js +0 -104
- package/src/implementation/pages/pdf-page-layer-collection.d.ts +0 -99
- package/src/implementation/pages/pdf-page-layer-collection.js +0 -113
- package/src/implementation/pages/pdf-page-layer.d.ts +0 -160
- package/src/implementation/pages/pdf-page-layer.js +0 -159
- package/src/implementation/pages/pdf-page-settings.d.ts +0 -111
- package/src/implementation/pages/pdf-page-settings.js +0 -126
- package/src/implementation/pages/pdf-page-size.d.ts +0 -159
- package/src/implementation/pages/pdf-page-size.js +0 -39
- package/src/implementation/pages/pdf-page-template-element.d.ts +0 -230
- package/src/implementation/pages/pdf-page-template-element.js +0 -509
- package/src/implementation/pages/pdf-page.d.ts +0 -153
- package/src/implementation/pages/pdf-page.js +0 -127
- package/src/implementation/pages/pdf-section-collection.d.ts +0 -109
- package/src/implementation/pages/pdf-section-collection.js +0 -91
- package/src/implementation/pages/pdf-section-page-collection.d.ts +0 -41
- package/src/implementation/pages/pdf-section-page-collection.js +0 -34
- package/src/implementation/pages/pdf-section-templates.d.ts +0 -64
- package/src/implementation/pages/pdf-section-templates.js +0 -74
- package/src/implementation/pages/pdf-section.d.ts +0 -319
- package/src/implementation/pages/pdf-section.js +0 -379
- package/src/implementation/primitives/index.d.ts +0 -12
- package/src/implementation/primitives/index.js +0 -15
- package/src/implementation/primitives/pdf-array.d.ts +0 -186
- package/src/implementation/primitives/pdf-array.js +0 -201
- package/src/implementation/primitives/pdf-boolean.d.ts +0 -84
- package/src/implementation/primitives/pdf-boolean.js +0 -70
- package/src/implementation/primitives/pdf-dictionary.d.ts +0 -311
- package/src/implementation/primitives/pdf-dictionary.js +0 -220
- package/src/implementation/primitives/pdf-name.d.ts +0 -121
- package/src/implementation/primitives/pdf-name.js +0 -106
- package/src/implementation/primitives/pdf-number.d.ts +0 -104
- package/src/implementation/primitives/pdf-number.js +0 -98
- package/src/implementation/primitives/pdf-reference.d.ts +0 -222
- package/src/implementation/primitives/pdf-reference.js +0 -192
- package/src/implementation/primitives/pdf-stream.d.ts +0 -111
- package/src/implementation/primitives/pdf-stream.js +0 -146
- package/src/implementation/primitives/pdf-string.d.ts +0 -212
- package/src/implementation/primitives/pdf-string.js +0 -147
- package/src/implementation/structured-elements/grid/index.d.ts +0 -0
- package/src/implementation/structured-elements/grid/index.js +0 -1
- package/src/implementation/structured-elements/grid/pdf-grid-cell.d.ts +0 -248
- package/src/implementation/structured-elements/grid/pdf-grid-cell.js +0 -504
- package/src/implementation/structured-elements/grid/pdf-grid-column.d.ts +0 -108
- package/src/implementation/structured-elements/grid/pdf-grid-column.js +0 -127
- package/src/implementation/structured-elements/grid/pdf-grid-row.d.ts +0 -207
- package/src/implementation/structured-elements/grid/pdf-grid-row.js +0 -246
- package/src/implementation/structured-elements/grid/pdf-grid.d.ts +0 -678
- package/src/implementation/structured-elements/grid/pdf-grid.js +0 -982
- package/src/implementation/structured-elements/grid/styles/index.d.ts +0 -5
- package/src/implementation/structured-elements/grid/styles/index.js +0 -9
- package/src/implementation/structured-elements/grid/styles/pdf-borders.d.ts +0 -126
- package/src/implementation/structured-elements/grid/styles/pdf-borders.js +0 -146
- package/src/implementation/structured-elements/grid/styles/style.d.ts +0 -250
- package/src/implementation/structured-elements/grid/styles/style.js +0 -269
- package/src/implementation/structured-elements/index.d.ts +0 -0
- package/src/implementation/structured-elements/index.js +0 -1
- package/src/implementation/structured-elements/tables/light-tables/enum.d.ts +0 -16
- package/src/implementation/structured-elements/tables/light-tables/enum.js +0 -9
- package/src/interfaces/i-pdf-cache.d.ts +0 -23
- package/src/interfaces/i-pdf-cache.js +0 -4
- package/src/interfaces/i-pdf-changable.d.ts +0 -17
- package/src/interfaces/i-pdf-changable.js +0 -4
- package/src/interfaces/i-pdf-primitives.d.ts +0 -45
- package/src/interfaces/i-pdf-primitives.js +0 -4
- package/src/interfaces/i-pdf-wrapper.d.ts +0 -13
- package/src/interfaces/i-pdf-wrapper.js +0 -4
- package/src/interfaces/i-pdf-writer.d.ts +0 -29
- package/src/interfaces/i-pdf-writer.js +0 -4
- package/src/interfaces/index.d.ts +0 -9
- package/src/interfaces/index.js +0 -4
|
@@ -0,0 +1,782 @@
|
|
|
1
|
+
import { _PdfDictionary, _PdfName, _PdfReference } from './../pdf-primitives';
|
|
2
|
+
import { PdfField, PdfTextBoxField, PdfButtonField, PdfCheckBoxField, PdfRadioButtonListField, PdfComboBoxField, PdfListBoxField, PdfSignatureField } from './field';
|
|
3
|
+
import { _getInheritableProperty, _getPageIndex } from './../utils';
|
|
4
|
+
import { PdfFormFieldsTabOrder, _FieldFlag, _SignatureFlag } from './../enumerator';
|
|
5
|
+
import { PdfPage } from './../pdf-page';
|
|
6
|
+
/**
|
|
7
|
+
* Represents a PDF form.
|
|
8
|
+
* ```typescript
|
|
9
|
+
* // Load an existing PDF document
|
|
10
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
11
|
+
* // Access the form of the PDF document
|
|
12
|
+
* let form: PdfForm = document.form;
|
|
13
|
+
* // Save the document
|
|
14
|
+
* document.save('output.pdf');
|
|
15
|
+
* // Destroy the document
|
|
16
|
+
* document.destroy();
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
var PdfForm = /** @class */ (function () {
|
|
20
|
+
/**
|
|
21
|
+
* Represents a loaded from the PDF document.
|
|
22
|
+
*
|
|
23
|
+
* @private
|
|
24
|
+
* @param {_PdfDictionary} dictionary Form dictionary.
|
|
25
|
+
* @param {_PdfCrossReference} crossReference Cross reference object.
|
|
26
|
+
*/
|
|
27
|
+
function PdfForm(dictionary, crossReference) {
|
|
28
|
+
this._hasKids = false;
|
|
29
|
+
this._setAppearance = false;
|
|
30
|
+
this._exportEmptyFields = false;
|
|
31
|
+
this._fieldCollection = [];
|
|
32
|
+
this._signFlag = _SignatureFlag.none;
|
|
33
|
+
this._dictionary = dictionary;
|
|
34
|
+
this._crossReference = crossReference;
|
|
35
|
+
this._parsedFields = new Map();
|
|
36
|
+
this._fields = [];
|
|
37
|
+
this._createFields();
|
|
38
|
+
}
|
|
39
|
+
Object.defineProperty(PdfForm.prototype, "count", {
|
|
40
|
+
/**
|
|
41
|
+
* Gets the fields count (Read only).
|
|
42
|
+
*
|
|
43
|
+
* @returns {number} Fields count.
|
|
44
|
+
*
|
|
45
|
+
* ```typescript
|
|
46
|
+
* // Load an existing PDF document
|
|
47
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
48
|
+
* // Access loaded form
|
|
49
|
+
* let form: PdfForm = document.form;
|
|
50
|
+
* // Gets the fields count
|
|
51
|
+
* let count: number = form.count;
|
|
52
|
+
* // Destroy the document
|
|
53
|
+
* document.destroy();
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
get: function () {
|
|
57
|
+
return this._fields.length;
|
|
58
|
+
},
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true
|
|
61
|
+
});
|
|
62
|
+
Object.defineProperty(PdfForm.prototype, "needAppearances", {
|
|
63
|
+
/**
|
|
64
|
+
* Gets a value indicating whether need appearances (Read only).
|
|
65
|
+
*
|
|
66
|
+
* @returns {boolean} Need appearances.
|
|
67
|
+
*
|
|
68
|
+
* ```typescript
|
|
69
|
+
* // Load an existing PDF document
|
|
70
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
71
|
+
* // Access loaded form
|
|
72
|
+
* let form: PdfForm = document.form;
|
|
73
|
+
* // Gets the boolean flag indicating need appearances
|
|
74
|
+
* let needAppearances: number = form.needAppearances;
|
|
75
|
+
* // Destroy the document
|
|
76
|
+
* document.destroy();
|
|
77
|
+
* ```
|
|
78
|
+
*/
|
|
79
|
+
get: function () {
|
|
80
|
+
if (this._dictionary.has('NeedAppearances')) {
|
|
81
|
+
this._needAppearances = this._dictionary.get('NeedAppearances');
|
|
82
|
+
}
|
|
83
|
+
return this._needAppearances;
|
|
84
|
+
},
|
|
85
|
+
enumerable: true,
|
|
86
|
+
configurable: true
|
|
87
|
+
});
|
|
88
|
+
Object.defineProperty(PdfForm.prototype, "exportEmptyFields", {
|
|
89
|
+
/**
|
|
90
|
+
* Gets a value indicating whether allow to export empty fields or not.
|
|
91
|
+
*
|
|
92
|
+
* @returns {boolean} Export empty fields.
|
|
93
|
+
* ```typescript
|
|
94
|
+
* // Load an existing PDF document
|
|
95
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
96
|
+
* // Access loaded form
|
|
97
|
+
* let form: PdfForm = document.form;
|
|
98
|
+
* // Gets a value indicating whether allow to export empty fields or not.
|
|
99
|
+
* let exportEmptyFields: boolean = form.exportEmptyFields;
|
|
100
|
+
* // Save the document
|
|
101
|
+
* document.save('output.pdf');
|
|
102
|
+
* // Destroy the document
|
|
103
|
+
* document.destroy();
|
|
104
|
+
* ```
|
|
105
|
+
*/
|
|
106
|
+
get: function () {
|
|
107
|
+
return this._exportEmptyFields;
|
|
108
|
+
},
|
|
109
|
+
/**
|
|
110
|
+
* Sets a value indicating whether allow to export empty fields or not.
|
|
111
|
+
*
|
|
112
|
+
* @param {boolean} value Export empty fields.
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Load an existing PDF document
|
|
115
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
116
|
+
* // Access loaded form
|
|
117
|
+
* let form: PdfForm = document.form;
|
|
118
|
+
* // Sets a value indicating whether allow to export empty fields or not.
|
|
119
|
+
* form.exportEmptyFields = false;
|
|
120
|
+
* // Save the document
|
|
121
|
+
* document.save('output.pdf');
|
|
122
|
+
* // Destroy the document
|
|
123
|
+
* document.destroy();
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
set: function (value) {
|
|
127
|
+
this._exportEmptyFields = value;
|
|
128
|
+
},
|
|
129
|
+
enumerable: true,
|
|
130
|
+
configurable: true
|
|
131
|
+
});
|
|
132
|
+
Object.defineProperty(PdfForm.prototype, "_signatureFlag", {
|
|
133
|
+
get: function () {
|
|
134
|
+
return this._signFlag;
|
|
135
|
+
},
|
|
136
|
+
set: function (value) {
|
|
137
|
+
if (value !== this._signFlag) {
|
|
138
|
+
this._signFlag = value;
|
|
139
|
+
this._dictionary.update('SigFlags', value);
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
enumerable: true,
|
|
143
|
+
configurable: true
|
|
144
|
+
});
|
|
145
|
+
/**
|
|
146
|
+
* Gets the `PdfField` at the specified index.
|
|
147
|
+
*
|
|
148
|
+
* @param {number} index Field index.
|
|
149
|
+
* @returns {PdfField} Loaded PDF form field at the specified index.
|
|
150
|
+
*
|
|
151
|
+
* ```typescript
|
|
152
|
+
* // Load an existing PDF document
|
|
153
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
154
|
+
* // Access the loaded form field
|
|
155
|
+
* let field: PdfField = document.form.fieldAt(0);
|
|
156
|
+
* // Save the document
|
|
157
|
+
* document.save('output.pdf');
|
|
158
|
+
* // Destroy the document
|
|
159
|
+
* document.destroy();
|
|
160
|
+
* ```
|
|
161
|
+
*/
|
|
162
|
+
PdfForm.prototype.fieldAt = function (index) {
|
|
163
|
+
if (index < 0 || index >= this._fields.length) {
|
|
164
|
+
throw Error('Index out of range.');
|
|
165
|
+
}
|
|
166
|
+
var field;
|
|
167
|
+
if (this._parsedFields.has(index)) {
|
|
168
|
+
field = this._parsedFields.get(index);
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
var dictionary = void 0;
|
|
172
|
+
var ref = this._fields[index]; // eslint-disable-line
|
|
173
|
+
if (ref && ref instanceof _PdfReference) {
|
|
174
|
+
dictionary = this._crossReference._fetch(ref);
|
|
175
|
+
}
|
|
176
|
+
if (dictionary) {
|
|
177
|
+
var key = _getInheritableProperty(dictionary, 'FT', false, true, 'Parent');
|
|
178
|
+
var fieldFlags = 0;
|
|
179
|
+
var flag = _getInheritableProperty(dictionary, 'Ff', false, true, 'Parent');
|
|
180
|
+
if (typeof flag !== 'undefined') {
|
|
181
|
+
fieldFlags = flag;
|
|
182
|
+
}
|
|
183
|
+
if (key) {
|
|
184
|
+
switch (key.name.toLowerCase()) {
|
|
185
|
+
case 'tx':
|
|
186
|
+
field = PdfTextBoxField._load(this, dictionary, this._crossReference, ref);
|
|
187
|
+
break;
|
|
188
|
+
case 'btn':
|
|
189
|
+
if ((fieldFlags & _FieldFlag.pushButton) !== 0) {
|
|
190
|
+
field = PdfButtonField._load(this, dictionary, this._crossReference, ref);
|
|
191
|
+
}
|
|
192
|
+
else if ((fieldFlags & _FieldFlag.radio) !== 0) {
|
|
193
|
+
field = PdfRadioButtonListField._load(this, dictionary, this._crossReference, ref);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
field = PdfCheckBoxField._load(this, dictionary, this._crossReference, ref);
|
|
197
|
+
}
|
|
198
|
+
break;
|
|
199
|
+
case 'ch':
|
|
200
|
+
if ((fieldFlags & _FieldFlag.combo) !== 0) {
|
|
201
|
+
field = PdfComboBoxField._load(this, dictionary, this._crossReference, ref);
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
field = PdfListBoxField._load(this, dictionary, this._crossReference, ref);
|
|
205
|
+
}
|
|
206
|
+
break;
|
|
207
|
+
case 'sig':
|
|
208
|
+
field = PdfSignatureField._load(this, dictionary, this._crossReference, ref);
|
|
209
|
+
break;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
this._parsedFields.set(index, field);
|
|
213
|
+
if (field && field instanceof PdfField) {
|
|
214
|
+
field._annotationIndex = index;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return field;
|
|
219
|
+
};
|
|
220
|
+
/**
|
|
221
|
+
* Add a new `PdfField`.
|
|
222
|
+
*
|
|
223
|
+
* @param {PdfField} field Field object to add.
|
|
224
|
+
* @returns {number} Field index.
|
|
225
|
+
*
|
|
226
|
+
* ```typescript
|
|
227
|
+
* // Load an existing PDF document
|
|
228
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
229
|
+
* // Add a new form field
|
|
230
|
+
* let index: number = document.form.add(field);
|
|
231
|
+
* // Save the document
|
|
232
|
+
* document.save('output.pdf');
|
|
233
|
+
* // Destroy the document
|
|
234
|
+
* document.destroy();
|
|
235
|
+
* ```
|
|
236
|
+
*/
|
|
237
|
+
PdfForm.prototype.add = function (field) {
|
|
238
|
+
this._fields.push(field._ref);
|
|
239
|
+
this._dictionary.update('Fields', this._fields);
|
|
240
|
+
this._parsedFields.set(this._fields.length - 1, field);
|
|
241
|
+
field._form = this;
|
|
242
|
+
this._crossReference._allowCatalog = true;
|
|
243
|
+
this._crossReference._root._updated = true;
|
|
244
|
+
if (field._kidsCount > 0) {
|
|
245
|
+
for (var i = 0; i < field._kidsCount; i++) {
|
|
246
|
+
var item = field.itemAt(i);
|
|
247
|
+
var page = item._page;
|
|
248
|
+
page.annotations._annotations.push(item._ref);
|
|
249
|
+
page._pageDictionary.set('Annots', page.annotations._annotations);
|
|
250
|
+
page._pageDictionary._updated = true;
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
else if (field._dictionary.has('Subtype') && field._dictionary.get('Subtype').name === 'Widget') {
|
|
254
|
+
var page = field._page;
|
|
255
|
+
page.annotations._annotations.push(field._ref);
|
|
256
|
+
field._page._pageDictionary.set('Annots', field.page.annotations._annotations);
|
|
257
|
+
field._page._pageDictionary._updated = true;
|
|
258
|
+
}
|
|
259
|
+
if (field instanceof PdfSignatureField) {
|
|
260
|
+
field._form._signatureFlag = _SignatureFlag.signatureExists | _SignatureFlag.appendOnly;
|
|
261
|
+
}
|
|
262
|
+
return (this._fields.length - 1);
|
|
263
|
+
};
|
|
264
|
+
/**
|
|
265
|
+
* Remove the specified PDF form field.
|
|
266
|
+
*
|
|
267
|
+
* @param {PdfField} field Field object to remove.
|
|
268
|
+
* @returns {void} Nothing.
|
|
269
|
+
*
|
|
270
|
+
* ```typescript
|
|
271
|
+
* // Load an existing PDF document
|
|
272
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
273
|
+
* // Access the loaded form field
|
|
274
|
+
* let field: PdfField = document.form.fieldAt(3);
|
|
275
|
+
* // Remove the form field
|
|
276
|
+
* document.form.removeField(field);
|
|
277
|
+
* // Save the document
|
|
278
|
+
* document.save('output.pdf');
|
|
279
|
+
* // Destroy the document
|
|
280
|
+
* document.destroy();
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
PdfForm.prototype.removeField = function (field) {
|
|
284
|
+
var index = this._fields.indexOf(field._ref);
|
|
285
|
+
if (index >= 0) {
|
|
286
|
+
this.removeFieldAt(index);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Remove the PDF form field from specified index.
|
|
291
|
+
*
|
|
292
|
+
* @param {number} index Field index to remove.
|
|
293
|
+
* @returns {void} Nothing.
|
|
294
|
+
*
|
|
295
|
+
* ```typescript
|
|
296
|
+
* // Load an existing PDF document
|
|
297
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
298
|
+
* // Remove the form field from the specified index
|
|
299
|
+
* document.form.removeFieldAt(3);
|
|
300
|
+
* // Save the document
|
|
301
|
+
* document.save('output.pdf');
|
|
302
|
+
* // Destroy the document
|
|
303
|
+
* document.destroy();
|
|
304
|
+
* ```
|
|
305
|
+
*/
|
|
306
|
+
PdfForm.prototype.removeFieldAt = function (index) {
|
|
307
|
+
var field = this.fieldAt(index);
|
|
308
|
+
if (field) {
|
|
309
|
+
if (field._kidsCount > 0) {
|
|
310
|
+
for (var i = field._kidsCount - 1; i >= 0; i--) {
|
|
311
|
+
var item = field.itemAt(i);
|
|
312
|
+
var page = item._getPage();
|
|
313
|
+
if (page) {
|
|
314
|
+
page._removeAnnotation(item._ref);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
else if (field._dictionary.has('Subtype') && field._dictionary.get('Subtype').name === 'Widget') {
|
|
319
|
+
var page = field.page;
|
|
320
|
+
if (page) {
|
|
321
|
+
page._removeAnnotation(field._ref);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
this._parsedFields.delete(index);
|
|
325
|
+
}
|
|
326
|
+
this._fields.splice(index, 1);
|
|
327
|
+
this._dictionary.set('Fields', this._fields);
|
|
328
|
+
this._dictionary._updated = true;
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Sets the flag to indicate the new appearance creation
|
|
332
|
+
* If true, appearance will not be created. Default appearance has been considered.
|
|
333
|
+
* If false, new appearance stream has been created from field values and updated as normal appearance.
|
|
334
|
+
*
|
|
335
|
+
* @param {boolean} value Set default appearance.
|
|
336
|
+
* @returns {void} Nothing.
|
|
337
|
+
*
|
|
338
|
+
* ```typescript
|
|
339
|
+
* // Load an existing PDF document
|
|
340
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
341
|
+
* // Set boolean flag to create a new appearance stream for form fields.
|
|
342
|
+
* document.form.setDefaultAppearance(false);
|
|
343
|
+
* // Save the document
|
|
344
|
+
* document.save('output.pdf');
|
|
345
|
+
* // Destroy the document
|
|
346
|
+
* document.destroy();
|
|
347
|
+
* ```
|
|
348
|
+
*/
|
|
349
|
+
PdfForm.prototype.setDefaultAppearance = function (value) {
|
|
350
|
+
this._setAppearance = !value;
|
|
351
|
+
this._needAppearances = value;
|
|
352
|
+
this._dictionary.update('NeedAppearances', value);
|
|
353
|
+
};
|
|
354
|
+
PdfForm.prototype.orderFormFields = function (tabOrder) {
|
|
355
|
+
var _this = this;
|
|
356
|
+
if (tabOrder === null || typeof tabOrder === 'undefined') {
|
|
357
|
+
this.orderFormFields(new Map());
|
|
358
|
+
}
|
|
359
|
+
else {
|
|
360
|
+
var tab = void 0;
|
|
361
|
+
var document_1 = this._crossReference._document;
|
|
362
|
+
var value = void 0;
|
|
363
|
+
if (tabOrder && tabOrder instanceof Map) {
|
|
364
|
+
var setTabOrder = true;
|
|
365
|
+
if (tabOrder.size > 0) {
|
|
366
|
+
this._tabCollection = tabOrder;
|
|
367
|
+
}
|
|
368
|
+
else {
|
|
369
|
+
setTabOrder = false;
|
|
370
|
+
this._tabCollection = tabOrder;
|
|
371
|
+
}
|
|
372
|
+
var fieldCollection = new Map();
|
|
373
|
+
this._fieldCollection = this._getFields();
|
|
374
|
+
if (this._fieldCollection && this._fieldCollection.length > 0) {
|
|
375
|
+
var page = this._fieldCollection[0].page;
|
|
376
|
+
if (page && document_1) {
|
|
377
|
+
for (var i = 0; i < this._fieldCollection.length; i++) {
|
|
378
|
+
var field = this._fieldCollection[Number.parseInt(i.toString(), 10)];
|
|
379
|
+
var index = _getPageIndex(document_1, field.page._pageDictionary);
|
|
380
|
+
if (fieldCollection.has(index)) {
|
|
381
|
+
value = fieldCollection.get(index);
|
|
382
|
+
value.push(field);
|
|
383
|
+
}
|
|
384
|
+
else {
|
|
385
|
+
value = [];
|
|
386
|
+
value.push(field);
|
|
387
|
+
fieldCollection.set(index, value);
|
|
388
|
+
}
|
|
389
|
+
var page_1 = document_1.getPage(index);
|
|
390
|
+
if (!this._tabCollection.has(index)) {
|
|
391
|
+
this._tabCollection.set(index, page_1.tabOrder);
|
|
392
|
+
}
|
|
393
|
+
if (setTabOrder) {
|
|
394
|
+
page_1.tabOrder = this._tabCollection.get(index);
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
var fieldsCount_1 = 0;
|
|
398
|
+
fieldCollection.forEach(function (value, key) {
|
|
399
|
+
_this._tabOrder = _this._tabCollection.get(key);
|
|
400
|
+
var fields = value;
|
|
401
|
+
fields.sort(function (pdfField1, pdfField2) {
|
|
402
|
+
return _this._compareFields(pdfField1, pdfField2);
|
|
403
|
+
});
|
|
404
|
+
for (var j = 0; j < fields.length; j++) {
|
|
405
|
+
var fieldIndex = _this._fieldCollection.indexOf(fields[Number.parseInt(j.toString(), 10)]);
|
|
406
|
+
if (fieldIndex !== -1 && fieldIndex !== fieldsCount_1 + j) {
|
|
407
|
+
var field = _this._fieldCollection[Number.parseInt(fieldIndex.toString(), 10)];
|
|
408
|
+
_this._fieldCollection.splice(fieldIndex, 1);
|
|
409
|
+
_this._fieldCollection.splice(fieldsCount_1 + j, 0, field);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
fieldsCount_1 += value.length;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
else {
|
|
418
|
+
this._tabOrder = tabOrder;
|
|
419
|
+
tab = this._getOrder(this._tabOrder);
|
|
420
|
+
this._fieldCollection = this._getFields();
|
|
421
|
+
this._fieldCollection.sort(function (pdfField1, pdfField2) {
|
|
422
|
+
return _this._compareFields(pdfField1, pdfField2);
|
|
423
|
+
});
|
|
424
|
+
}
|
|
425
|
+
this._parsedFields.clear();
|
|
426
|
+
for (var i = 0; i < this._fieldCollection.length; i++) {
|
|
427
|
+
this._parsedFields.set(Number.parseInt(i.toString(), 10), this._fieldCollection[Number.parseInt(i.toString(), 10)]);
|
|
428
|
+
this._fields[Number.parseInt(i.toString(), 10)] = this._fieldCollection[Number.parseInt(i.toString(), 10)]._ref;
|
|
429
|
+
if (tab) {
|
|
430
|
+
this._fieldCollection[Number.parseInt(i.toString(), 10)].page._pageDictionary.update('Tabs', tab);
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
this._dictionary.update('Fields', this._fields);
|
|
434
|
+
}
|
|
435
|
+
};
|
|
436
|
+
PdfForm.prototype._createFields = function () {
|
|
437
|
+
var fields; // eslint-disable-line
|
|
438
|
+
if (this._dictionary.has('Fields')) {
|
|
439
|
+
fields = this._dictionary.get('Fields');
|
|
440
|
+
}
|
|
441
|
+
var count = 0;
|
|
442
|
+
var nodes = []; // eslint-disable-line
|
|
443
|
+
while (typeof fields !== 'undefined' && fields !== null) {
|
|
444
|
+
for (; count < fields.length; count++) {
|
|
445
|
+
var ref = fields[count]; // eslint-disable-line
|
|
446
|
+
var fieldDictionary = void 0;
|
|
447
|
+
if (ref && ref instanceof _PdfReference) {
|
|
448
|
+
fieldDictionary = this._crossReference._fetch(ref);
|
|
449
|
+
}
|
|
450
|
+
var fieldKids = void 0;
|
|
451
|
+
if (fieldDictionary && fieldDictionary.has('Kids')) {
|
|
452
|
+
fieldKids = fieldDictionary.get('Kids');
|
|
453
|
+
if (typeof fieldKids !== 'undefined' && fieldKids.length > 0) {
|
|
454
|
+
for (var i = 0; i < fieldKids.length; i++) {
|
|
455
|
+
var reference = fieldKids[Number.parseInt(i.toString(), 10)];
|
|
456
|
+
if (reference && reference instanceof _PdfReference) {
|
|
457
|
+
var kidsDict = this._crossReference._fetch(reference);
|
|
458
|
+
if (typeof kidsDict !== 'undefined' && !kidsDict.has('Parent')) {
|
|
459
|
+
kidsDict.update('Parent', ref);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
if (typeof fieldKids === 'undefined') {
|
|
466
|
+
if (typeof fieldDictionary !== 'undefined') {
|
|
467
|
+
if (this._fields.indexOf(ref) === -1) {
|
|
468
|
+
this._fields.push(ref);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
else {
|
|
473
|
+
var isNode = (!fieldDictionary.has('FT')) || this._isNode(fieldKids);
|
|
474
|
+
if (isNode) {
|
|
475
|
+
nodes.push({ fields: fields, count: count });
|
|
476
|
+
this._hasKids = true;
|
|
477
|
+
count = -1;
|
|
478
|
+
fields = fieldKids;
|
|
479
|
+
}
|
|
480
|
+
else {
|
|
481
|
+
this._fields.push(ref);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
if (nodes.length === 0) {
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
var entry = nodes.pop(); // eslint-disable-line
|
|
489
|
+
fields = entry.fields;
|
|
490
|
+
count = entry.count + 1;
|
|
491
|
+
}
|
|
492
|
+
};
|
|
493
|
+
PdfForm.prototype._isNode = function (kids) {
|
|
494
|
+
var isNode = false;
|
|
495
|
+
if (typeof kids !== 'undefined' && kids.length > 0) {
|
|
496
|
+
var entry = kids[0]; // eslint-disable-line
|
|
497
|
+
var dictionary = void 0;
|
|
498
|
+
if (typeof entry !== 'undefined' && entry !== null) {
|
|
499
|
+
if (entry instanceof _PdfDictionary) {
|
|
500
|
+
dictionary = entry;
|
|
501
|
+
}
|
|
502
|
+
else if (entry instanceof _PdfReference) {
|
|
503
|
+
dictionary = this._crossReference._fetch(entry);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
if (typeof dictionary !== 'undefined' && dictionary.has('Subtype')) {
|
|
507
|
+
var subtype = dictionary.get('Subtype');
|
|
508
|
+
if (subtype && subtype.name !== 'Widget') {
|
|
509
|
+
isNode = true;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
return isNode;
|
|
514
|
+
};
|
|
515
|
+
PdfForm.prototype._parseWidgetReferences = function () {
|
|
516
|
+
var _this = this;
|
|
517
|
+
if (typeof this._widgetReferences === 'undefined' && this.count > 0) {
|
|
518
|
+
this._widgetReferences = [];
|
|
519
|
+
this._fields.forEach(function (fieldReference) {
|
|
520
|
+
var dictionary = _this._crossReference._fetch(fieldReference);
|
|
521
|
+
if (dictionary) {
|
|
522
|
+
if (dictionary.has('Kids')) {
|
|
523
|
+
var fieldKids = dictionary.get('Kids');
|
|
524
|
+
if (fieldKids && fieldKids.length > 0) {
|
|
525
|
+
fieldKids.forEach(function (kidReference) {
|
|
526
|
+
var kidDictionary;
|
|
527
|
+
if (kidReference instanceof _PdfDictionary) {
|
|
528
|
+
kidDictionary = kidReference;
|
|
529
|
+
}
|
|
530
|
+
else if (kidReference instanceof _PdfReference) {
|
|
531
|
+
kidDictionary = _this._crossReference._fetch(kidReference);
|
|
532
|
+
}
|
|
533
|
+
if (typeof kidDictionary !== 'undefined' && kidDictionary.has('Subtype')) {
|
|
534
|
+
var subtype = kidDictionary.get('Subtype');
|
|
535
|
+
if (subtype && subtype.name === 'Widget') {
|
|
536
|
+
_this._widgetReferences.push(kidReference);
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
});
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
else {
|
|
543
|
+
_this._widgetReferences.push(fieldReference);
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
return this._widgetReferences;
|
|
549
|
+
};
|
|
550
|
+
PdfForm.prototype._doPostProcess = function (isFlatten) {
|
|
551
|
+
for (var i = this.count - 1; i >= 0; i--) {
|
|
552
|
+
var field = this.fieldAt(i);
|
|
553
|
+
if (field) {
|
|
554
|
+
field._doPostProcess(isFlatten || field.flatten);
|
|
555
|
+
if (!isFlatten && field.flatten) {
|
|
556
|
+
this.removeFieldAt(i);
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
};
|
|
561
|
+
PdfForm.prototype._getFieldIndex = function (name) {
|
|
562
|
+
var index = -1;
|
|
563
|
+
if (this.count > 0) {
|
|
564
|
+
if (!this._fieldNames) {
|
|
565
|
+
this._fieldNames = [];
|
|
566
|
+
}
|
|
567
|
+
if (!this._indexedFieldNames) {
|
|
568
|
+
this._indexedFieldNames = [];
|
|
569
|
+
}
|
|
570
|
+
if (!this._actualFieldNames) {
|
|
571
|
+
this._actualFieldNames = [];
|
|
572
|
+
}
|
|
573
|
+
if (!this._indexedActualFieldNames) {
|
|
574
|
+
this._indexedActualFieldNames = [];
|
|
575
|
+
}
|
|
576
|
+
for (var i = 0; i < this.count; i++) {
|
|
577
|
+
var field = this.fieldAt(i);
|
|
578
|
+
if (field) {
|
|
579
|
+
var fieldName = field.name;
|
|
580
|
+
if (fieldName) {
|
|
581
|
+
this._fieldNames.push(fieldName);
|
|
582
|
+
this._indexedFieldNames.push(fieldName.split('[')[0]);
|
|
583
|
+
}
|
|
584
|
+
var actualName = field.actualName;
|
|
585
|
+
if (actualName) {
|
|
586
|
+
this._actualFieldNames.push(actualName);
|
|
587
|
+
this._indexedActualFieldNames.push(actualName.split('[')[0]);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
var nameIndex = this._fieldNames.indexOf(name);
|
|
592
|
+
if (nameIndex !== -1) {
|
|
593
|
+
index = nameIndex;
|
|
594
|
+
}
|
|
595
|
+
else {
|
|
596
|
+
nameIndex = this._indexedFieldNames.indexOf(name);
|
|
597
|
+
if (nameIndex !== -1) {
|
|
598
|
+
index = nameIndex;
|
|
599
|
+
}
|
|
600
|
+
else {
|
|
601
|
+
nameIndex = this._actualFieldNames.indexOf(name);
|
|
602
|
+
if (nameIndex !== -1) {
|
|
603
|
+
index = nameIndex;
|
|
604
|
+
}
|
|
605
|
+
else {
|
|
606
|
+
nameIndex = this._indexedActualFieldNames.indexOf(name);
|
|
607
|
+
if (nameIndex !== -1) {
|
|
608
|
+
index = nameIndex;
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
return index;
|
|
615
|
+
};
|
|
616
|
+
PdfForm.prototype._getFields = function () {
|
|
617
|
+
var fields = [];
|
|
618
|
+
for (var i = 0; i < this._fields.length; i++) {
|
|
619
|
+
var field = this.fieldAt(i);
|
|
620
|
+
if (field && field instanceof PdfField) {
|
|
621
|
+
fields.push(field);
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
return fields;
|
|
625
|
+
};
|
|
626
|
+
PdfForm.prototype._getOrder = function (tabOrder) {
|
|
627
|
+
if (tabOrder !== PdfFormFieldsTabOrder.none) {
|
|
628
|
+
var tabs = '';
|
|
629
|
+
if (tabOrder === PdfFormFieldsTabOrder.row) {
|
|
630
|
+
tabs = 'R';
|
|
631
|
+
}
|
|
632
|
+
else if (tabOrder === PdfFormFieldsTabOrder.column) {
|
|
633
|
+
tabs = 'C';
|
|
634
|
+
}
|
|
635
|
+
else if (tabOrder === PdfFormFieldsTabOrder.structure) {
|
|
636
|
+
tabs = 'S';
|
|
637
|
+
}
|
|
638
|
+
return _PdfName.get(tabs);
|
|
639
|
+
}
|
|
640
|
+
return null;
|
|
641
|
+
};
|
|
642
|
+
PdfForm.prototype._compareFields = function (field1, field2) {
|
|
643
|
+
var result = 0;
|
|
644
|
+
var xdiff;
|
|
645
|
+
var index;
|
|
646
|
+
var page1 = field1.page;
|
|
647
|
+
var page2 = field2.page;
|
|
648
|
+
if (page1 && page1 instanceof PdfPage && page2 && page2 instanceof PdfPage) {
|
|
649
|
+
var page1Index = page1._pageIndex;
|
|
650
|
+
var page2Index = page2._pageIndex;
|
|
651
|
+
var rectangle1 = this._getRectangle(field1._dictionary);
|
|
652
|
+
var rectangle2 = this._getRectangle(field2._dictionary);
|
|
653
|
+
if (rectangle1 && rectangle1.length >= 2 && rectangle2 && rectangle2.length >= 2) {
|
|
654
|
+
var x1 = rectangle1[0];
|
|
655
|
+
var y1 = rectangle1[1];
|
|
656
|
+
var x2 = rectangle2[0];
|
|
657
|
+
var y2 = rectangle2[1];
|
|
658
|
+
if (typeof x1 === 'number' && typeof x2 === 'number' &&
|
|
659
|
+
typeof y1 === 'number' && typeof y2 === 'number') {
|
|
660
|
+
index = page1Index - page2Index;
|
|
661
|
+
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
662
|
+
xdiff = this._compare(y2, y1);
|
|
663
|
+
if (index !== 0) {
|
|
664
|
+
result = index;
|
|
665
|
+
}
|
|
666
|
+
else if (xdiff !== 0) {
|
|
667
|
+
result = xdiff;
|
|
668
|
+
}
|
|
669
|
+
else {
|
|
670
|
+
result = this._compare(x1, x2);
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
else if (this._tabOrder === PdfFormFieldsTabOrder.column) {
|
|
674
|
+
xdiff = this._compare(x1, x2);
|
|
675
|
+
if (index !== 0) {
|
|
676
|
+
result = index;
|
|
677
|
+
}
|
|
678
|
+
else if (xdiff !== 0) {
|
|
679
|
+
result = xdiff;
|
|
680
|
+
}
|
|
681
|
+
else {
|
|
682
|
+
result = this._compare(y2, y1);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
else if (this._tabOrder === PdfFormFieldsTabOrder.manual ||
|
|
686
|
+
this._tabOrder === PdfFormFieldsTabOrder.none || this._tabOrder === PdfFormFieldsTabOrder.structure) {
|
|
687
|
+
if (field1 instanceof PdfField && field2 instanceof PdfField) {
|
|
688
|
+
var field1Index = field1.tabIndex;
|
|
689
|
+
var field2Index = field2.tabIndex;
|
|
690
|
+
xdiff = this._compare(field1Index, field2Index);
|
|
691
|
+
if (index !== 0) {
|
|
692
|
+
result = index;
|
|
693
|
+
}
|
|
694
|
+
else {
|
|
695
|
+
result = xdiff;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
}
|
|
702
|
+
return result;
|
|
703
|
+
};
|
|
704
|
+
PdfForm.prototype._getRectangle = function (dictionary) {
|
|
705
|
+
var _this = this;
|
|
706
|
+
if (dictionary.has('Rect')) {
|
|
707
|
+
var rect = dictionary.get('Rect');
|
|
708
|
+
if (rect) {
|
|
709
|
+
return rect;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
else {
|
|
713
|
+
if (dictionary.has('Kids')) {
|
|
714
|
+
var kidsArray = dictionary.get('Kids');
|
|
715
|
+
if (kidsArray) {
|
|
716
|
+
if (kidsArray.length > 1) {
|
|
717
|
+
kidsArray.sort(function (x, y) {
|
|
718
|
+
return _this._compareKidsElement(x, y);
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
var dictionary_1 = this._crossReference._fetch(kidsArray[0]);
|
|
722
|
+
return this._getRectangle(dictionary_1);
|
|
723
|
+
}
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
return null;
|
|
727
|
+
};
|
|
728
|
+
PdfForm.prototype._compare = function (x, y) {
|
|
729
|
+
if (x > y) {
|
|
730
|
+
return 1;
|
|
731
|
+
}
|
|
732
|
+
else if (x < y) {
|
|
733
|
+
return -1;
|
|
734
|
+
}
|
|
735
|
+
else {
|
|
736
|
+
return 0;
|
|
737
|
+
}
|
|
738
|
+
};
|
|
739
|
+
PdfForm.prototype._compareKidsElement = function (x, y) {
|
|
740
|
+
var xDictionary = this._crossReference._fetch(x);
|
|
741
|
+
var yDictionary = this._crossReference._fetch(y);
|
|
742
|
+
var xRect = this._getRectangle(xDictionary);
|
|
743
|
+
var yRect = this._getRectangle(yDictionary);
|
|
744
|
+
if (xRect && xRect.length >= 2 && yRect && yRect.length >= 2) {
|
|
745
|
+
var x1 = xRect[0];
|
|
746
|
+
var y1 = xRect[1];
|
|
747
|
+
var x2 = yRect[0];
|
|
748
|
+
var y2 = yRect[1];
|
|
749
|
+
if (typeof x1 === 'number' && typeof x2 === 'number' &&
|
|
750
|
+
typeof y1 === 'number' && typeof y2 === 'number') {
|
|
751
|
+
var result = 0;
|
|
752
|
+
var xdiff = void 0;
|
|
753
|
+
if (this._tabOrder === PdfFormFieldsTabOrder.row) {
|
|
754
|
+
xdiff = this._compare(y2, y1);
|
|
755
|
+
if (xdiff !== 0) {
|
|
756
|
+
result = xdiff;
|
|
757
|
+
}
|
|
758
|
+
else {
|
|
759
|
+
result = this._compare(x1, x2);
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
else if (this._tabOrder === PdfFormFieldsTabOrder.column) {
|
|
763
|
+
xdiff = this._compare(x1, x2);
|
|
764
|
+
if (xdiff !== 0) {
|
|
765
|
+
result = xdiff;
|
|
766
|
+
}
|
|
767
|
+
else {
|
|
768
|
+
result = this._compare(y2, y1);
|
|
769
|
+
}
|
|
770
|
+
}
|
|
771
|
+
return result;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
return null;
|
|
775
|
+
};
|
|
776
|
+
PdfForm.prototype._clear = function () {
|
|
777
|
+
this._fields = [];
|
|
778
|
+
this._parsedFields = new Map();
|
|
779
|
+
};
|
|
780
|
+
return PdfForm;
|
|
781
|
+
}());
|
|
782
|
+
export { PdfForm };
|