@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,1035 @@
|
|
|
1
|
+
import { _PdfCommand, _PdfName, _PdfDictionary, _isCommand, _PdfReference } from './pdf-primitives';
|
|
2
|
+
import { _isWhiteSpace, FormatError, ParserEndOfFileException } from './utils';
|
|
3
|
+
import { _PdfNullStream } from './base-stream';
|
|
4
|
+
import { PdfPredictorStream } from './predictor-stream';
|
|
5
|
+
import { _PdfFlateStream } from './flate-stream';
|
|
6
|
+
var maxCacheLength = 1000;
|
|
7
|
+
var maxNumberLength = 5552;
|
|
8
|
+
var endOfFile = 'EOF';
|
|
9
|
+
var specialChars = [
|
|
10
|
+
1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 1, 0, 0,
|
|
11
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
12
|
+
1, 0, 0, 0, 0, 2, 0, 0, 2, 2, 0, 0, 0, 0, 0, 2,
|
|
13
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0,
|
|
14
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
15
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,
|
|
16
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
17
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 2, 0, 0,
|
|
18
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
19
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
20
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
21
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
22
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
23
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
24
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
|
25
|
+
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
|
26
|
+
];
|
|
27
|
+
var _PdfLexicalOperator = /** @class */ (function () {
|
|
28
|
+
function _PdfLexicalOperator(stream) {
|
|
29
|
+
this.stream = stream;
|
|
30
|
+
this.nextChar();
|
|
31
|
+
this.stringBuffer = [];
|
|
32
|
+
this._hexStringNumber = 0;
|
|
33
|
+
this.beginInlineImagePosition = -1;
|
|
34
|
+
}
|
|
35
|
+
_PdfLexicalOperator.prototype.nextChar = function () {
|
|
36
|
+
return (this.currentChar = this.stream.getByte());
|
|
37
|
+
};
|
|
38
|
+
_PdfLexicalOperator.prototype.peekChar = function () {
|
|
39
|
+
return this.stream.peekByte();
|
|
40
|
+
};
|
|
41
|
+
_PdfLexicalOperator.prototype.getNumber = function () {
|
|
42
|
+
var ch = this.currentChar;
|
|
43
|
+
var eNotation = false;
|
|
44
|
+
var divideBy = 0;
|
|
45
|
+
var sign = 0;
|
|
46
|
+
if (ch === 0x2d) {
|
|
47
|
+
sign = -1;
|
|
48
|
+
ch = this.nextChar();
|
|
49
|
+
if (ch === 0x2d) {
|
|
50
|
+
ch = this.nextChar();
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else if (ch === 0x2b) {
|
|
54
|
+
sign = 1;
|
|
55
|
+
ch = this.nextChar();
|
|
56
|
+
}
|
|
57
|
+
if (ch === 0x0a || ch === 0x0d) {
|
|
58
|
+
do {
|
|
59
|
+
ch = this.nextChar();
|
|
60
|
+
} while (ch === 0x0a || ch === 0x0d);
|
|
61
|
+
}
|
|
62
|
+
if (ch === 0x2e) {
|
|
63
|
+
divideBy = 10;
|
|
64
|
+
ch = this.nextChar();
|
|
65
|
+
}
|
|
66
|
+
if (ch < 0x30 || ch > 0x39) {
|
|
67
|
+
if (_isWhiteSpace(ch) || ch === -1) {
|
|
68
|
+
if (divideBy === 10 && sign === 0) {
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
if (divideBy === 0 && sign === -1) {
|
|
72
|
+
return 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
throw new FormatError("Invalid number: " + String.fromCharCode(ch) + " (charCode " + ch + ")");
|
|
76
|
+
}
|
|
77
|
+
sign = sign || 1;
|
|
78
|
+
var baseValue = ch - 0x30;
|
|
79
|
+
var powerValue = 0;
|
|
80
|
+
var powerValueSign = 1;
|
|
81
|
+
ch = this.nextChar();
|
|
82
|
+
while (ch >= 0) {
|
|
83
|
+
if (ch >= 0x30 && ch <= 0x39) {
|
|
84
|
+
var currentDigit = ch - 0x30;
|
|
85
|
+
if (eNotation) {
|
|
86
|
+
powerValue = powerValue * 10 + currentDigit;
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
if (divideBy !== 0) {
|
|
90
|
+
divideBy *= 10;
|
|
91
|
+
}
|
|
92
|
+
baseValue = baseValue * 10 + currentDigit;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
else if (ch === 0x2e) {
|
|
96
|
+
if (divideBy === 0) {
|
|
97
|
+
divideBy = 1;
|
|
98
|
+
}
|
|
99
|
+
else {
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
else if (ch === 0x2d) {
|
|
104
|
+
ch = this.nextChar();
|
|
105
|
+
continue;
|
|
106
|
+
}
|
|
107
|
+
else if (ch === 0x45 || ch === 0x65) {
|
|
108
|
+
ch = this.peekChar();
|
|
109
|
+
if (ch === 0x2b || ch === 0x2d) {
|
|
110
|
+
powerValueSign = ch === 0x2d ? -1 : 1;
|
|
111
|
+
this.nextChar();
|
|
112
|
+
}
|
|
113
|
+
else if (ch < 0x30 || ch > 0x39) {
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
eNotation = true;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
ch = this.nextChar();
|
|
122
|
+
}
|
|
123
|
+
if (divideBy !== 0) {
|
|
124
|
+
baseValue /= divideBy;
|
|
125
|
+
}
|
|
126
|
+
if (eNotation) {
|
|
127
|
+
baseValue *= Math.pow(10, (powerValueSign * powerValue));
|
|
128
|
+
}
|
|
129
|
+
return sign * baseValue;
|
|
130
|
+
};
|
|
131
|
+
_PdfLexicalOperator.prototype.getString = function () {
|
|
132
|
+
var numParen = 1;
|
|
133
|
+
var done = false;
|
|
134
|
+
var stringBuffer = this.stringBuffer;
|
|
135
|
+
stringBuffer.length = 0;
|
|
136
|
+
var ch = this.nextChar();
|
|
137
|
+
while (true) { // eslint-disable-line
|
|
138
|
+
var charBuffered = false;
|
|
139
|
+
switch (ch | 0) {
|
|
140
|
+
case -1:
|
|
141
|
+
done = true;
|
|
142
|
+
break;
|
|
143
|
+
case 0x28:
|
|
144
|
+
++numParen;
|
|
145
|
+
stringBuffer.push('(');
|
|
146
|
+
break;
|
|
147
|
+
case 0x29:
|
|
148
|
+
if (--numParen === 0) {
|
|
149
|
+
this.nextChar();
|
|
150
|
+
done = true;
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
stringBuffer.push(')');
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case 0x5c:
|
|
157
|
+
ch = this.nextChar();
|
|
158
|
+
switch (ch) {
|
|
159
|
+
case -1:
|
|
160
|
+
done = true;
|
|
161
|
+
break;
|
|
162
|
+
case 0x6e:
|
|
163
|
+
stringBuffer.push('\n');
|
|
164
|
+
break;
|
|
165
|
+
case 0x72:
|
|
166
|
+
stringBuffer.push('\r');
|
|
167
|
+
break;
|
|
168
|
+
case 0x74:
|
|
169
|
+
stringBuffer.push('\t');
|
|
170
|
+
break;
|
|
171
|
+
case 0x62:
|
|
172
|
+
stringBuffer.push('\b');
|
|
173
|
+
break;
|
|
174
|
+
case 0x66:
|
|
175
|
+
stringBuffer.push('\f');
|
|
176
|
+
break;
|
|
177
|
+
case 0x5c:
|
|
178
|
+
case 0x28:
|
|
179
|
+
case 0x29:
|
|
180
|
+
stringBuffer.push(String.fromCharCode(ch));
|
|
181
|
+
break;
|
|
182
|
+
case 0x30:
|
|
183
|
+
case 0x31:
|
|
184
|
+
case 0x32:
|
|
185
|
+
case 0x33:
|
|
186
|
+
case 0x34:
|
|
187
|
+
case 0x35:
|
|
188
|
+
case 0x36:
|
|
189
|
+
case 0x37:
|
|
190
|
+
var x = ch & 0x0f; // eslint-disable-line
|
|
191
|
+
ch = this.nextChar();
|
|
192
|
+
charBuffered = true;
|
|
193
|
+
if (ch >= 0x30 && ch <= 0x37) {
|
|
194
|
+
x = (x << 3) + (ch & 0x0f);
|
|
195
|
+
ch = this.nextChar();
|
|
196
|
+
if (ch >= 0x30 && ch <= 0x37) {
|
|
197
|
+
charBuffered = false;
|
|
198
|
+
x = (x << 3) + (ch & 0x0f);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
stringBuffer.push(String.fromCharCode(x));
|
|
202
|
+
break;
|
|
203
|
+
case 0x0d:
|
|
204
|
+
if (this.peekChar() === 0x0a) {
|
|
205
|
+
this.nextChar();
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
case 0x0a:
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
stringBuffer.push(String.fromCharCode(ch));
|
|
212
|
+
break;
|
|
213
|
+
}
|
|
214
|
+
break;
|
|
215
|
+
default:
|
|
216
|
+
stringBuffer.push(String.fromCharCode(ch));
|
|
217
|
+
break;
|
|
218
|
+
}
|
|
219
|
+
if (done) {
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
if (!charBuffered) {
|
|
223
|
+
ch = this.nextChar();
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
return stringBuffer.join('');
|
|
227
|
+
};
|
|
228
|
+
_PdfLexicalOperator.prototype.getName = function () {
|
|
229
|
+
var ch;
|
|
230
|
+
var previousCh;
|
|
231
|
+
var stringBuffer = this.stringBuffer;
|
|
232
|
+
stringBuffer.length = 0;
|
|
233
|
+
ch = this.nextChar();
|
|
234
|
+
while (ch >= 0 && !specialChars[ch]) { // eslint-disable-line
|
|
235
|
+
if (ch === 0x23) {
|
|
236
|
+
ch = this.nextChar();
|
|
237
|
+
if (specialChars[ch]) { // eslint-disable-line
|
|
238
|
+
stringBuffer.push('#');
|
|
239
|
+
break;
|
|
240
|
+
}
|
|
241
|
+
var x = this._toHexDigit(ch);
|
|
242
|
+
if (x !== -1) {
|
|
243
|
+
previousCh = ch;
|
|
244
|
+
ch = this.nextChar();
|
|
245
|
+
var x2 = this._toHexDigit(ch);
|
|
246
|
+
if (x2 === -1) {
|
|
247
|
+
stringBuffer.push('#', String.fromCharCode(previousCh));
|
|
248
|
+
if (specialChars[ch]) { // eslint-disable-line
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
stringBuffer.push(String.fromCharCode(ch));
|
|
252
|
+
ch = this.nextChar();
|
|
253
|
+
continue;
|
|
254
|
+
}
|
|
255
|
+
stringBuffer.push(String.fromCharCode((x << 4) | x2));
|
|
256
|
+
}
|
|
257
|
+
else {
|
|
258
|
+
stringBuffer.push('#', String.fromCharCode(ch));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
else {
|
|
262
|
+
stringBuffer.push(String.fromCharCode(ch));
|
|
263
|
+
}
|
|
264
|
+
ch = this.nextChar();
|
|
265
|
+
}
|
|
266
|
+
return _PdfName.get(stringBuffer.join(''));
|
|
267
|
+
};
|
|
268
|
+
_PdfLexicalOperator.prototype.getHexString = function () {
|
|
269
|
+
var stringBuffer = this.stringBuffer;
|
|
270
|
+
stringBuffer.length = 0;
|
|
271
|
+
var ch = this.currentChar;
|
|
272
|
+
var isFirstHex = true;
|
|
273
|
+
var firstDigit;
|
|
274
|
+
var secondDigit;
|
|
275
|
+
this._hexStringNumber = 0;
|
|
276
|
+
while (true) { // eslint-disable-line
|
|
277
|
+
if (ch < 0) {
|
|
278
|
+
break;
|
|
279
|
+
}
|
|
280
|
+
else if (ch === 0x3e) {
|
|
281
|
+
this.nextChar();
|
|
282
|
+
break;
|
|
283
|
+
}
|
|
284
|
+
else if (specialChars[ch] === 1) { // eslint-disable-line
|
|
285
|
+
ch = this.nextChar();
|
|
286
|
+
continue;
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
if (isFirstHex) {
|
|
290
|
+
firstDigit = this._toHexDigit(ch);
|
|
291
|
+
if (firstDigit === -1) {
|
|
292
|
+
ch = this.nextChar();
|
|
293
|
+
continue;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
secondDigit = this._toHexDigit(ch);
|
|
298
|
+
if (secondDigit === -1) {
|
|
299
|
+
ch = this.nextChar();
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
stringBuffer.push(String.fromCharCode((firstDigit << 4) | secondDigit));
|
|
303
|
+
}
|
|
304
|
+
isFirstHex = !isFirstHex;
|
|
305
|
+
ch = this.nextChar();
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
return stringBuffer.join('');
|
|
309
|
+
};
|
|
310
|
+
_PdfLexicalOperator.prototype.getObject = function () {
|
|
311
|
+
var comment = false;
|
|
312
|
+
var ch = this.currentChar;
|
|
313
|
+
while (true) { // eslint-disable-line
|
|
314
|
+
if (ch < 0) {
|
|
315
|
+
return endOfFile;
|
|
316
|
+
}
|
|
317
|
+
if (comment) {
|
|
318
|
+
if (ch === 0x0a || ch === 0x0d) {
|
|
319
|
+
comment = false;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
else if (ch === 0x25) {
|
|
323
|
+
comment = true;
|
|
324
|
+
}
|
|
325
|
+
else if (specialChars[ch] !== 1) { // eslint-disable-line
|
|
326
|
+
break;
|
|
327
|
+
}
|
|
328
|
+
ch = this.nextChar();
|
|
329
|
+
}
|
|
330
|
+
switch (ch | 0) {
|
|
331
|
+
case 0x30:
|
|
332
|
+
case 0x31:
|
|
333
|
+
case 0x32:
|
|
334
|
+
case 0x33:
|
|
335
|
+
case 0x34:
|
|
336
|
+
case 0x35:
|
|
337
|
+
case 0x36:
|
|
338
|
+
case 0x37:
|
|
339
|
+
case 0x38:
|
|
340
|
+
case 0x39:
|
|
341
|
+
case 0x2b:
|
|
342
|
+
case 0x2d:
|
|
343
|
+
case 0x2e:
|
|
344
|
+
return this.getNumber();
|
|
345
|
+
case 0x28:
|
|
346
|
+
return this.getString();
|
|
347
|
+
case 0x2f:
|
|
348
|
+
return this.getName();
|
|
349
|
+
case 0x5b:
|
|
350
|
+
this.nextChar();
|
|
351
|
+
return _PdfCommand.get('[');
|
|
352
|
+
case 0x5d:
|
|
353
|
+
this.nextChar();
|
|
354
|
+
return _PdfCommand.get(']');
|
|
355
|
+
case 0x3c:
|
|
356
|
+
ch = this.nextChar();
|
|
357
|
+
if (ch === 0x3c) {
|
|
358
|
+
this.nextChar();
|
|
359
|
+
return _PdfCommand.get('<<');
|
|
360
|
+
}
|
|
361
|
+
return this.getHexString();
|
|
362
|
+
case 0x3e:
|
|
363
|
+
ch = this.nextChar();
|
|
364
|
+
if (ch === 0x3e) {
|
|
365
|
+
this.nextChar();
|
|
366
|
+
return _PdfCommand.get('>>');
|
|
367
|
+
}
|
|
368
|
+
return _PdfCommand.get('>');
|
|
369
|
+
case 0x7b:
|
|
370
|
+
this.nextChar();
|
|
371
|
+
return _PdfCommand.get('{');
|
|
372
|
+
case 0x7d:
|
|
373
|
+
this.nextChar();
|
|
374
|
+
return _PdfCommand.get('}');
|
|
375
|
+
case 0x29:
|
|
376
|
+
this.nextChar();
|
|
377
|
+
throw new FormatError("Illegal character: " + ch);
|
|
378
|
+
}
|
|
379
|
+
var str = String.fromCharCode(ch);
|
|
380
|
+
if (ch < 0x20 || ch > 0x7f) {
|
|
381
|
+
var nextCh = this.peekChar();
|
|
382
|
+
if (nextCh >= 0x20 && nextCh <= 0x7f) {
|
|
383
|
+
this.nextChar();
|
|
384
|
+
return _PdfCommand.get(str);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
ch = this.nextChar();
|
|
388
|
+
while (ch >= 0 && !specialChars[ch]) { // eslint-disable-line
|
|
389
|
+
var possibleCommand = str + String.fromCharCode(ch);
|
|
390
|
+
if (str.length === 128) {
|
|
391
|
+
throw new FormatError("Command token too long: " + str.length);
|
|
392
|
+
}
|
|
393
|
+
str = possibleCommand;
|
|
394
|
+
ch = this.nextChar();
|
|
395
|
+
}
|
|
396
|
+
if (str === 'true') {
|
|
397
|
+
return true;
|
|
398
|
+
}
|
|
399
|
+
if (str === 'false') {
|
|
400
|
+
return false;
|
|
401
|
+
}
|
|
402
|
+
if (str === 'null') {
|
|
403
|
+
return null;
|
|
404
|
+
}
|
|
405
|
+
if (str === 'BI') {
|
|
406
|
+
this.beginInlineImagePosition = this.stream.position;
|
|
407
|
+
}
|
|
408
|
+
return _PdfCommand.get(str);
|
|
409
|
+
};
|
|
410
|
+
_PdfLexicalOperator.prototype.peekObj = function () {
|
|
411
|
+
var streamPos = this.stream.position;
|
|
412
|
+
var currentChar = this.currentChar;
|
|
413
|
+
var beginInlineImagePosition = this.beginInlineImagePosition;
|
|
414
|
+
var nextObj; // eslint-disable-line
|
|
415
|
+
try {
|
|
416
|
+
nextObj = this.getObject();
|
|
417
|
+
}
|
|
418
|
+
catch (ex) { } // eslint-disable-line
|
|
419
|
+
this.stream.position = streamPos;
|
|
420
|
+
this.currentChar = currentChar;
|
|
421
|
+
this.beginInlineImagePosition = beginInlineImagePosition;
|
|
422
|
+
return nextObj;
|
|
423
|
+
};
|
|
424
|
+
_PdfLexicalOperator.prototype.skipToNextLine = function () {
|
|
425
|
+
var ch = this.currentChar;
|
|
426
|
+
while (ch >= 0) {
|
|
427
|
+
if (ch === 0x0d) {
|
|
428
|
+
ch = this.nextChar();
|
|
429
|
+
if (ch === 0x0a) {
|
|
430
|
+
this.nextChar();
|
|
431
|
+
}
|
|
432
|
+
break;
|
|
433
|
+
}
|
|
434
|
+
else if (ch === 0x0a) {
|
|
435
|
+
this.nextChar();
|
|
436
|
+
break;
|
|
437
|
+
}
|
|
438
|
+
ch = this.nextChar();
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
_PdfLexicalOperator.prototype._toHexDigit = function (ch) {
|
|
442
|
+
if (ch >= 0x30 && ch <= 0x39) {
|
|
443
|
+
return ch & 0x0f;
|
|
444
|
+
}
|
|
445
|
+
if ((ch >= 0x41 && ch <= 0x46) || (ch >= 0x61 && ch <= 0x66)) {
|
|
446
|
+
return (ch & 0x0f) + 9;
|
|
447
|
+
}
|
|
448
|
+
return -1;
|
|
449
|
+
};
|
|
450
|
+
return _PdfLexicalOperator;
|
|
451
|
+
}());
|
|
452
|
+
export { _PdfLexicalOperator };
|
|
453
|
+
var _PdfParser = /** @class */ (function () {
|
|
454
|
+
function _PdfParser(lexicalOperator, xref, allowStreams, recoveryMode) {
|
|
455
|
+
if (allowStreams === void 0) { allowStreams = false; }
|
|
456
|
+
if (recoveryMode === void 0) { recoveryMode = false; }
|
|
457
|
+
this.lexicalOperator = lexicalOperator;
|
|
458
|
+
this.xref = xref;
|
|
459
|
+
this.allowStreams = allowStreams;
|
|
460
|
+
this.recoveryMode = recoveryMode;
|
|
461
|
+
this.imageCache = new Map();
|
|
462
|
+
this.refill();
|
|
463
|
+
}
|
|
464
|
+
_PdfParser.prototype.refill = function () {
|
|
465
|
+
this.first = this.lexicalOperator.getObject();
|
|
466
|
+
this.second = this.lexicalOperator.getObject();
|
|
467
|
+
};
|
|
468
|
+
_PdfParser.prototype.shift = function () {
|
|
469
|
+
if (this.second instanceof _PdfCommand && this.second.command === 'ID') {
|
|
470
|
+
this.first = this.second;
|
|
471
|
+
this.second = null;
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
this.first = this.second;
|
|
475
|
+
this.second = this.lexicalOperator.getObject();
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
_PdfParser.prototype.tryShift = function () {
|
|
479
|
+
try {
|
|
480
|
+
this.shift();
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
catch (e) {
|
|
484
|
+
return false;
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
_PdfParser.prototype.getObject = function (cipherTransform) {
|
|
488
|
+
var first = this.first; // eslint-disable-line
|
|
489
|
+
this.shift();
|
|
490
|
+
if (first instanceof _PdfCommand) {
|
|
491
|
+
switch (first.command) {
|
|
492
|
+
case 'BI':
|
|
493
|
+
return this.makeInlineImage(cipherTransform);
|
|
494
|
+
case '[':
|
|
495
|
+
var array = []; // eslint-disable-line
|
|
496
|
+
while (!_isCommand(this.first, ']') && this.first !== endOfFile) {
|
|
497
|
+
array.push(this.getObject(cipherTransform));
|
|
498
|
+
}
|
|
499
|
+
if (this.first === endOfFile) {
|
|
500
|
+
if (this.recoveryMode) {
|
|
501
|
+
return array;
|
|
502
|
+
}
|
|
503
|
+
throw new ParserEndOfFileException('End of file inside array.');
|
|
504
|
+
}
|
|
505
|
+
this.shift();
|
|
506
|
+
return array;
|
|
507
|
+
case '<<':
|
|
508
|
+
var dictionary = new _PdfDictionary(this.xref); // eslint-disable-line
|
|
509
|
+
while (!_isCommand(this.first, '>>') && this.first !== endOfFile) {
|
|
510
|
+
if (!(this.first instanceof _PdfName)) {
|
|
511
|
+
this.shift();
|
|
512
|
+
continue;
|
|
513
|
+
}
|
|
514
|
+
var key = this.first.name;
|
|
515
|
+
this.shift();
|
|
516
|
+
var isEnd = this._checkEnd();
|
|
517
|
+
if (isEnd) {
|
|
518
|
+
break;
|
|
519
|
+
}
|
|
520
|
+
dictionary.set(key, this.getObject(cipherTransform));
|
|
521
|
+
}
|
|
522
|
+
if (this.first === endOfFile) {
|
|
523
|
+
if (this.recoveryMode) {
|
|
524
|
+
return dictionary;
|
|
525
|
+
}
|
|
526
|
+
throw new ParserEndOfFileException('End of file inside dictionary.');
|
|
527
|
+
}
|
|
528
|
+
if (_isCommand(this.second, 'stream')) {
|
|
529
|
+
if (this.allowStreams === true) {
|
|
530
|
+
return this.makeStream(dictionary, cipherTransform);
|
|
531
|
+
}
|
|
532
|
+
else {
|
|
533
|
+
return dictionary;
|
|
534
|
+
}
|
|
535
|
+
}
|
|
536
|
+
this.shift();
|
|
537
|
+
return dictionary;
|
|
538
|
+
default:
|
|
539
|
+
return first;
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
if (Number.isInteger(first)) {
|
|
543
|
+
if (Number.isInteger(this.first) && _isCommand(this.second, 'R')) {
|
|
544
|
+
var ref = _PdfReference.get(first, this.first);
|
|
545
|
+
this.shift();
|
|
546
|
+
this.shift();
|
|
547
|
+
return ref;
|
|
548
|
+
}
|
|
549
|
+
return first;
|
|
550
|
+
}
|
|
551
|
+
if (typeof first === 'string') {
|
|
552
|
+
if (cipherTransform) {
|
|
553
|
+
return cipherTransform.decryptString(first);
|
|
554
|
+
}
|
|
555
|
+
return first;
|
|
556
|
+
}
|
|
557
|
+
return first;
|
|
558
|
+
};
|
|
559
|
+
_PdfParser.prototype.findDiscreteDecodeInlineStreamEnd = function (stream) {
|
|
560
|
+
var startPos = stream.position;
|
|
561
|
+
var foundEnd = false;
|
|
562
|
+
var b;
|
|
563
|
+
var markerLength;
|
|
564
|
+
b = stream.getByte();
|
|
565
|
+
while (b !== -1) {
|
|
566
|
+
if (b !== 0xff) {
|
|
567
|
+
b = stream.getByte();
|
|
568
|
+
continue;
|
|
569
|
+
}
|
|
570
|
+
switch (stream.getByte()) {
|
|
571
|
+
case 0x00:
|
|
572
|
+
break;
|
|
573
|
+
case 0xff:
|
|
574
|
+
stream.skip(-1);
|
|
575
|
+
break;
|
|
576
|
+
case 0xd9:
|
|
577
|
+
foundEnd = true;
|
|
578
|
+
break;
|
|
579
|
+
case 0xc0:
|
|
580
|
+
case 0xc1:
|
|
581
|
+
case 0xc2:
|
|
582
|
+
case 0xc3:
|
|
583
|
+
case 0xc5:
|
|
584
|
+
case 0xc6:
|
|
585
|
+
case 0xc7:
|
|
586
|
+
case 0xc9:
|
|
587
|
+
case 0xca:
|
|
588
|
+
case 0xcb:
|
|
589
|
+
case 0xcd:
|
|
590
|
+
case 0xce:
|
|
591
|
+
case 0xcf:
|
|
592
|
+
case 0xc4:
|
|
593
|
+
case 0xcc:
|
|
594
|
+
case 0xda:
|
|
595
|
+
case 0xdb:
|
|
596
|
+
case 0xdc:
|
|
597
|
+
case 0xdd:
|
|
598
|
+
case 0xde:
|
|
599
|
+
case 0xdf:
|
|
600
|
+
case 0xe0:
|
|
601
|
+
case 0xe1:
|
|
602
|
+
case 0xe2:
|
|
603
|
+
case 0xe3:
|
|
604
|
+
case 0xe4:
|
|
605
|
+
case 0xe5:
|
|
606
|
+
case 0xe6:
|
|
607
|
+
case 0xe7:
|
|
608
|
+
case 0xe8:
|
|
609
|
+
case 0xe9:
|
|
610
|
+
case 0xea:
|
|
611
|
+
case 0xeb:
|
|
612
|
+
case 0xec:
|
|
613
|
+
case 0xed:
|
|
614
|
+
case 0xee:
|
|
615
|
+
case 0xef:
|
|
616
|
+
case 0xfe:
|
|
617
|
+
markerLength = stream.getUnsignedInteger16();
|
|
618
|
+
if (markerLength > 2) {
|
|
619
|
+
stream.skip(markerLength - 2);
|
|
620
|
+
}
|
|
621
|
+
else {
|
|
622
|
+
stream.skip(-2);
|
|
623
|
+
}
|
|
624
|
+
break;
|
|
625
|
+
}
|
|
626
|
+
if (foundEnd) {
|
|
627
|
+
break;
|
|
628
|
+
}
|
|
629
|
+
b = stream.getByte();
|
|
630
|
+
}
|
|
631
|
+
var length = stream.position - startPos;
|
|
632
|
+
if (b === -1) {
|
|
633
|
+
stream.skip(-length);
|
|
634
|
+
return this.findDefaultInlineStreamEnd(stream);
|
|
635
|
+
}
|
|
636
|
+
this.inlineStreamSkipEI(stream);
|
|
637
|
+
return length;
|
|
638
|
+
};
|
|
639
|
+
_PdfParser.prototype.findDecodeInlineStreamEnd = function (stream) {
|
|
640
|
+
var startPos = stream.position;
|
|
641
|
+
var ch;
|
|
642
|
+
while ((ch = stream.getByte()) !== -1) { // eslint-disable-line
|
|
643
|
+
if (ch === 0x7e) {
|
|
644
|
+
var tildePos = stream.position;
|
|
645
|
+
ch = stream.peekByte();
|
|
646
|
+
while (_isWhiteSpace(ch)) {
|
|
647
|
+
stream.skip();
|
|
648
|
+
ch = stream.peekByte();
|
|
649
|
+
}
|
|
650
|
+
if (ch === 0x3e) {
|
|
651
|
+
stream.skip();
|
|
652
|
+
break;
|
|
653
|
+
}
|
|
654
|
+
if (stream.position > tildePos) {
|
|
655
|
+
var maybeEI = stream.peekBytes(2);
|
|
656
|
+
if (maybeEI[0] === 0x45 && maybeEI[1] === 0x49) {
|
|
657
|
+
break;
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
var length = stream.position - startPos;
|
|
663
|
+
if (ch === -1) {
|
|
664
|
+
stream.skip(-length);
|
|
665
|
+
return this.findDefaultInlineStreamEnd(stream);
|
|
666
|
+
}
|
|
667
|
+
this.inlineStreamSkipEI(stream);
|
|
668
|
+
return length;
|
|
669
|
+
};
|
|
670
|
+
_PdfParser.prototype.findHexDecodeInlineStreamEnd = function (stream) {
|
|
671
|
+
var startPos = stream.position;
|
|
672
|
+
var ch;
|
|
673
|
+
ch = stream.getByte();
|
|
674
|
+
while (ch !== -1) {
|
|
675
|
+
if (ch === 0x3e) {
|
|
676
|
+
break;
|
|
677
|
+
}
|
|
678
|
+
ch = stream.getByte();
|
|
679
|
+
}
|
|
680
|
+
var length = stream.position - startPos;
|
|
681
|
+
if (ch === -1) {
|
|
682
|
+
stream.skip(-length);
|
|
683
|
+
return this.findDefaultInlineStreamEnd(stream);
|
|
684
|
+
}
|
|
685
|
+
this.inlineStreamSkipEI(stream);
|
|
686
|
+
return length;
|
|
687
|
+
};
|
|
688
|
+
_PdfParser.prototype.inlineStreamSkipEI = function (stream) {
|
|
689
|
+
var state = 0;
|
|
690
|
+
var ch;
|
|
691
|
+
ch = stream.getByte();
|
|
692
|
+
while (ch !== -1) {
|
|
693
|
+
if (state === 0) {
|
|
694
|
+
state = ch === 0x45 ? 1 : 0;
|
|
695
|
+
}
|
|
696
|
+
else if (state === 1) {
|
|
697
|
+
state = ch === 0x49 ? 2 : 0;
|
|
698
|
+
}
|
|
699
|
+
else if (state === 2) {
|
|
700
|
+
break;
|
|
701
|
+
}
|
|
702
|
+
ch = stream.getByte();
|
|
703
|
+
}
|
|
704
|
+
};
|
|
705
|
+
_PdfParser.prototype.makeInlineImage = function (cipherTransform) {
|
|
706
|
+
var lexicalOperator = this.lexicalOperator;
|
|
707
|
+
var stream = lexicalOperator.stream;
|
|
708
|
+
var dictionary = new _PdfDictionary(this.xref);
|
|
709
|
+
var dictLength;
|
|
710
|
+
while (!_isCommand(this.first, 'ID') && this.first !== endOfFile) {
|
|
711
|
+
if (!(this.first instanceof _PdfName)) {
|
|
712
|
+
throw new FormatError('Dictionary key must be a name object');
|
|
713
|
+
}
|
|
714
|
+
var key = this.first.name;
|
|
715
|
+
this.shift();
|
|
716
|
+
if (this.first.name === endOfFile) {
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
dictionary.set(key, this.getObject(cipherTransform));
|
|
720
|
+
}
|
|
721
|
+
if (lexicalOperator.beginInlineImagePosition !== -1) {
|
|
722
|
+
dictLength = stream.position - lexicalOperator.beginInlineImagePosition;
|
|
723
|
+
}
|
|
724
|
+
var filter = dictionary.get('F', 'Filter'); // eslint-disable-line
|
|
725
|
+
var filterName;
|
|
726
|
+
if (filter instanceof _PdfName) {
|
|
727
|
+
filterName = filter.name;
|
|
728
|
+
}
|
|
729
|
+
else if (Array.isArray(filter)) {
|
|
730
|
+
var reference = filter[0]; // eslint-disable-line
|
|
731
|
+
var filterZero = (reference !== null && typeof reference !== 'undefined' && reference instanceof _PdfReference) ?
|
|
732
|
+
this.xref._fetch(reference) :
|
|
733
|
+
reference;
|
|
734
|
+
if (filterZero) {
|
|
735
|
+
filterName = filterZero.name;
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
var startPos = stream.position;
|
|
739
|
+
var length;
|
|
740
|
+
switch (filterName) {
|
|
741
|
+
case 'DCT':
|
|
742
|
+
case 'DCTDecode':
|
|
743
|
+
length = this.findDiscreteDecodeInlineStreamEnd(stream);
|
|
744
|
+
break;
|
|
745
|
+
case 'A85':
|
|
746
|
+
case 'ASCII85Decode':
|
|
747
|
+
length = this.findDecodeInlineStreamEnd(stream);
|
|
748
|
+
break;
|
|
749
|
+
case 'AHx':
|
|
750
|
+
case 'ASCIIHexDecode':
|
|
751
|
+
length = this.findHexDecodeInlineStreamEnd(stream);
|
|
752
|
+
break;
|
|
753
|
+
default:
|
|
754
|
+
length = this.findDefaultInlineStreamEnd(stream);
|
|
755
|
+
}
|
|
756
|
+
var imageStream = stream.makeSubStream(startPos, length, dictionary); // eslint-disable-line
|
|
757
|
+
var cacheKey;
|
|
758
|
+
if (length < maxCacheLength && dictLength < maxNumberLength) {
|
|
759
|
+
var imageBytes = imageStream.getBytes();
|
|
760
|
+
imageStream.reset();
|
|
761
|
+
var initialStreamPos = stream.position;
|
|
762
|
+
stream.position = lexicalOperator.beginInlineImagePosition;
|
|
763
|
+
var dictBytes = stream.getBytes(dictLength);
|
|
764
|
+
stream.position = initialStreamPos;
|
|
765
|
+
cacheKey = this._computeMaxNumber(imageBytes) + '_' + this._computeMaxNumber(dictBytes);
|
|
766
|
+
var cacheEntry = this.imageCache[cacheKey]; // eslint-disable-line
|
|
767
|
+
if (cacheEntry !== undefined) {
|
|
768
|
+
this.second = _PdfCommand.get('EI');
|
|
769
|
+
this.shift();
|
|
770
|
+
cacheEntry.reset();
|
|
771
|
+
return cacheEntry;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
if (cipherTransform) {
|
|
775
|
+
imageStream = cipherTransform.createStream(imageStream, length);
|
|
776
|
+
}
|
|
777
|
+
imageStream = this.filter(imageStream, dictionary, length);
|
|
778
|
+
imageStream.dictionary = dictionary;
|
|
779
|
+
if (cacheKey !== undefined) {
|
|
780
|
+
this.imageCache[cacheKey] = imageStream; // eslint-disable-line
|
|
781
|
+
}
|
|
782
|
+
this.second = _PdfCommand.get('EI');
|
|
783
|
+
this.shift();
|
|
784
|
+
return imageStream;
|
|
785
|
+
};
|
|
786
|
+
_PdfParser.prototype._computeMaxNumber = function (bytes) {
|
|
787
|
+
var bytesLength = bytes.length;
|
|
788
|
+
var a = 1;
|
|
789
|
+
var b = 0;
|
|
790
|
+
for (var i = 0; i < bytesLength; ++i) {
|
|
791
|
+
a += bytes[i] & 0xff; // eslint-disable-line
|
|
792
|
+
b += a;
|
|
793
|
+
}
|
|
794
|
+
return (b % 65521 << 16) | a % 65521;
|
|
795
|
+
};
|
|
796
|
+
_PdfParser.prototype.makeStream = function (dictionary, cipherTransform) {
|
|
797
|
+
var lexicalOperator = this.lexicalOperator;
|
|
798
|
+
var stream = lexicalOperator.stream; // eslint-disable-line
|
|
799
|
+
lexicalOperator.skipToNextLine();
|
|
800
|
+
var startPosition = stream.position - 1;
|
|
801
|
+
var length = dictionary.get('Length');
|
|
802
|
+
if (!Number.isInteger(length)) {
|
|
803
|
+
length = 0;
|
|
804
|
+
}
|
|
805
|
+
stream.position = startPosition + length;
|
|
806
|
+
lexicalOperator.nextChar();
|
|
807
|
+
if (this.tryShift() && _isCommand(this.second, 'endstream')) {
|
|
808
|
+
this.shift();
|
|
809
|
+
}
|
|
810
|
+
else {
|
|
811
|
+
var endStreamSignature = new Uint8Array([0x65, 0x6e, 0x64, 0x73, 0x74, 0x72, 0x65, 0x61, 0x6d]);
|
|
812
|
+
var actualLength = this._findStreamLength(startPosition, endStreamSignature);
|
|
813
|
+
if (actualLength < 0) {
|
|
814
|
+
var end = endStreamSignature.length - 1;
|
|
815
|
+
var truncatedSignature = endStreamSignature.slice(0, end);
|
|
816
|
+
var maybeLength = this._findStreamLength(startPosition, truncatedSignature);
|
|
817
|
+
if (maybeLength >= 0) {
|
|
818
|
+
var lastByte = stream.peekBytes(end + 1)[end]; // eslint-disable-line
|
|
819
|
+
if (_isWhiteSpace(lastByte)) {
|
|
820
|
+
actualLength = maybeLength;
|
|
821
|
+
}
|
|
822
|
+
}
|
|
823
|
+
if (actualLength < 0) {
|
|
824
|
+
throw new FormatError('Missing endstream command.');
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
length = actualLength;
|
|
828
|
+
lexicalOperator.nextChar();
|
|
829
|
+
this.shift();
|
|
830
|
+
this.shift();
|
|
831
|
+
}
|
|
832
|
+
this.shift();
|
|
833
|
+
stream = stream.makeSubStream(startPosition, length, dictionary);
|
|
834
|
+
if (cipherTransform) {
|
|
835
|
+
stream = cipherTransform.createStream(stream, length);
|
|
836
|
+
}
|
|
837
|
+
stream = this.filter(stream, dictionary, length);
|
|
838
|
+
stream.dictionary = dictionary;
|
|
839
|
+
return stream;
|
|
840
|
+
};
|
|
841
|
+
_PdfParser.prototype.filter = function (stream, dictionary, length) {
|
|
842
|
+
var filter = dictionary.get('F', 'Filter'); // eslint-disable-line
|
|
843
|
+
var params = dictionary.get('DP', 'DecodeParms'); // eslint-disable-line
|
|
844
|
+
if (filter instanceof _PdfName) {
|
|
845
|
+
return this.makeFilter(stream, filter.name, length, params);
|
|
846
|
+
}
|
|
847
|
+
var maybeLength = length;
|
|
848
|
+
if (Array.isArray(filter)) {
|
|
849
|
+
var filterArray = filter; // eslint-disable-line
|
|
850
|
+
var paramsArray = params; // eslint-disable-line
|
|
851
|
+
for (var i = 0; i < filterArray.length; ++i) {
|
|
852
|
+
var reference = filterArray[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
|
|
853
|
+
filter = reference instanceof _PdfReference ? this.xref._fetch(reference) : reference;
|
|
854
|
+
if (!(filter instanceof _PdfName)) {
|
|
855
|
+
throw new FormatError("Bad filter name '" + filter + "'");
|
|
856
|
+
}
|
|
857
|
+
params = null;
|
|
858
|
+
if (Array.isArray(paramsArray) && i in paramsArray) {
|
|
859
|
+
var ref = paramsArray[Number.parseInt(i.toString(), 10)]; // eslint-disable-line
|
|
860
|
+
params = ref instanceof _PdfReference ? this.xref._fetch(ref) : ref;
|
|
861
|
+
}
|
|
862
|
+
stream = this.makeFilter(stream, filter.name, maybeLength, params);
|
|
863
|
+
maybeLength = null;
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
return stream;
|
|
867
|
+
};
|
|
868
|
+
_PdfParser.prototype.makeFilter = function (stream, name, maybeLength, params) {
|
|
869
|
+
if (maybeLength === 0) {
|
|
870
|
+
return new _PdfNullStream();
|
|
871
|
+
}
|
|
872
|
+
try {
|
|
873
|
+
if (name === 'Fl' || name === 'FlateDecode') {
|
|
874
|
+
if (params) {
|
|
875
|
+
return new PdfPredictorStream(new _PdfFlateStream(stream, maybeLength), maybeLength, params);
|
|
876
|
+
}
|
|
877
|
+
return new _PdfFlateStream(stream, maybeLength);
|
|
878
|
+
}
|
|
879
|
+
return stream;
|
|
880
|
+
}
|
|
881
|
+
catch (ex) {
|
|
882
|
+
return new _PdfNullStream();
|
|
883
|
+
}
|
|
884
|
+
};
|
|
885
|
+
_PdfParser.prototype._findStreamLength = function (startPosition, signature) {
|
|
886
|
+
var stream = this.lexicalOperator.stream;
|
|
887
|
+
stream.position = startPosition;
|
|
888
|
+
var length = 2048;
|
|
889
|
+
var signatureLength = signature.length;
|
|
890
|
+
while (stream.position < stream.end) {
|
|
891
|
+
var scanBytes = stream.peekBytes(length);
|
|
892
|
+
var scanLength = scanBytes.length - signatureLength;
|
|
893
|
+
if (scanLength <= 0) {
|
|
894
|
+
break;
|
|
895
|
+
}
|
|
896
|
+
var position = 0;
|
|
897
|
+
while (position < scanLength) {
|
|
898
|
+
var j = 0;
|
|
899
|
+
while (j < signatureLength && scanBytes[position + j] === signature[j]) { // eslint-disable-line
|
|
900
|
+
j++;
|
|
901
|
+
}
|
|
902
|
+
if (j >= signatureLength) {
|
|
903
|
+
stream.position += position;
|
|
904
|
+
return stream.position - startPosition;
|
|
905
|
+
}
|
|
906
|
+
position++;
|
|
907
|
+
}
|
|
908
|
+
stream.position += scanLength;
|
|
909
|
+
}
|
|
910
|
+
return -1;
|
|
911
|
+
};
|
|
912
|
+
_PdfParser.prototype.findDefaultInlineStreamEnd = function (stream) {
|
|
913
|
+
var startPosition = stream.position;
|
|
914
|
+
var n = 10;
|
|
915
|
+
var state = 0;
|
|
916
|
+
var ch;
|
|
917
|
+
var endImagePosition;
|
|
918
|
+
ch = stream.getByte();
|
|
919
|
+
while (ch !== -1) {
|
|
920
|
+
if (state === 0) {
|
|
921
|
+
state = ch === 0x45 ? 1 : 0;
|
|
922
|
+
}
|
|
923
|
+
else if (state === 1) {
|
|
924
|
+
state = ch === 0x49 ? 2 : 0;
|
|
925
|
+
}
|
|
926
|
+
else {
|
|
927
|
+
if (state !== 2) {
|
|
928
|
+
throw new Error('findDefaultInlineStreamEnd - invalid state.');
|
|
929
|
+
}
|
|
930
|
+
if (ch === 0x20 || ch === 0xa || ch === 0xd) {
|
|
931
|
+
endImagePosition = stream.position;
|
|
932
|
+
var followingBytes = stream.peekBytes(n);
|
|
933
|
+
for (var i = 0, ii = followingBytes.length; i < ii; i++) {
|
|
934
|
+
ch = followingBytes[i]; // eslint-disable-line
|
|
935
|
+
if (ch === 0x0 && followingBytes[i + 1] !== 0x0) {
|
|
936
|
+
continue;
|
|
937
|
+
}
|
|
938
|
+
if (ch !== 0xa && ch !== 0xd && (ch < 0x20 || ch > 0x7f)) {
|
|
939
|
+
state = 0;
|
|
940
|
+
break;
|
|
941
|
+
}
|
|
942
|
+
}
|
|
943
|
+
if (state !== 2) {
|
|
944
|
+
ch = stream.getByte();
|
|
945
|
+
continue;
|
|
946
|
+
}
|
|
947
|
+
if (state === 2) {
|
|
948
|
+
break;
|
|
949
|
+
}
|
|
950
|
+
}
|
|
951
|
+
else {
|
|
952
|
+
state = 0;
|
|
953
|
+
}
|
|
954
|
+
}
|
|
955
|
+
ch = stream.getByte();
|
|
956
|
+
}
|
|
957
|
+
if (ch === -1) {
|
|
958
|
+
if (typeof endImagePosition !== 'undefined') {
|
|
959
|
+
stream.skip(-(stream.position - endImagePosition));
|
|
960
|
+
}
|
|
961
|
+
}
|
|
962
|
+
var endOffset = 4;
|
|
963
|
+
stream.skip(-endOffset);
|
|
964
|
+
ch = stream.peekByte();
|
|
965
|
+
stream.skip(endOffset);
|
|
966
|
+
if (!_isWhiteSpace(ch)) {
|
|
967
|
+
endOffset--;
|
|
968
|
+
}
|
|
969
|
+
return stream.position - endOffset - startPosition;
|
|
970
|
+
};
|
|
971
|
+
_PdfParser.prototype._checkEnd = function () {
|
|
972
|
+
if (this.first === endOfFile) {
|
|
973
|
+
return true;
|
|
974
|
+
}
|
|
975
|
+
else {
|
|
976
|
+
return false;
|
|
977
|
+
}
|
|
978
|
+
};
|
|
979
|
+
return _PdfParser;
|
|
980
|
+
}());
|
|
981
|
+
export { _PdfParser };
|
|
982
|
+
/* eslint-disable */
|
|
983
|
+
var _Linearization = /** @class */ (function () {
|
|
984
|
+
function _Linearization(stream) {
|
|
985
|
+
this.isValid = false;
|
|
986
|
+
var parser = new _PdfParser(new _PdfLexicalOperator(stream), null);
|
|
987
|
+
var obj1 = parser.getObject();
|
|
988
|
+
var obj2 = parser.getObject();
|
|
989
|
+
var obj3 = parser.getObject();
|
|
990
|
+
var dictionary = parser.getObject();
|
|
991
|
+
this.isValid = Number.isInteger(obj1) && Number.isInteger(obj2) && _isCommand(obj3, 'obj') && typeof dictionary !== 'undefined';
|
|
992
|
+
if (this.isValid) {
|
|
993
|
+
var obj = dictionary.get('Linearized');
|
|
994
|
+
this.isValid = typeof obj !== 'undefined' && obj > 0;
|
|
995
|
+
}
|
|
996
|
+
if (this.isValid) {
|
|
997
|
+
var length_1 = this.getInt(dictionary, 'L');
|
|
998
|
+
if (length_1 !== stream.length) {
|
|
999
|
+
throw new Error('The L parameter in the linearization dictionary ' + 'does not equal the stream length.');
|
|
1000
|
+
}
|
|
1001
|
+
this.length = length_1;
|
|
1002
|
+
this.hints = this.getHints(dictionary);
|
|
1003
|
+
this.objectNumberFirst = this.getInt(dictionary, 'O');
|
|
1004
|
+
this.endFirst = this.getInt(dictionary, 'E');
|
|
1005
|
+
this.pageCount = this.getInt(dictionary, 'N');
|
|
1006
|
+
this.mainXRefEntriesOffset = this.getInt(dictionary, 'T');
|
|
1007
|
+
this.pageFirst = dictionary.has('P') ? this.getInt(dictionary, 'P', true) : 0;
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
_Linearization.prototype.getInt = function (dictionary, name, allowZeroValue) {
|
|
1011
|
+
if (allowZeroValue === void 0) { allowZeroValue = false; }
|
|
1012
|
+
var obj = dictionary.get(name);
|
|
1013
|
+
if (typeof obj !== 'undefined' && Number.isInteger(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
|
|
1014
|
+
return obj;
|
|
1015
|
+
}
|
|
1016
|
+
throw new Error("The '" + name + "' parameter in the linearization " + 'dictionary is invalid.');
|
|
1017
|
+
};
|
|
1018
|
+
_Linearization.prototype.getHints = function (dictionary) {
|
|
1019
|
+
var hints = dictionary.getArray('H');
|
|
1020
|
+
var hintsLength = hints.length;
|
|
1021
|
+
if (hints && (hintsLength === 2 || hintsLength === 4)) {
|
|
1022
|
+
for (var index = 0; index < hintsLength; index++) {
|
|
1023
|
+
var hint = hints[index];
|
|
1024
|
+
if (!(Number.isInteger(hint) && hint > 0)) {
|
|
1025
|
+
throw new Error("Hint (" + index + ") in the linearization dictionary is invalid.");
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
return hints;
|
|
1029
|
+
}
|
|
1030
|
+
throw new Error('Hint array in the linearization dictionary is invalid.');
|
|
1031
|
+
};
|
|
1032
|
+
return _Linearization;
|
|
1033
|
+
}());
|
|
1034
|
+
export { _Linearization };
|
|
1035
|
+
/* eslint-enable */
|