@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,1022 @@
|
|
|
1
|
+
import { _PdfStream } from './base-stream';
|
|
2
|
+
import { _PdfCrossReference } from './pdf-cross-reference';
|
|
3
|
+
import { _Linearization } from './pdf-parser';
|
|
4
|
+
import { _isWhiteSpace, FormatError, _decode } from './utils';
|
|
5
|
+
import { _PdfCatalog } from './pdf-catalog';
|
|
6
|
+
import { _PdfDictionary, _PdfReference, _isName, _clearPrimitiveCaches } from './pdf-primitives';
|
|
7
|
+
import { PdfPage } from './pdf-page';
|
|
8
|
+
import { Save } from '@syncfusion/ej2-file-utils';
|
|
9
|
+
import { DataFormat, PdfPermissionFlag, PdfTextAlignment } from './enumerator';
|
|
10
|
+
import { PdfForm } from './form/form';
|
|
11
|
+
import { PdfBrush } from './graphics/pdf-graphics';
|
|
12
|
+
import { PdfFontFamily, PdfFontStyle, PdfStandardFont } from './fonts/pdf-standard-font';
|
|
13
|
+
import { PdfStringFormat, PdfVerticalAlignment } from './fonts/pdf-string-format';
|
|
14
|
+
import { _XfdfDocument } from './import-export/xfdf-document';
|
|
15
|
+
import { _JsonDocument } from './import-export/json-document';
|
|
16
|
+
import { _FdfDocument } from './import-export/fdf-document';
|
|
17
|
+
import { PdfBookmarkBase, _PdfNamedDestinationCollection } from './pdf-outline';
|
|
18
|
+
import { _XmlDocument } from './import-export/xml-document';
|
|
19
|
+
import { PdfFileStructure } from './pdf-file-structure';
|
|
20
|
+
/**
|
|
21
|
+
* Represents a PDF document and can be used to parse an existing PDF document.
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Load an existing PDF document
|
|
24
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
25
|
+
* // Access first page
|
|
26
|
+
* let page: PdfPage = document.getPage(0);
|
|
27
|
+
* // Flatten annotations and form fields
|
|
28
|
+
* document.flatten = true;
|
|
29
|
+
* // Save the document
|
|
30
|
+
* document.save('output.pdf');
|
|
31
|
+
* // Destroy the document
|
|
32
|
+
* document.destroy();
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
var PdfDocument = /** @class */ (function () {
|
|
36
|
+
function PdfDocument(data, password) {
|
|
37
|
+
this._headerSignature = new Uint8Array([0x25, 0x50, 0x44, 0x46, 0x2d]);
|
|
38
|
+
this._startXrefSignature = new Uint8Array([0x73, 0x74, 0x61, 0x72, 0x74, 0x78, 0x72, 0x65, 0x66]);
|
|
39
|
+
this._endObjSignature = new Uint8Array([0x65, 0x6e, 0x64, 0x6f, 0x62, 0x6a]);
|
|
40
|
+
this._version = '';
|
|
41
|
+
this._permissions = PdfPermissionFlag.default;
|
|
42
|
+
this._isEncrypted = false;
|
|
43
|
+
this._isUserPassword = false;
|
|
44
|
+
this._hasUserPasswordOnly = false;
|
|
45
|
+
this._encryptOnlyAttachment = false;
|
|
46
|
+
this._encryptMetaData = false;
|
|
47
|
+
this._allowCustomData = false;
|
|
48
|
+
if (!data) {
|
|
49
|
+
throw new Error('PDF data cannot be undefined or null');
|
|
50
|
+
}
|
|
51
|
+
this._stream = new _PdfStream(typeof data === 'string' ? _decode(data) : data);
|
|
52
|
+
this._fileStructure = new PdfFileStructure();
|
|
53
|
+
this._crossReference = new _PdfCrossReference(this, password);
|
|
54
|
+
this._pages = new Map();
|
|
55
|
+
this._checkHeader();
|
|
56
|
+
this._crossReference._setStartXRef(this._startXRef);
|
|
57
|
+
try {
|
|
58
|
+
this._parse(false);
|
|
59
|
+
}
|
|
60
|
+
catch (e) {
|
|
61
|
+
if (e.name === 'XRefParseException') {
|
|
62
|
+
this._parse(true);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
throw e;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
this._crossReference._version = this._version;
|
|
69
|
+
}
|
|
70
|
+
Object.defineProperty(PdfDocument.prototype, "_allowImportCustomData", {
|
|
71
|
+
get: function () {
|
|
72
|
+
return this._allowCustomData;
|
|
73
|
+
},
|
|
74
|
+
set: function (value) {
|
|
75
|
+
this._allowCustomData = value;
|
|
76
|
+
},
|
|
77
|
+
enumerable: true,
|
|
78
|
+
configurable: true
|
|
79
|
+
});
|
|
80
|
+
Object.defineProperty(PdfDocument.prototype, "_linearization", {
|
|
81
|
+
get: function () {
|
|
82
|
+
if (!this._linear) {
|
|
83
|
+
var value = void 0;
|
|
84
|
+
try {
|
|
85
|
+
value = new _Linearization(this._stream);
|
|
86
|
+
}
|
|
87
|
+
catch (err) { } // eslint-disable-line
|
|
88
|
+
this._linear = value;
|
|
89
|
+
}
|
|
90
|
+
return this._linear;
|
|
91
|
+
},
|
|
92
|
+
enumerable: true,
|
|
93
|
+
configurable: true
|
|
94
|
+
});
|
|
95
|
+
Object.defineProperty(PdfDocument.prototype, "_startXRef", {
|
|
96
|
+
get: function () {
|
|
97
|
+
var stream = this._stream;
|
|
98
|
+
var startXRef = 0;
|
|
99
|
+
if (this._linearization && this._linearization.isValid) {
|
|
100
|
+
stream.reset();
|
|
101
|
+
if (this._find(stream, this._endObjSignature)) {
|
|
102
|
+
startXRef = stream.position + 6 - stream.start;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
else {
|
|
106
|
+
var step = 1024;
|
|
107
|
+
var startXRefLength = this._startXrefSignature.length;
|
|
108
|
+
var found = false;
|
|
109
|
+
var position = stream.end;
|
|
110
|
+
while (!found && position > 0) {
|
|
111
|
+
position -= step - startXRefLength;
|
|
112
|
+
if (position < 0) {
|
|
113
|
+
position = 0;
|
|
114
|
+
}
|
|
115
|
+
stream.position = position;
|
|
116
|
+
found = this._find(stream, this._startXrefSignature, step, true);
|
|
117
|
+
}
|
|
118
|
+
if (found) {
|
|
119
|
+
stream.skip(9);
|
|
120
|
+
var ch = void 0;
|
|
121
|
+
do {
|
|
122
|
+
ch = stream.getByte();
|
|
123
|
+
} while (_isWhiteSpace(ch));
|
|
124
|
+
var str = '';
|
|
125
|
+
while (ch >= 0x20 && ch <= 0x39) {
|
|
126
|
+
str += String.fromCharCode(ch);
|
|
127
|
+
ch = stream.getByte();
|
|
128
|
+
}
|
|
129
|
+
startXRef = parseInt(str, 10);
|
|
130
|
+
if (isNaN(startXRef)) {
|
|
131
|
+
startXRef = 0;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
return startXRef;
|
|
136
|
+
},
|
|
137
|
+
enumerable: true,
|
|
138
|
+
configurable: true
|
|
139
|
+
});
|
|
140
|
+
Object.defineProperty(PdfDocument.prototype, "isEncrypted", {
|
|
141
|
+
/**
|
|
142
|
+
* Gets a value indicating whether the document is encrypted. (Read Only).
|
|
143
|
+
*
|
|
144
|
+
* @returns {boolean} A boolean value indicates whether the document is encrypted.
|
|
145
|
+
*
|
|
146
|
+
* ```typescript
|
|
147
|
+
* // Load an existing PDF document
|
|
148
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
149
|
+
* // Gets a value indicating whether the document is encrypted.
|
|
150
|
+
* let isEncrypted: boolean = document.isEncrypted;
|
|
151
|
+
* // Destroy the document
|
|
152
|
+
* document.destroy();
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
155
|
+
get: function () {
|
|
156
|
+
return this._isEncrypted;
|
|
157
|
+
},
|
|
158
|
+
enumerable: true,
|
|
159
|
+
configurable: true
|
|
160
|
+
});
|
|
161
|
+
Object.defineProperty(PdfDocument.prototype, "isUserPassword", {
|
|
162
|
+
/**
|
|
163
|
+
* Gets a value indicating whether the document is decrypted using the user password. (Read only).
|
|
164
|
+
*
|
|
165
|
+
* @returns {boolean} A boolean value indicates whether the document is decrypted using the user password.
|
|
166
|
+
*
|
|
167
|
+
* ```typescript
|
|
168
|
+
* // Load an existing PDF document
|
|
169
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
170
|
+
* // Gets a value indicating whether the document is decrypted using the user password
|
|
171
|
+
* let isUserPassword: boolean = document.isUserPassword;
|
|
172
|
+
* // Destroy the document
|
|
173
|
+
* document.destroy();
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
get: function () {
|
|
177
|
+
return this._isUserPassword;
|
|
178
|
+
},
|
|
179
|
+
enumerable: true,
|
|
180
|
+
configurable: true
|
|
181
|
+
});
|
|
182
|
+
Object.defineProperty(PdfDocument.prototype, "pageCount", {
|
|
183
|
+
/**
|
|
184
|
+
* Gets the page count (Read only).
|
|
185
|
+
*
|
|
186
|
+
* @returns {number} Number of pages
|
|
187
|
+
*
|
|
188
|
+
* ```typescript
|
|
189
|
+
* // Load an existing PDF document
|
|
190
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
191
|
+
* // Gets the page count
|
|
192
|
+
* let count: number = document.pageCount;
|
|
193
|
+
* // Destroy the document
|
|
194
|
+
* document.destroy();
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
197
|
+
get: function () {
|
|
198
|
+
if (typeof this._pageCount === 'undefined') {
|
|
199
|
+
this._pageCount = 0;
|
|
200
|
+
if (this._linearization && this._linearization.isValid) {
|
|
201
|
+
this._pageCount = this._linearization.pageCount;
|
|
202
|
+
}
|
|
203
|
+
else {
|
|
204
|
+
this._pageCount = this._catalog.pageCount;
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
return this._pageCount;
|
|
208
|
+
},
|
|
209
|
+
enumerable: true,
|
|
210
|
+
configurable: true
|
|
211
|
+
});
|
|
212
|
+
Object.defineProperty(PdfDocument.prototype, "form", {
|
|
213
|
+
/**
|
|
214
|
+
* Gets the PDF form fields included in the document (Read only).
|
|
215
|
+
*
|
|
216
|
+
* @returns {PdfForm} Form object
|
|
217
|
+
*
|
|
218
|
+
* ```typescript
|
|
219
|
+
* // Load an existing PDF document
|
|
220
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
221
|
+
* // Access loaded form
|
|
222
|
+
* let form: PdfForm = document.form;
|
|
223
|
+
* // Destroy the document
|
|
224
|
+
* document.destroy();
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
get: function () {
|
|
228
|
+
if (typeof this._form === 'undefined') {
|
|
229
|
+
this._form = new PdfForm(this._catalog.acroForm, this._crossReference);
|
|
230
|
+
}
|
|
231
|
+
return this._form;
|
|
232
|
+
},
|
|
233
|
+
enumerable: true,
|
|
234
|
+
configurable: true
|
|
235
|
+
});
|
|
236
|
+
Object.defineProperty(PdfDocument.prototype, "flatten", {
|
|
237
|
+
/**
|
|
238
|
+
* Gets the boolean flag to flatten the annotations and form fields.
|
|
239
|
+
*
|
|
240
|
+
* @returns {boolean} Flag to flatten
|
|
241
|
+
*
|
|
242
|
+
* ```typescript
|
|
243
|
+
* // Load an existing PDF document
|
|
244
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
245
|
+
* // Gets the flatten value applied
|
|
246
|
+
* let flatten: boolean = document.flatten;
|
|
247
|
+
* // Destroy the document
|
|
248
|
+
* document.destroy();
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
get: function () {
|
|
252
|
+
return this._flatten;
|
|
253
|
+
},
|
|
254
|
+
/**
|
|
255
|
+
* Sets the boolean flag to flatten the annotations and form fields.
|
|
256
|
+
*
|
|
257
|
+
* @param {boolean} value to flatten
|
|
258
|
+
*
|
|
259
|
+
* ```typescript
|
|
260
|
+
* // Load an existing PDF document
|
|
261
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
262
|
+
* // Flatten PDF annotations and form fields
|
|
263
|
+
* document.flatten = true;
|
|
264
|
+
* // Destroy the document
|
|
265
|
+
* document.destroy();
|
|
266
|
+
* ```
|
|
267
|
+
*/
|
|
268
|
+
set: function (value) {
|
|
269
|
+
this._flatten = value;
|
|
270
|
+
},
|
|
271
|
+
enumerable: true,
|
|
272
|
+
configurable: true
|
|
273
|
+
});
|
|
274
|
+
Object.defineProperty(PdfDocument.prototype, "permissions", {
|
|
275
|
+
/**
|
|
276
|
+
* Gets the permission flag of the PDF document (Read only).
|
|
277
|
+
*
|
|
278
|
+
* @returns {PdfPermissionFlag} permission flag. Default value is PdfPermissionFlag.default.
|
|
279
|
+
*
|
|
280
|
+
* ```typescript
|
|
281
|
+
* // Load an existing PDF document
|
|
282
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
283
|
+
* // Gets the permission flag
|
|
284
|
+
* let permission: PdfPermissionFlag = document.permissions;
|
|
285
|
+
* // Destroy the document
|
|
286
|
+
* document.destroy();
|
|
287
|
+
* ```
|
|
288
|
+
*/
|
|
289
|
+
get: function () {
|
|
290
|
+
if (this._crossReference) {
|
|
291
|
+
var flag = this._crossReference._permissionFlags;
|
|
292
|
+
if (typeof flag !== 'undefined') {
|
|
293
|
+
this._permissions = (flag & ~-3904);
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
return this._permissions;
|
|
297
|
+
},
|
|
298
|
+
enumerable: true,
|
|
299
|
+
configurable: true
|
|
300
|
+
});
|
|
301
|
+
Object.defineProperty(PdfDocument.prototype, "bookmarks", {
|
|
302
|
+
/**
|
|
303
|
+
* Gets the bookmarks (Read only).
|
|
304
|
+
*
|
|
305
|
+
* @returns {PdfBookmarkBase} Bookmarks.
|
|
306
|
+
*
|
|
307
|
+
* ```typescript
|
|
308
|
+
* // Load an existing PDF document
|
|
309
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
310
|
+
* // Get bookmarks
|
|
311
|
+
* let bookmarks: PdfBookmarkBase = document.bookmarks;
|
|
312
|
+
* // Destroy the document
|
|
313
|
+
* document.destroy();
|
|
314
|
+
* ```
|
|
315
|
+
*/
|
|
316
|
+
get: function () {
|
|
317
|
+
var catalog = this._catalog;
|
|
318
|
+
if (catalog && catalog._catalogDictionary.has('Outlines')) {
|
|
319
|
+
var outlines = catalog._catalogDictionary.get('Outlines');
|
|
320
|
+
if (outlines) {
|
|
321
|
+
this._bookmarkBase = new PdfBookmarkBase(outlines, this._crossReference);
|
|
322
|
+
if (outlines.has('First')) {
|
|
323
|
+
this._bookmarkBase._reproduceTree();
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
return this._bookmarkBase;
|
|
328
|
+
},
|
|
329
|
+
enumerable: true,
|
|
330
|
+
configurable: true
|
|
331
|
+
});
|
|
332
|
+
Object.defineProperty(PdfDocument.prototype, "fileStructure", {
|
|
333
|
+
/**
|
|
334
|
+
* Gets the internal structure of the PDF document.
|
|
335
|
+
*
|
|
336
|
+
* @returns {PdfFileStructure} The internal structure of the PDF document.
|
|
337
|
+
* ```typescript
|
|
338
|
+
* // Load an existing PDF document
|
|
339
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
340
|
+
* // Access the internal file structure of the PDF document
|
|
341
|
+
* let fileStructure: PdfFileStructure = document.fileStructure;
|
|
342
|
+
* // Get the cross reference type
|
|
343
|
+
* let type: PdfCrossReferenceType = fileStructure.crossReferenceType;
|
|
344
|
+
* // Save the document
|
|
345
|
+
* document.save('output.pdf');
|
|
346
|
+
* // Destroy the document
|
|
347
|
+
* document.destroy();
|
|
348
|
+
* ```
|
|
349
|
+
*/
|
|
350
|
+
get: function () {
|
|
351
|
+
return this._fileStructure;
|
|
352
|
+
},
|
|
353
|
+
enumerable: true,
|
|
354
|
+
configurable: true
|
|
355
|
+
});
|
|
356
|
+
/**
|
|
357
|
+
* Gets the `PdfPage` at the specified index.
|
|
358
|
+
*
|
|
359
|
+
* @param {number} pageIndex Page index.
|
|
360
|
+
* @returns {PdfPage} PDF page at the specified index.
|
|
361
|
+
*
|
|
362
|
+
* ```typescript
|
|
363
|
+
* // Load an existing PDF document
|
|
364
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
365
|
+
* // Access first page
|
|
366
|
+
* let page: PdfPage = document.getPage(0);
|
|
367
|
+
* // Save the document
|
|
368
|
+
* document.save('output.pdf');
|
|
369
|
+
* // Destroy the document
|
|
370
|
+
* document.destroy();
|
|
371
|
+
* ```
|
|
372
|
+
*/
|
|
373
|
+
PdfDocument.prototype.getPage = function (pageIndex) {
|
|
374
|
+
var cachedPage = this._pages.get(pageIndex);
|
|
375
|
+
if (cachedPage) {
|
|
376
|
+
return cachedPage;
|
|
377
|
+
}
|
|
378
|
+
var _a = this, _catalog = _a._catalog, _linearization = _a._linearization;
|
|
379
|
+
var promise;
|
|
380
|
+
if (_linearization && _linearization.isValid && _linearization.pageFirst === pageIndex) {
|
|
381
|
+
promise = this._getLinearizationPage(pageIndex);
|
|
382
|
+
}
|
|
383
|
+
else {
|
|
384
|
+
promise = _catalog.getPageDictionary(pageIndex);
|
|
385
|
+
}
|
|
386
|
+
var page = new PdfPage(this._crossReference, pageIndex, promise.dictionary, promise.reference);
|
|
387
|
+
this._pages.set(pageIndex, page);
|
|
388
|
+
return page;
|
|
389
|
+
};
|
|
390
|
+
PdfDocument.prototype.save = function (filename) {
|
|
391
|
+
this._doPostProcess(this._flatten);
|
|
392
|
+
if (typeof filename === 'string') {
|
|
393
|
+
Save.save(filename, new Blob([this._crossReference._save()], { type: 'application/pdf' }));
|
|
394
|
+
}
|
|
395
|
+
else {
|
|
396
|
+
return this._crossReference._save();
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
/**
|
|
400
|
+
* Saves the document to the specified output stream and return the stream as Blob.
|
|
401
|
+
*
|
|
402
|
+
* @returns {Promise<{ blobData: Blob }>} Saved PDF data as `Blob`.
|
|
403
|
+
*
|
|
404
|
+
* ```typescript
|
|
405
|
+
* // Load an existing PDF document
|
|
406
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
407
|
+
* // Save the document
|
|
408
|
+
* let data: Promise<{ blobData: Blob }> = document.saveAsBlob();
|
|
409
|
+
* // Destroy the document
|
|
410
|
+
* document.destroy();
|
|
411
|
+
* ```
|
|
412
|
+
*/
|
|
413
|
+
PdfDocument.prototype.saveAsBlob = function () {
|
|
414
|
+
var _this = this;
|
|
415
|
+
return new Promise(function (resolve) {
|
|
416
|
+
var obj = { blobData: new Blob([_this._crossReference._save()], { type: 'application/pdf' }) };
|
|
417
|
+
resolve(obj);
|
|
418
|
+
});
|
|
419
|
+
};
|
|
420
|
+
PdfDocument.prototype.exportAnnotations = function (arg1, arg2) {
|
|
421
|
+
this._doPostProcessOnAnnotations();
|
|
422
|
+
var helper;
|
|
423
|
+
var settings;
|
|
424
|
+
if (arg1 && arg1 instanceof PdfAnnotationExportSettings) {
|
|
425
|
+
settings = arg1;
|
|
426
|
+
}
|
|
427
|
+
else if (arg2 && arg2 instanceof PdfAnnotationExportSettings) {
|
|
428
|
+
settings = arg2;
|
|
429
|
+
}
|
|
430
|
+
if (settings) {
|
|
431
|
+
if (settings.dataFormat === DataFormat.xfdf) {
|
|
432
|
+
helper = new _XfdfDocument();
|
|
433
|
+
}
|
|
434
|
+
else if (settings.dataFormat === DataFormat.json) {
|
|
435
|
+
helper = new _JsonDocument();
|
|
436
|
+
}
|
|
437
|
+
else if (settings.dataFormat === DataFormat.fdf) {
|
|
438
|
+
helper = new _FdfDocument();
|
|
439
|
+
}
|
|
440
|
+
else {
|
|
441
|
+
return undefined;
|
|
442
|
+
}
|
|
443
|
+
helper.exportAppearance = settings.exportAppearance;
|
|
444
|
+
}
|
|
445
|
+
else {
|
|
446
|
+
helper = new _XfdfDocument();
|
|
447
|
+
}
|
|
448
|
+
var result = helper._exportAnnotations(this);
|
|
449
|
+
if (arg1 && typeof arg1 === 'string') {
|
|
450
|
+
Save.save(arg1, new Blob([result], { type: 'text/plain' }));
|
|
451
|
+
}
|
|
452
|
+
else {
|
|
453
|
+
return result;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
PdfDocument.prototype.exportFormData = function (arg1, arg2) {
|
|
457
|
+
this._doPostProcessOnFormFields();
|
|
458
|
+
var helper;
|
|
459
|
+
var settings;
|
|
460
|
+
if (arg1 && arg1 instanceof PdfFormFieldExportSettings) {
|
|
461
|
+
settings = arg1;
|
|
462
|
+
}
|
|
463
|
+
else if (arg2 && arg2 instanceof PdfFormFieldExportSettings) {
|
|
464
|
+
settings = arg2;
|
|
465
|
+
}
|
|
466
|
+
if (settings) {
|
|
467
|
+
if (settings.dataFormat === DataFormat.xfdf) {
|
|
468
|
+
helper = new _XfdfDocument(settings.exportName);
|
|
469
|
+
}
|
|
470
|
+
else if (settings.dataFormat === DataFormat.json) {
|
|
471
|
+
helper = new _JsonDocument(settings.exportName);
|
|
472
|
+
}
|
|
473
|
+
else if (settings.dataFormat === DataFormat.fdf) {
|
|
474
|
+
helper = new _FdfDocument(settings.exportName);
|
|
475
|
+
}
|
|
476
|
+
else if (settings.dataFormat === DataFormat.xml) {
|
|
477
|
+
helper = new _XmlDocument(settings.exportName);
|
|
478
|
+
}
|
|
479
|
+
else {
|
|
480
|
+
return undefined;
|
|
481
|
+
}
|
|
482
|
+
helper._asPerSpecification = settings.asPerSpecification;
|
|
483
|
+
}
|
|
484
|
+
else {
|
|
485
|
+
helper = new _XfdfDocument();
|
|
486
|
+
helper._asPerSpecification = false;
|
|
487
|
+
}
|
|
488
|
+
if (arg1 && typeof arg1 === 'string') {
|
|
489
|
+
Save.save(arg1, new Blob([helper._exportFormFields(this)], { type: 'text/plain' }));
|
|
490
|
+
}
|
|
491
|
+
else {
|
|
492
|
+
return helper._exportFormFields(this);
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
PdfDocument.prototype.importAnnotations = function (data, dataFormat) {
|
|
496
|
+
if (dataFormat === DataFormat.xfdf) {
|
|
497
|
+
var xfdf = new _XfdfDocument();
|
|
498
|
+
xfdf._importAnnotations(this, (typeof data === 'string') ? _decode(data) : data);
|
|
499
|
+
}
|
|
500
|
+
else if (dataFormat === DataFormat.json) {
|
|
501
|
+
var json = new _JsonDocument();
|
|
502
|
+
json._importAnnotations(this, (typeof data === 'string') ? _decode(data) : data);
|
|
503
|
+
}
|
|
504
|
+
else if (dataFormat === DataFormat.fdf) {
|
|
505
|
+
var fdf = new _FdfDocument();
|
|
506
|
+
fdf._importAnnotations(this, (typeof data === 'string') ? _decode(data) : data);
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
PdfDocument.prototype.importFormData = function (data, dataFormat) {
|
|
510
|
+
if (this.form.count > 0) {
|
|
511
|
+
if (dataFormat === DataFormat.xfdf) {
|
|
512
|
+
var xfdf = new _XfdfDocument();
|
|
513
|
+
xfdf._importFormData(this, (typeof data === 'string') ? _decode(data) : data);
|
|
514
|
+
}
|
|
515
|
+
else if (dataFormat === DataFormat.json) {
|
|
516
|
+
var json = new _JsonDocument();
|
|
517
|
+
json._importFormData(this, (typeof data === 'string') ? _decode(data) : data);
|
|
518
|
+
}
|
|
519
|
+
else if (dataFormat === DataFormat.fdf) {
|
|
520
|
+
var fdf = new _FdfDocument();
|
|
521
|
+
fdf._importFormData(this, (typeof data === 'string') ? _decode(data) : data);
|
|
522
|
+
}
|
|
523
|
+
else if (dataFormat === DataFormat.xml) {
|
|
524
|
+
var xml = new _XmlDocument();
|
|
525
|
+
xml._importFormData(this, (typeof data === 'string') ? _decode(data) : data);
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
};
|
|
529
|
+
/**
|
|
530
|
+
* Disposes the current instance of `PdfDocument` class.
|
|
531
|
+
*
|
|
532
|
+
* @returns {void} Nothing.
|
|
533
|
+
*
|
|
534
|
+
* ```typescript
|
|
535
|
+
* // Load an existing PDF document
|
|
536
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
537
|
+
* // Destroy the document
|
|
538
|
+
* document.destroy();
|
|
539
|
+
* ```
|
|
540
|
+
*/
|
|
541
|
+
PdfDocument.prototype.destroy = function () {
|
|
542
|
+
if (this._crossReference) {
|
|
543
|
+
this._crossReference._destroy();
|
|
544
|
+
this._crossReference = undefined;
|
|
545
|
+
}
|
|
546
|
+
if (this._catalog) {
|
|
547
|
+
this._catalog._destroy();
|
|
548
|
+
this._catalog = undefined;
|
|
549
|
+
}
|
|
550
|
+
this._endObjSignature = undefined;
|
|
551
|
+
this._headerSignature = undefined;
|
|
552
|
+
if (this._pages && this._pages.size > 0) {
|
|
553
|
+
this._pages.forEach(function (value) {
|
|
554
|
+
value._destroy();
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
this._pages.clear();
|
|
558
|
+
this._pages = undefined;
|
|
559
|
+
this._startXrefSignature = undefined;
|
|
560
|
+
this._stream = undefined;
|
|
561
|
+
this._form = undefined;
|
|
562
|
+
_clearPrimitiveCaches();
|
|
563
|
+
};
|
|
564
|
+
Object.defineProperty(PdfDocument.prototype, "_destinationCollection", {
|
|
565
|
+
get: function () {
|
|
566
|
+
if (this._namedDestinationCollection === null || typeof this._namedDestinationCollection === 'undefined') {
|
|
567
|
+
if (this._catalog._catalogDictionary.has('Names')) {
|
|
568
|
+
var names = this._catalog._catalogDictionary.get('Names');
|
|
569
|
+
this._namedDestinationCollection = new _PdfNamedDestinationCollection(names, this._crossReference);
|
|
570
|
+
}
|
|
571
|
+
else {
|
|
572
|
+
this._namedDestinationCollection = new _PdfNamedDestinationCollection();
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return this._namedDestinationCollection;
|
|
576
|
+
},
|
|
577
|
+
enumerable: true,
|
|
578
|
+
configurable: true
|
|
579
|
+
});
|
|
580
|
+
PdfDocument.prototype._getLinearizationPage = function (pageIndex) {
|
|
581
|
+
var _a = this, _catalog = _a._catalog, _linearization = _a._linearization, _crossReference = _a._crossReference;
|
|
582
|
+
var ref = _PdfReference.get(_linearization.objectNumberFirst, 0);
|
|
583
|
+
try {
|
|
584
|
+
var obj = _crossReference._fetch(ref); // eslint-disable-line
|
|
585
|
+
if (obj instanceof _PdfDictionary) {
|
|
586
|
+
var type = obj.get('Type');
|
|
587
|
+
if (_isName(type, 'Page') || (!obj.has('Type') && !obj.has('Kids'))) {
|
|
588
|
+
if (!_catalog.pageKidsCountCache.has(ref)) {
|
|
589
|
+
_catalog.pageKidsCountCache.put(ref, 1);
|
|
590
|
+
}
|
|
591
|
+
if (!_catalog.pageIndexCache.has(ref)) {
|
|
592
|
+
_catalog.pageIndexCache.put(ref, 0);
|
|
593
|
+
}
|
|
594
|
+
return { dictionary: obj, reference: ref };
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
throw new FormatError('The Linearization dictionary does not point to a valid Page dictionary.');
|
|
598
|
+
}
|
|
599
|
+
catch (reason) {
|
|
600
|
+
return _catalog.getPageDictionary(pageIndex);
|
|
601
|
+
}
|
|
602
|
+
};
|
|
603
|
+
PdfDocument.prototype._checkHeader = function () {
|
|
604
|
+
var stream = this._stream;
|
|
605
|
+
stream.reset();
|
|
606
|
+
if (!this._find(stream, this._headerSignature)) {
|
|
607
|
+
return;
|
|
608
|
+
}
|
|
609
|
+
stream.moveStart();
|
|
610
|
+
var version = '';
|
|
611
|
+
var ch = stream.getByte();
|
|
612
|
+
while (ch > 0x20) {
|
|
613
|
+
if (version.length >= 12) {
|
|
614
|
+
break;
|
|
615
|
+
}
|
|
616
|
+
version += String.fromCharCode(ch);
|
|
617
|
+
ch = stream.getByte();
|
|
618
|
+
}
|
|
619
|
+
if (!this._version) {
|
|
620
|
+
this._version = version.substring(5);
|
|
621
|
+
}
|
|
622
|
+
};
|
|
623
|
+
PdfDocument.prototype._parse = function (recoveryMode) {
|
|
624
|
+
this._crossReference._parse(recoveryMode);
|
|
625
|
+
this._catalog = new _PdfCatalog(this._crossReference);
|
|
626
|
+
if (this._catalog.version) {
|
|
627
|
+
this._version = this._catalog.version;
|
|
628
|
+
}
|
|
629
|
+
};
|
|
630
|
+
PdfDocument.prototype._find = function (stream, signature, limit, backwards) {
|
|
631
|
+
if (limit === void 0) { limit = 1024; }
|
|
632
|
+
if (backwards === void 0) { backwards = false; }
|
|
633
|
+
var signatureLength = signature.length;
|
|
634
|
+
var scanBytes = stream.peekBytes(limit);
|
|
635
|
+
var scanLength = scanBytes.length - signatureLength;
|
|
636
|
+
if (scanLength <= 0) {
|
|
637
|
+
return false;
|
|
638
|
+
}
|
|
639
|
+
if (backwards) {
|
|
640
|
+
var signatureEnd = signatureLength - 1;
|
|
641
|
+
var position = scanBytes.length - 1;
|
|
642
|
+
while (position >= signatureEnd) {
|
|
643
|
+
var j = 0;
|
|
644
|
+
while (j < signatureLength && scanBytes[position - j] === signature[signatureEnd - j]) {
|
|
645
|
+
j++;
|
|
646
|
+
}
|
|
647
|
+
if (j >= signatureLength) {
|
|
648
|
+
stream.position += position - signatureEnd;
|
|
649
|
+
return true;
|
|
650
|
+
}
|
|
651
|
+
position--;
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
else {
|
|
655
|
+
var position = 0;
|
|
656
|
+
while (position <= scanLength) {
|
|
657
|
+
var j = 0;
|
|
658
|
+
while (j < signatureLength && scanBytes[position + j] === signature[j]) { // eslint-disable-line
|
|
659
|
+
j++;
|
|
660
|
+
}
|
|
661
|
+
if (j >= signatureLength) {
|
|
662
|
+
stream.position += position;
|
|
663
|
+
return true;
|
|
664
|
+
}
|
|
665
|
+
position++;
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
return false;
|
|
669
|
+
};
|
|
670
|
+
PdfDocument.prototype._doPostProcess = function (isFlatten) {
|
|
671
|
+
if (isFlatten === void 0) { isFlatten = false; }
|
|
672
|
+
this._doPostProcessOnFormFields(isFlatten);
|
|
673
|
+
this._doPostProcessOnAnnotations(isFlatten);
|
|
674
|
+
};
|
|
675
|
+
PdfDocument.prototype._doPostProcessOnFormFields = function (isFlatten) {
|
|
676
|
+
if (isFlatten === void 0) { isFlatten = false; }
|
|
677
|
+
this.form._doPostProcess(isFlatten);
|
|
678
|
+
if (isFlatten) {
|
|
679
|
+
var formObject = this._catalog._catalogDictionary.getRaw('AcroForm');
|
|
680
|
+
var dictionary = new _PdfDictionary(this._crossReference);
|
|
681
|
+
dictionary._updated = true;
|
|
682
|
+
if (formObject instanceof _PdfReference) {
|
|
683
|
+
this._crossReference._cacheMap.set(formObject, dictionary);
|
|
684
|
+
}
|
|
685
|
+
else {
|
|
686
|
+
this.form._dictionary = dictionary;
|
|
687
|
+
this._crossReference._allowCatalog = true;
|
|
688
|
+
}
|
|
689
|
+
this.form._clear();
|
|
690
|
+
}
|
|
691
|
+
};
|
|
692
|
+
PdfDocument.prototype._doPostProcessOnAnnotations = function (isFlatten) {
|
|
693
|
+
if (isFlatten === void 0) { isFlatten = false; }
|
|
694
|
+
for (var i = 0; i < this.pageCount; i++) {
|
|
695
|
+
var page = this.getPage(i);
|
|
696
|
+
page.annotations._doPostProcess(isFlatten);
|
|
697
|
+
if (isFlatten) {
|
|
698
|
+
if (page._pageDictionary.has('Annots')) {
|
|
699
|
+
delete page._pageDictionary._map.Annots;
|
|
700
|
+
page._pageDictionary._updated = true;
|
|
701
|
+
}
|
|
702
|
+
page.annotations._clear();
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
|
+
PdfDocument.prototype._addWatermarkText = function () {
|
|
707
|
+
if (this.pageCount > 0) {
|
|
708
|
+
for (var index = 0; index < this._pageCount; index++) {
|
|
709
|
+
var page = this.getPage(index);
|
|
710
|
+
if (page) {
|
|
711
|
+
try {
|
|
712
|
+
var graphics = page.graphics;
|
|
713
|
+
graphics.save();
|
|
714
|
+
graphics.setTransparency(0.20);
|
|
715
|
+
graphics.drawRectangle(0, 0, page.size[0], 33.75, new PdfBrush([255, 255, 255]));
|
|
716
|
+
graphics.restore();
|
|
717
|
+
graphics.save();
|
|
718
|
+
graphics.setTransparency(0.50);
|
|
719
|
+
var font = new PdfStandardFont(PdfFontFamily.helvetica, 12, PdfFontStyle.regular);
|
|
720
|
+
var format = new PdfStringFormat(PdfTextAlignment.center, PdfVerticalAlignment.middle);
|
|
721
|
+
graphics.drawString('Created with a trial version of Syncfusion Essential PDF', font, [0, 0, page.size[0], 33.75], null, new PdfBrush([0, 0, 0]), format);
|
|
722
|
+
graphics.restore();
|
|
723
|
+
}
|
|
724
|
+
catch (e) { } // eslint-disable-line
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
}
|
|
728
|
+
};
|
|
729
|
+
return PdfDocument;
|
|
730
|
+
}());
|
|
731
|
+
export { PdfDocument };
|
|
732
|
+
/**
|
|
733
|
+
* Represents annotation export settings.
|
|
734
|
+
* ```typescript
|
|
735
|
+
* // Load an existing PDF document
|
|
736
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
737
|
+
* // Sets export data format as JSON type to annotation export settings
|
|
738
|
+
* let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
|
|
739
|
+
* // Set the data format defined in annotation export settings
|
|
740
|
+
* settings.dataFormat = DataFormat.json;
|
|
741
|
+
* // Export annotations to JSON format
|
|
742
|
+
* let json: Uint8Array = document.exportAnnotations(settings);
|
|
743
|
+
* // Save the document
|
|
744
|
+
* document.save('output.pdf');
|
|
745
|
+
* // Destroy the document
|
|
746
|
+
* document.destroy();
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
var PdfAnnotationExportSettings = /** @class */ (function () {
|
|
750
|
+
function PdfAnnotationExportSettings() {
|
|
751
|
+
this._format = DataFormat.xfdf;
|
|
752
|
+
this._exportAppearance = false;
|
|
753
|
+
}
|
|
754
|
+
Object.defineProperty(PdfAnnotationExportSettings.prototype, "dataFormat", {
|
|
755
|
+
/**
|
|
756
|
+
* Gets the data format defined in annotation export settings.
|
|
757
|
+
*
|
|
758
|
+
* @returns {DataFormat} - Returns the data format.
|
|
759
|
+
* ```typescript
|
|
760
|
+
* // Load an existing PDF document
|
|
761
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
762
|
+
* // Sets export data format as JSON type to annotation export settings
|
|
763
|
+
* let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
|
|
764
|
+
* // Export annotations to JSON format
|
|
765
|
+
* let json: Uint8Array = document.exportAnnotations(settings);
|
|
766
|
+
* // Get the data format defined in annotation export settings
|
|
767
|
+
* let dataFormat: DataFormat = settings.dataFormat;
|
|
768
|
+
* // Save the document
|
|
769
|
+
* document.save('output.pdf');
|
|
770
|
+
* // Destroy the document
|
|
771
|
+
* document.destroy();
|
|
772
|
+
* ```
|
|
773
|
+
*/
|
|
774
|
+
get: function () {
|
|
775
|
+
return this._format;
|
|
776
|
+
},
|
|
777
|
+
/**
|
|
778
|
+
* Sets the data format defined in annotation export settings.
|
|
779
|
+
*
|
|
780
|
+
* @param {DataFormat} format - Specifies the data format.
|
|
781
|
+
* ```typescript
|
|
782
|
+
* // Load an existing PDF document
|
|
783
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
784
|
+
* // Sets export data format as JSON type to annotation export settings
|
|
785
|
+
* let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
|
|
786
|
+
* // Set the data format defined in annotation export settings
|
|
787
|
+
* settings.dataFormat = DataFormat.json;
|
|
788
|
+
* // Export annotations to JSON format
|
|
789
|
+
* let json: Uint8Array = document.exportAnnotations(settings);
|
|
790
|
+
* // Save the document
|
|
791
|
+
* document.save('output.pdf');
|
|
792
|
+
* // Destroy the document
|
|
793
|
+
* document.destroy();
|
|
794
|
+
* ```
|
|
795
|
+
*/
|
|
796
|
+
set: function (format) {
|
|
797
|
+
this._format = format;
|
|
798
|
+
},
|
|
799
|
+
enumerable: true,
|
|
800
|
+
configurable: true
|
|
801
|
+
});
|
|
802
|
+
Object.defineProperty(PdfAnnotationExportSettings.prototype, "exportAppearance", {
|
|
803
|
+
/**
|
|
804
|
+
* Gets the boolean value indicating whether the appearance of a particular object can be exported or not.
|
|
805
|
+
*
|
|
806
|
+
* @returns {boolean} - Returns the boolean value.
|
|
807
|
+
* ```typescript
|
|
808
|
+
* // Load an existing PDF document
|
|
809
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
810
|
+
* // Sets the annotation export settings with enabled export appearance.
|
|
811
|
+
* let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
|
|
812
|
+
* // Export annotations to XFDF format
|
|
813
|
+
* let xfdf: Uint8Array = document.exportAnnotations(settings);
|
|
814
|
+
* // Get the boolean value indicating whether the appearance of a particular object can be exported or not
|
|
815
|
+
* let appearance: boolean = settings.exportAppearance;
|
|
816
|
+
* // Save the document
|
|
817
|
+
* document.save('output.pdf');
|
|
818
|
+
* // Destroy the document
|
|
819
|
+
* document.destroy();
|
|
820
|
+
* ```
|
|
821
|
+
*/
|
|
822
|
+
get: function () {
|
|
823
|
+
return this._exportAppearance;
|
|
824
|
+
},
|
|
825
|
+
/**
|
|
826
|
+
* Sets the boolean value indicating whether the appearance of a particular object can be exported or not.
|
|
827
|
+
*
|
|
828
|
+
* @param {boolean} value - The boolean value.
|
|
829
|
+
* ```typescript
|
|
830
|
+
* // Load an existing PDF document
|
|
831
|
+
* let document: PdfDocument = new PdfDocument(data, password);
|
|
832
|
+
* // Sets the annotation export settings with enabled export appearance.
|
|
833
|
+
* let settings: PdfAnnotationExportSettings = new PdfAnnotationExportSettings();
|
|
834
|
+
* // Set the boolean value indicating whether the appearance of a particular object can be exported or not
|
|
835
|
+
* settings.exportAppearance = true;
|
|
836
|
+
* // Export annotations to XFDF format
|
|
837
|
+
* let xfdf: Uint8Array = document.exportAnnotations(settings);
|
|
838
|
+
* // Save the document
|
|
839
|
+
* document.save('output.pdf');
|
|
840
|
+
* // Destroy the document
|
|
841
|
+
* document.destroy();
|
|
842
|
+
* ```
|
|
843
|
+
*/
|
|
844
|
+
set: function (value) {
|
|
845
|
+
this._exportAppearance = value;
|
|
846
|
+
},
|
|
847
|
+
enumerable: true,
|
|
848
|
+
configurable: true
|
|
849
|
+
});
|
|
850
|
+
return PdfAnnotationExportSettings;
|
|
851
|
+
}());
|
|
852
|
+
export { PdfAnnotationExportSettings };
|
|
853
|
+
/**
|
|
854
|
+
* Represents form fields export settings.
|
|
855
|
+
* ```typescript
|
|
856
|
+
* // Load an existing PDF document
|
|
857
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
858
|
+
* // Sets the form field data export settings with output data format.
|
|
859
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
860
|
+
* // Set the data format defined in form field export settings.
|
|
861
|
+
* settings.dataFormat = DataFormat.json;
|
|
862
|
+
* // Export form field to JSON format
|
|
863
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
864
|
+
* // Save the document
|
|
865
|
+
* document.save('output.pdf');
|
|
866
|
+
* // Destroy the document
|
|
867
|
+
* document.destroy();
|
|
868
|
+
* ```
|
|
869
|
+
*/
|
|
870
|
+
var PdfFormFieldExportSettings = /** @class */ (function () {
|
|
871
|
+
function PdfFormFieldExportSettings() {
|
|
872
|
+
this._format = DataFormat.xfdf;
|
|
873
|
+
this._exportName = '';
|
|
874
|
+
this._asPerSpecification = true;
|
|
875
|
+
}
|
|
876
|
+
Object.defineProperty(PdfFormFieldExportSettings.prototype, "dataFormat", {
|
|
877
|
+
/**
|
|
878
|
+
* Gets the data format defined in form field export settings.
|
|
879
|
+
*
|
|
880
|
+
* @returns {DataFormat} - Returns the data format.
|
|
881
|
+
* ```typescript
|
|
882
|
+
* // Load an existing PDF document
|
|
883
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
884
|
+
* // Sets the form field data export settings with output data format.
|
|
885
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
886
|
+
* // Export form field to JSON format
|
|
887
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
888
|
+
* // Get the data format defined in form field export settings
|
|
889
|
+
* let dataFormat: DataFormat = settings.dataFormat;
|
|
890
|
+
* // Save the document
|
|
891
|
+
* document.save('output.pdf');
|
|
892
|
+
* // Destroy the document
|
|
893
|
+
* document.destroy();
|
|
894
|
+
* ```
|
|
895
|
+
*/
|
|
896
|
+
get: function () {
|
|
897
|
+
return this._format;
|
|
898
|
+
},
|
|
899
|
+
/**
|
|
900
|
+
* Sets the data format defined in form field export settings.
|
|
901
|
+
*
|
|
902
|
+
* @param {DataFormat} format - Specifies the data format.
|
|
903
|
+
* ```typescript
|
|
904
|
+
* // Load an existing PDF document
|
|
905
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
906
|
+
* // Sets the form field data export settings with output data format.
|
|
907
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
908
|
+
* // Set the data format defined in form field export settings.
|
|
909
|
+
* settings.dataFormat = DataFormat.json;
|
|
910
|
+
* // Export form field to JSON format
|
|
911
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
912
|
+
* // Save the document
|
|
913
|
+
* document.save('output.pdf');
|
|
914
|
+
* // Destroy the document
|
|
915
|
+
* document.destroy();
|
|
916
|
+
* ```
|
|
917
|
+
*/
|
|
918
|
+
set: function (format) {
|
|
919
|
+
this._format = format;
|
|
920
|
+
},
|
|
921
|
+
enumerable: true,
|
|
922
|
+
configurable: true
|
|
923
|
+
});
|
|
924
|
+
Object.defineProperty(PdfFormFieldExportSettings.prototype, "exportName", {
|
|
925
|
+
/**
|
|
926
|
+
* Gets the export name defined in form field export settings.
|
|
927
|
+
*
|
|
928
|
+
* @returns {string} - Returns the string value.
|
|
929
|
+
* ```typescript
|
|
930
|
+
* // Load an existing PDF document
|
|
931
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
932
|
+
* // Sets the form field data export settings with export name.
|
|
933
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
934
|
+
* // Export form field to JSON format
|
|
935
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
936
|
+
* // Get the export name defined in form field export settings
|
|
937
|
+
* let name: boolean = settings.exportName;
|
|
938
|
+
* // Save the document
|
|
939
|
+
* document.save('output.pdf');
|
|
940
|
+
* // Destroy the document
|
|
941
|
+
* document.destroy();
|
|
942
|
+
* ```
|
|
943
|
+
*/
|
|
944
|
+
get: function () {
|
|
945
|
+
return this._exportName;
|
|
946
|
+
},
|
|
947
|
+
/**
|
|
948
|
+
* Sets the export name defined in form field export settings.
|
|
949
|
+
*
|
|
950
|
+
* @param {string} name - Specifies the export name of the form.
|
|
951
|
+
* ```typescript
|
|
952
|
+
* // Load an existing PDF document
|
|
953
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
954
|
+
* // Sets the form field data export settings with export name.
|
|
955
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
956
|
+
* // Set the export name defined in form field export settings.
|
|
957
|
+
* settings.exportName = ‘JobApplication’.
|
|
958
|
+
* // Export form field to JSON format
|
|
959
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
960
|
+
* // Save the document
|
|
961
|
+
* document.save('output.pdf');
|
|
962
|
+
* // Destroy the document
|
|
963
|
+
* document.destroy();
|
|
964
|
+
* ```
|
|
965
|
+
*/
|
|
966
|
+
set: function (name) {
|
|
967
|
+
this._exportName = name;
|
|
968
|
+
},
|
|
969
|
+
enumerable: true,
|
|
970
|
+
configurable: true
|
|
971
|
+
});
|
|
972
|
+
Object.defineProperty(PdfFormFieldExportSettings.prototype, "asPerSpecification", {
|
|
973
|
+
/**
|
|
974
|
+
* Gets the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
975
|
+
*
|
|
976
|
+
* @returns {boolean} - Returns the boolean value.
|
|
977
|
+
* ```typescript
|
|
978
|
+
* // Load an existing PDF document
|
|
979
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
980
|
+
* // Sets the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
981
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
982
|
+
* // Export form field to JSON format
|
|
983
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
984
|
+
* // Get the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
985
|
+
* let asPerSpecification: boolean = settings.asPerSpecification;
|
|
986
|
+
* // Save the document
|
|
987
|
+
* document.save('output.pdf');
|
|
988
|
+
* // Destroy the document
|
|
989
|
+
* document.destroy();
|
|
990
|
+
* ```
|
|
991
|
+
*/
|
|
992
|
+
get: function () {
|
|
993
|
+
return this._asPerSpecification;
|
|
994
|
+
},
|
|
995
|
+
/**
|
|
996
|
+
* Sets the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
997
|
+
*
|
|
998
|
+
* @param {boolean} value - The boolean value.
|
|
999
|
+
* ```typescript
|
|
1000
|
+
* // Load an existing PDF document
|
|
1001
|
+
* let document: PdfDocument = new PdfDocument(data);
|
|
1002
|
+
* // Sets the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
1003
|
+
* let settings: PdfFormFieldExportSettings = new PdfFormFieldExportSettings();
|
|
1004
|
+
* // Set the boolean value indicating whether the data in a form field can be exported based on a certain specification.
|
|
1005
|
+
* settings.asPerSpecification = true;
|
|
1006
|
+
* // Export form field to JSON format
|
|
1007
|
+
* let json: Uint8Array = document.exportFormData(settings);
|
|
1008
|
+
* // Save the document
|
|
1009
|
+
* document.save('output.pdf');
|
|
1010
|
+
* // Destroy the document
|
|
1011
|
+
* document.destroy();
|
|
1012
|
+
* ```
|
|
1013
|
+
*/
|
|
1014
|
+
set: function (value) {
|
|
1015
|
+
this._asPerSpecification = value;
|
|
1016
|
+
},
|
|
1017
|
+
enumerable: true,
|
|
1018
|
+
configurable: true
|
|
1019
|
+
});
|
|
1020
|
+
return PdfFormFieldExportSettings;
|
|
1021
|
+
}());
|
|
1022
|
+
export { PdfFormFieldExportSettings };
|