@pdfme/pdf-lib 6.0.3 → 6.0.5-dev.1
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/{src/api/Embeddable.ts → dist/api/Embeddable.d.ts} +1 -1
- package/dist/api/PDFDocument.d.ts +778 -0
- package/dist/api/PDFDocumentOptions.d.ts +38 -0
- package/dist/api/PDFEmbeddedFile.d.ts +38 -0
- package/dist/api/PDFEmbeddedPage.d.ts +73 -0
- package/dist/api/PDFFont.d.ts +94 -0
- package/dist/api/PDFImage.d.ts +95 -0
- package/dist/api/PDFJavaScript.d.ts +38 -0
- package/dist/api/PDFPage.d.ts +910 -0
- package/dist/api/PDFPageOptions.d.ts +172 -0
- package/dist/api/StandardFonts.d.ts +16 -0
- package/dist/api/colors.d.ts +34 -0
- package/dist/api/errors.d.ts +42 -0
- package/dist/api/form/PDFButton.d.ts +137 -0
- package/dist/api/form/PDFCheckBox.d.ts +142 -0
- package/dist/api/form/PDFDropdown.d.ts +402 -0
- package/dist/api/form/PDFField.d.ts +203 -0
- package/dist/api/form/PDFForm.d.ts +411 -0
- package/dist/api/form/PDFOptionList.d.ts +335 -0
- package/dist/api/form/PDFRadioGroup.d.ts +252 -0
- package/dist/api/form/PDFSignature.d.ts +29 -0
- package/dist/api/form/PDFTextField.d.ts +537 -0
- package/dist/api/form/appearances.d.ts +41 -0
- package/dist/api/image/alignment.d.ts +5 -0
- package/dist/api/objects.d.ts +4 -0
- package/dist/api/operations.d.ts +226 -0
- package/dist/api/operators.d.ts +90 -0
- package/dist/api/rotations.d.ts +38 -0
- package/dist/api/sizes.d.ts +52 -0
- package/dist/api/svg.d.ts +70 -0
- package/dist/api/svgPath.d.ts +2 -0
- package/dist/api/text/alignment.d.ts +5 -0
- package/dist/api/text/layout.d.ts +54 -0
- package/dist/core/PDFContext.d.ts +84 -0
- package/dist/core/PDFObjectCopier.d.ts +37 -0
- package/dist/core/acroform/PDFAcroButton.d.ts +21 -0
- package/dist/core/acroform/PDFAcroCheckBox.d.ts +13 -0
- package/dist/core/acroform/PDFAcroChoice.d.ts +20 -0
- package/dist/core/acroform/PDFAcroComboBox.d.ts +9 -0
- package/dist/core/acroform/PDFAcroField.d.ts +36 -0
- package/dist/core/acroform/PDFAcroForm.d.ts +20 -0
- package/dist/core/acroform/PDFAcroListBox.d.ts +9 -0
- package/dist/core/acroform/PDFAcroNonTerminal.d.ts +13 -0
- package/dist/core/acroform/PDFAcroPushButton.d.ts +9 -0
- package/dist/core/acroform/PDFAcroRadioButton.d.ts +13 -0
- package/{src/core/acroform/PDFAcroSignature.ts → dist/core/acroform/PDFAcroSignature.d.ts} +2 -4
- package/dist/core/acroform/PDFAcroTerminal.d.ts +16 -0
- package/dist/core/acroform/PDFAcroText.d.ts +22 -0
- package/dist/core/acroform/flags.d.ts +141 -0
- package/dist/core/acroform/utils.d.ts +6 -0
- package/dist/core/annotation/AppearanceCharacteristics.d.ts +33 -0
- package/dist/core/annotation/BorderStyle.d.ts +11 -0
- package/dist/core/annotation/PDFAnnotation.d.ts +51 -0
- package/dist/core/annotation/PDFWidgetAnnotation.d.ts +26 -0
- package/dist/core/annotation/flags.d.ts +79 -0
- package/dist/core/crypto.d.ts +95 -0
- package/dist/core/document/PDFCrossRefSection.d.ts +27 -0
- package/dist/core/document/PDFHeader.d.ts +10 -0
- package/dist/core/document/PDFTrailer.d.ts +9 -0
- package/dist/core/document/PDFTrailerDict.d.ts +10 -0
- package/dist/core/embedders/CMap.d.ts +3 -0
- package/dist/core/embedders/CustomFontEmbedder.d.ts +44 -0
- package/dist/core/embedders/CustomFontSubsetEmbedder.d.ts +20 -0
- package/dist/core/embedders/FileEmbedder.d.ts +33 -0
- package/dist/core/embedders/FontFlags.d.ts +13 -0
- package/dist/core/embedders/JavaScriptEmbedder.d.ts +10 -0
- package/dist/core/embedders/JpegEmbedder.d.ts +23 -0
- package/dist/core/embedders/PDFPageEmbedder.d.ts +37 -0
- package/dist/core/embedders/PngEmbedder.d.ts +19 -0
- package/dist/core/embedders/StandardFontEmbedder.d.ts +36 -0
- package/dist/core/errors.d.ts +94 -0
- package/{src/core/index.ts → dist/core/index.d.ts} +1 -17
- package/dist/core/interactive/ViewerPreferences.d.ts +347 -0
- package/dist/core/objects/PDFArray.d.ts +63 -0
- package/dist/core/objects/PDFBool.d.ts +13 -0
- package/dist/core/objects/PDFDict.d.ts +62 -0
- package/dist/core/objects/PDFHexString.d.ts +16 -0
- package/dist/core/objects/PDFInvalidObject.d.ts +11 -0
- package/dist/core/objects/PDFName.d.ts +41 -0
- package/dist/core/objects/PDFNull.d.ts +10 -0
- package/dist/core/objects/PDFNumber.d.ts +15 -0
- package/dist/core/objects/PDFObject.d.ts +8 -0
- package/dist/core/objects/PDFRawStream.d.ts +16 -0
- package/dist/core/objects/PDFRef.d.ts +13 -0
- package/dist/core/objects/PDFStream.d.ts +16 -0
- package/dist/core/objects/PDFString.d.ts +16 -0
- package/dist/core/operators/PDFOperator.d.ts +19 -0
- package/dist/core/operators/PDFOperatorNames.d.ts +76 -0
- package/dist/core/parser/BaseParser.d.ts +14 -0
- package/dist/core/parser/ByteStream.d.ts +26 -0
- package/dist/core/parser/PDFObjectParser.d.ts +31 -0
- package/dist/core/parser/PDFObjectStreamParser.d.ts +13 -0
- package/dist/core/parser/PDFParser.d.ts +46 -0
- package/dist/core/parser/PDFXRefStreamParser.d.ts +21 -0
- package/dist/core/streams/Ascii85Stream.d.ts +9 -0
- package/dist/core/streams/AsciiHexStream.d.ts +9 -0
- package/dist/core/streams/DecodeStream.d.ts +26 -0
- package/dist/core/streams/DecryptStream.d.ts +12 -0
- package/dist/core/streams/FlateStream.d.ts +13 -0
- package/dist/core/streams/LZWStream.d.ts +12 -0
- package/dist/core/streams/RunLengthStream.d.ts +8 -0
- package/dist/core/streams/Stream.d.ts +34 -0
- package/dist/core/streams/decode.d.ts +3 -0
- package/dist/core/structures/PDFCatalog.d.ts +27 -0
- package/dist/core/structures/PDFContentStream.d.ts +15 -0
- package/dist/core/structures/PDFCrossRefStream.d.ts +53 -0
- package/dist/core/structures/PDFFlateStream.d.ts +13 -0
- package/dist/core/structures/PDFObjectStream.d.ts +20 -0
- package/dist/core/structures/PDFPageLeaf.d.ts +54 -0
- package/dist/core/structures/PDFPageTree.d.ts +41 -0
- package/dist/core/syntax/CharCodes.d.ts +61 -0
- package/dist/core/syntax/Delimiters.d.ts +1 -0
- package/dist/core/syntax/Irregular.d.ts +1 -0
- package/dist/core/syntax/Keywords.d.ts +22 -0
- package/dist/core/syntax/Numeric.d.ts +3 -0
- package/dist/core/syntax/Whitespace.d.ts +1 -0
- package/dist/core/writers/PDFStreamWriter.d.ts +19 -0
- package/dist/core/writers/PDFWriter.d.ts +29 -0
- package/dist/index.js +19124 -0
- package/dist/index.js.map +1 -0
- package/dist/types/fontkit.d.ts +597 -0
- package/{src/types/index.ts → dist/types/index.d.ts} +8 -13
- package/{src/types/matrix.ts → dist/types/matrix.d.ts} +1 -2
- package/dist/utils/Cache.d.ts +10 -0
- package/dist/utils/arrays.d.ts +16 -0
- package/dist/utils/async.d.ts +5 -0
- package/dist/utils/base64.d.ts +10 -0
- package/dist/utils/elements/Arc.d.ts +22 -0
- package/dist/utils/elements/Circle.d.ts +14 -0
- package/dist/utils/elements/Ellipse.d.ts +20 -0
- package/dist/utils/elements/GraphElement.d.ts +6 -0
- package/dist/utils/elements/Line.d.ts +23 -0
- package/dist/utils/elements/Plot.d.ts +11 -0
- package/dist/utils/elements/Point.d.ts +18 -0
- package/dist/utils/elements/Rectangle.d.ts +21 -0
- package/dist/utils/elements/Segment.d.ts +19 -0
- package/dist/utils/errors.d.ts +1 -0
- package/dist/utils/intersections.d.ts +9 -0
- package/dist/utils/maths.d.ts +45 -0
- package/dist/utils/numbers.d.ts +23 -0
- package/dist/utils/objects.d.ts +15 -0
- package/dist/utils/pdfDocEncoding.d.ts +7 -0
- package/dist/utils/png.d.ts +17 -0
- package/dist/utils/rng.d.ts +13 -0
- package/dist/utils/strings.d.ts +25 -0
- package/{src/utils/unicode.ts → dist/utils/unicode.d.ts} +8 -195
- package/dist/utils/validators.d.ts +26 -0
- package/package.json +6 -1
- package/__tests__/api/PDFDocument.spec.ts +0 -576
- package/__tests__/api/PDFImage.spec.ts +0 -60
- package/__tests__/api/PDFPage.spec.ts +0 -151
- package/__tests__/api/form/PDFCheckBox.spec.ts +0 -71
- package/__tests__/api/form/PDFDropdown.spec.ts +0 -118
- package/__tests__/api/form/PDFForm.spec.ts +0 -370
- package/__tests__/api/form/PDFOptionList.spec.ts +0 -104
- package/__tests__/api/form/PDFRadioGroup.spec.ts +0 -183
- package/__tests__/api/form/PDFTextField.spec.ts +0 -148
- package/__tests__/api/svgPath.spec.ts +0 -153
- package/__tests__/api/text/layout.spec.ts +0 -166
- package/__tests__/core/PDFContext.spec.ts +0 -194
- package/__tests__/core/PDFObjectCopier.spec.ts +0 -421
- package/__tests__/core/acroform/PDFAcroField.spec.ts +0 -98
- package/__tests__/core/acroform/PDFAcroTerminal.spec.ts +0 -39
- package/__tests__/core/annotation/PDFWidgetAnnotation.spec.ts +0 -40
- package/__tests__/core/document/PDFCrossRefSection.spec.ts +0 -88
- package/__tests__/core/document/PDFHeader.spec.ts +0 -22
- package/__tests__/core/document/PDFTrailer.spec.ts +0 -28
- package/__tests__/core/document/PDFTrailerDict.spec.ts +0 -24
- package/__tests__/core/embedders/CMap.spec.ts +0 -47
- package/__tests__/core/embedders/CustomFontEmbedder.spec.ts +0 -96
- package/__tests__/core/embedders/CustomFontSubsetEmbedder.spec.ts +0 -62
- package/__tests__/core/embedders/FileEmbedder.spec.ts +0 -54
- package/__tests__/core/embedders/JpegEmbedder.spec.ts +0 -67
- package/__tests__/core/embedders/PDFPageEmbedder.spec.ts +0 -65
- package/__tests__/core/embedders/PngEmbedder.spec.ts +0 -87
- package/__tests__/core/embedders/StandardFontEmbedder.spec.ts +0 -79
- package/__tests__/core/embedders/data/SourceHanSerifJP-Regular.otf.cmap +0 -16096
- package/__tests__/core/embedders/data/Ubuntu-R.ttf.cmap +0 -1211
- package/__tests__/core/objects/PDFArray.spec.ts +0 -134
- package/__tests__/core/objects/PDFBool.spec.ts +0 -42
- package/__tests__/core/objects/PDFDict.spec.ts +0 -195
- package/__tests__/core/objects/PDFHexString.spec.ts +0 -168
- package/__tests__/core/objects/PDFInvalidObject.spec.ts +0 -32
- package/__tests__/core/objects/PDFName.spec.ts +0 -122
- package/__tests__/core/objects/PDFNull.spec.ts +0 -30
- package/__tests__/core/objects/PDFNumber.spec.ts +0 -50
- package/__tests__/core/objects/PDFObject.spec.ts +0 -29
- package/__tests__/core/objects/PDFRawStream.spec.ts +0 -45
- package/__tests__/core/objects/PDFRef.spec.ts +0 -60
- package/__tests__/core/objects/PDFString.spec.ts +0 -237
- package/__tests__/core/operators/PDFOperator.spec.ts +0 -77
- package/__tests__/core/parser/PDFObjectParser.spec.ts +0 -730
- package/__tests__/core/parser/PDFObjectStreamParser.spec.ts +0 -158
- package/__tests__/core/parser/PDFParser.spec.ts +0 -398
- package/__tests__/core/parser/PDFXRefStreamParser.spec.ts +0 -187
- package/__tests__/core/parser/data/object-stream-invalid +0 -2
- package/__tests__/core/parser/data/object-stream1 +0 -16
- package/__tests__/core/parser/data/object-stream2 +0 -10
- package/__tests__/core/parser/data/object-stream3 +0 -0
- package/__tests__/core/parser/data/object-stream4 +0 -0
- package/__tests__/core/parser/data/xref-stream1 +0 -0
- package/__tests__/core/parser/data/xref-stream2 +0 -0
- package/__tests__/core/parser/data/xref-stream3 +0 -0
- package/__tests__/core/parser/data/xref-stream4 +0 -0
- package/__tests__/core/streams/Ascii85Stream.spec.ts +0 -20
- package/__tests__/core/streams/AsciiHexStream.spec.ts +0 -20
- package/__tests__/core/streams/FlateStream.spec.ts +0 -20
- package/__tests__/core/streams/LZWStream.spec.ts +0 -20
- package/__tests__/core/streams/RunLengthStream.spec.ts +0 -20
- package/__tests__/core/streams/Stream.spec.ts +0 -128
- package/__tests__/core/streams/data/ascii85/1.decoded +0 -0
- package/__tests__/core/streams/data/ascii85/1.encoded +0 -43
- package/__tests__/core/streams/data/asciihex/1.decoded +0 -1
- package/__tests__/core/streams/data/asciihex/1.encoded +0 -1
- package/__tests__/core/streams/data/asciihex/2.decoded +0 -7
- package/__tests__/core/streams/data/asciihex/2.encoded +0 -1
- package/__tests__/core/streams/data/flate/1.corrupt.encoded +0 -1
- package/__tests__/core/streams/data/flate/1.decoded +0 -0
- package/__tests__/core/streams/data/flate/1.encoded +0 -2
- package/__tests__/core/streams/data/flate/2.decoded +0 -33
- package/__tests__/core/streams/data/flate/2.encoded +0 -0
- package/__tests__/core/streams/data/flate/3.decoded +0 -15
- package/__tests__/core/streams/data/flate/3.encoded +0 -0
- package/__tests__/core/streams/data/flate/4.decoded +0 -16
- package/__tests__/core/streams/data/flate/4.encoded +0 -0
- package/__tests__/core/streams/data/flate/5.decoded +0 -0
- package/__tests__/core/streams/data/flate/5.encoded +0 -0
- package/__tests__/core/streams/data/flate/6.decoded +0 -17
- package/__tests__/core/streams/data/flate/6.encoded +0 -0
- package/__tests__/core/streams/data/flate/7.decoded +0 -20
- package/__tests__/core/streams/data/flate/7.encoded +0 -1
- package/__tests__/core/streams/data/lzw/1.decoded +0 -0
- package/__tests__/core/streams/data/lzw/1.encoded +0 -0
- package/__tests__/core/streams/data/lzw/2.decoded +0 -0
- package/__tests__/core/streams/data/lzw/2.encoded +0 -0
- package/__tests__/core/streams/data/lzw/3.decoded +0 -14
- package/__tests__/core/streams/data/lzw/3.encoded +0 -2
- package/__tests__/core/streams/data/lzw/4.decoded +0 -14
- package/__tests__/core/streams/data/lzw/4.encoded +0 -2
- package/__tests__/core/streams/data/runlength/1.decoded +0 -1
- package/__tests__/core/streams/data/runlength/1.encoded +0 -1
- package/__tests__/core/streams/data/runlength/2.decoded +0 -1
- package/__tests__/core/streams/data/runlength/2.encoded +0 -1
- package/__tests__/core/streams/data/runlength/3.decoded +0 -0
- package/__tests__/core/streams/data/runlength/3.encoded +0 -0
- package/__tests__/core/streams/data/runlength/4.decoded +0 -1
- package/__tests__/core/streams/data/runlength/4.encoded +0 -1
- package/__tests__/core/streams/data/runlength/5.decoded +0 -1
- package/__tests__/core/streams/data/runlength/5.encoded +0 -1
- package/__tests__/core/streams/data/runlength/empty.encoded +0 -1
- package/__tests__/core/structures/PDFCatalog.spec.ts +0 -108
- package/__tests__/core/structures/PDFContentStream.spec.ts +0 -117
- package/__tests__/core/structures/PDFCrossRefStream.spec.ts +0 -145
- package/__tests__/core/structures/PDFObjectStream.spec.ts +0 -138
- package/__tests__/core/structures/PDFPageLeaf.spec.ts +0 -355
- package/__tests__/core/structures/PDFPageTree.spec.ts +0 -592
- package/__tests__/core/writers/PDFStreamWriter.spec.ts +0 -71
- package/__tests__/core/writers/PDFWriter.spec.ts +0 -144
- package/__tests__/core/writers/data/stream-writer-1.pdf +0 -0
- package/__tests__/index.test.ts +0 -12
- package/__tests__/utils/base64.spec.ts +0 -61
- package/__tests__/utils/data/simple.pdf +0 -201
- package/__tests__/utils/data/simple.pdf.base64 +0 -1
- package/__tests__/utils/pdfDocEncoding.spec.ts +0 -82
- package/__tests__/utils/png.spec.ts +0 -53
- package/__tests__/utils/rng.spec.ts +0 -14
- package/__tests__/utils/strings.spec.ts +0 -98
- package/__tests__/utils/unicode.spec.ts +0 -337
- package/assets/fonts/source_hans_jp/SourceHanSerifJP-Regular.otf +0 -0
- package/assets/fonts/ubuntu/Ubuntu-B.ttf +0 -0
- package/assets/fonts/ubuntu/Ubuntu-R.ttf +0 -0
- package/assets/images/cat_riding_unicorn.jpg +0 -0
- package/assets/images/cmyk_colorspace.jpg +0 -0
- package/assets/images/greyscale_bird.png +0 -0
- package/assets/images/minions_banana_alpha.png +0 -0
- package/assets/images/minions_banana_no_alpha.png +0 -0
- package/assets/images/minions_laughing.jpg +0 -0
- package/assets/pdfs/bixby_guide.pdf +0 -0
- package/assets/pdfs/encrypted_new.pdf +0 -0
- package/assets/pdfs/encrypted_old.pdf +0 -0
- package/assets/pdfs/fancy_fields.pdf +0 -0
- package/assets/pdfs/giraffe.pdf +0 -0
- package/assets/pdfs/invalid_root_ref.pdf +0 -0
- package/assets/pdfs/just_metadata.pdf +0 -49
- package/assets/pdfs/missing_endobj_keyword.pdf +0 -70
- package/assets/pdfs/missing_xref_trailer_dict.pdf +0 -141
- package/assets/pdfs/normal.pdf +0 -0
- package/assets/pdfs/pdf20examples/PDF 2.0 with offset start.pdf +0 -179
- package/assets/pdfs/stuff_following_header.pdf +0 -0
- package/assets/pdfs/us_constitution.pdf +0 -0
- package/assets/pdfs/with_comments.pdf +0 -0
- package/assets/pdfs/with_invalid_objects.pdf +0 -53
- package/assets/pdfs/with_invalid_stream_EOL.pdf +0 -0
- package/assets/pdfs/with_null_parent_entry.pdf +0 -0
- package/assets/pdfs/with_signature.pdf +0 -0
- package/assets/pdfs/with_update_sections.pdf +0 -0
- package/assets/pdfs/with_viewer_prefs.pdf +0 -0
- package/assets/pdfs/with_xfa_fields.pdf +0 -0
- package/src/api/PDFDocument.ts +0 -1389
- package/src/api/PDFDocumentOptions.ts +0 -45
- package/src/api/PDFEmbeddedFile.ts +0 -87
- package/src/api/PDFEmbeddedPage.ts +0 -100
- package/src/api/PDFFont.ts +0 -149
- package/src/api/PDFImage.ts +0 -143
- package/src/api/PDFJavaScript.ts +0 -75
- package/src/api/PDFPage.ts +0 -1604
- package/src/api/PDFPageOptions.ts +0 -175
- package/src/api/StandardFonts.ts +0 -16
- package/src/api/colors.ts +0 -109
- package/src/api/errors.ts +0 -110
- package/src/api/form/PDFButton.ts +0 -242
- package/src/api/form/PDFCheckBox.ts +0 -247
- package/src/api/form/PDFDropdown.ts +0 -637
- package/src/api/form/PDFField.ts +0 -491
- package/src/api/form/PDFForm.ts +0 -842
- package/src/api/form/PDFOptionList.ts +0 -555
- package/src/api/form/PDFRadioGroup.ts +0 -455
- package/src/api/form/PDFSignature.ts +0 -44
- package/src/api/form/PDFTextField.ts +0 -811
- package/src/api/form/appearances.ts +0 -655
- package/src/api/image/alignment.ts +0 -5
- package/src/api/objects.ts +0 -10
- package/src/api/operations.ts +0 -873
- package/src/api/operators.ts +0 -335
- package/src/api/rotations.ts +0 -84
- package/src/api/sizes.ts +0 -52
- package/src/api/svg.ts +0 -888
- package/src/api/svgPath.ts +0 -460
- package/src/api/text/alignment.ts +0 -5
- package/src/api/text/layout.ts +0 -328
- package/src/core/PDFContext.ts +0 -274
- package/src/core/PDFObjectCopier.ts +0 -142
- package/src/core/acroform/PDFAcroButton.ts +0 -104
- package/src/core/acroform/PDFAcroCheckBox.ts +0 -48
- package/src/core/acroform/PDFAcroChoice.ts +0 -143
- package/src/core/acroform/PDFAcroComboBox.ts +0 -21
- package/src/core/acroform/PDFAcroField.ts +0 -168
- package/src/core/acroform/PDFAcroForm.ts +0 -96
- package/src/core/acroform/PDFAcroListBox.ts +0 -19
- package/src/core/acroform/PDFAcroNonTerminal.ts +0 -33
- package/src/core/acroform/PDFAcroPushButton.ts +0 -21
- package/src/core/acroform/PDFAcroRadioButton.ts +0 -57
- package/src/core/acroform/PDFAcroTerminal.ts +0 -70
- package/src/core/acroform/PDFAcroText.ts +0 -76
- package/src/core/acroform/flags.ts +0 -162
- package/src/core/acroform/utils.ts +0 -129
- package/src/core/annotation/AppearanceCharacteristics.ts +0 -133
- package/src/core/annotation/BorderStyle.ts +0 -31
- package/src/core/annotation/PDFAnnotation.ts +0 -148
- package/src/core/annotation/PDFWidgetAnnotation.ts +0 -111
- package/src/core/annotation/flags.ts +0 -90
- package/src/core/crypto.ts +0 -1844
- package/src/core/document/PDFCrossRefSection.ts +0 -161
- package/src/core/document/PDFHeader.ts +0 -48
- package/src/core/document/PDFTrailer.ts +0 -48
- package/src/core/document/PDFTrailerDict.ts +0 -39
- package/src/core/embedders/CMap.ts +0 -65
- package/src/core/embedders/CustomFontEmbedder.ts +0 -237
- package/src/core/embedders/CustomFontSubsetEmbedder.ts +0 -89
- package/src/core/embedders/FileEmbedder.ts +0 -77
- package/src/core/embedders/FontFlags.ts +0 -45
- package/src/core/embedders/JavaScriptEmbedder.ts +0 -34
- package/src/core/embedders/JpegEmbedder.ts +0 -118
- package/src/core/embedders/PDFPageEmbedder.ts +0 -139
- package/src/core/embedders/PngEmbedder.ts +0 -69
- package/src/core/embedders/StandardFontEmbedder.ts +0 -121
- package/src/core/errors.ts +0 -226
- package/src/core/interactive/ViewerPreferences.ts +0 -565
- package/src/core/objects/PDFArray.ts +0 -179
- package/src/core/objects/PDFBool.ts +0 -53
- package/src/core/objects/PDFDict.ts +0 -220
- package/src/core/objects/PDFHexString.ts +0 -94
- package/src/core/objects/PDFInvalidObject.ts +0 -34
- package/src/core/objects/PDFName.ts +0 -152
- package/src/core/objects/PDFNull.ts +0 -30
- package/src/core/objects/PDFNumber.ts +0 -44
- package/src/core/objects/PDFObject.ts +0 -22
- package/src/core/objects/PDFRawStream.ts +0 -41
- package/src/core/objects/PDFRef.ts +0 -51
- package/src/core/objects/PDFStream.ts +0 -87
- package/src/core/objects/PDFString.ts +0 -118
- package/src/core/operators/PDFOperator.ts +0 -72
- package/src/core/operators/PDFOperatorNames.ts +0 -92
- package/src/core/parser/BaseParser.ts +0 -119
- package/src/core/parser/ByteStream.ts +0 -76
- package/src/core/parser/PDFObjectParser.ts +0 -302
- package/src/core/parser/PDFObjectStreamParser.ts +0 -65
- package/src/core/parser/PDFParser.ts +0 -363
- package/src/core/parser/PDFXRefStreamParser.ts +0 -129
- package/src/core/streams/Ascii85Stream.ts +0 -97
- package/src/core/streams/AsciiHexStream.ts +0 -77
- package/src/core/streams/DecodeStream.ts +0 -188
- package/src/core/streams/DecryptStream.ts +0 -49
- package/src/core/streams/FlateStream.ts +0 -397
- package/src/core/streams/LZWStream.ts +0 -157
- package/src/core/streams/RunLengthStream.ts +0 -55
- package/src/core/streams/Stream.ts +0 -126
- package/src/core/streams/decode.ts +0 -70
- package/src/core/structures/PDFCatalog.ts +0 -81
- package/src/core/structures/PDFContentStream.ts +0 -58
- package/src/core/structures/PDFCrossRefStream.ts +0 -238
- package/src/core/structures/PDFFlateStream.ts +0 -40
- package/src/core/structures/PDFObjectStream.ts +0 -91
- package/src/core/structures/PDFPageLeaf.ts +0 -244
- package/src/core/structures/PDFPageTree.ts +0 -192
- package/src/core/syntax/CharCodes.ts +0 -62
- package/src/core/syntax/Delimiters.ts +0 -14
- package/src/core/syntax/Irregular.ts +0 -10
- package/src/core/syntax/Keywords.ts +0 -57
- package/src/core/syntax/Numeric.ts +0 -26
- package/src/core/syntax/Whitespace.ts +0 -10
- package/src/core/writers/PDFStreamWriter.ts +0 -114
- package/src/core/writers/PDFWriter.ts +0 -146
- package/src/types/fontkit.ts +0 -643
- package/src/utils/Cache.ts +0 -26
- package/src/utils/arrays.ts +0 -153
- package/src/utils/async.ts +0 -8
- package/src/utils/base64.ts +0 -98
- package/src/utils/elements/Arc.ts +0 -97
- package/src/utils/elements/Circle.ts +0 -47
- package/src/utils/elements/Ellipse.ts +0 -117
- package/src/utils/elements/GraphElement.ts +0 -14
- package/src/utils/elements/Line.ts +0 -83
- package/src/utils/elements/Plot.ts +0 -50
- package/src/utils/elements/Point.ts +0 -37
- package/src/utils/elements/Rectangle.ts +0 -65
- package/src/utils/elements/Segment.ts +0 -81
- package/src/utils/errors.ts +0 -3
- package/src/utils/intersections.ts +0 -237
- package/src/utils/maths.ts +0 -96
- package/src/utils/numbers.ts +0 -55
- package/src/utils/objects.ts +0 -13
- package/src/utils/pdfDocEncoding.ts +0 -69
- package/src/utils/png.ts +0 -100
- package/src/utils/rng.ts +0 -21
- package/src/utils/strings.ts +0 -191
- package/src/utils/validators.ts +0 -192
- package/tsconfig.build.json +0 -14
- package/tsconfig.json +0 -15
- package/vite.config.mts +0 -39
- /package/{src/api/form/index.ts → dist/api/form/index.d.ts} +0 -0
- /package/{src/api/image/index.ts → dist/api/image/index.d.ts} +0 -0
- /package/{src/api/index.ts → dist/api/index.d.ts} +0 -0
- /package/{src/api/text/index.ts → dist/api/text/index.d.ts} +0 -0
- /package/{src/core/acroform/index.ts → dist/core/acroform/index.d.ts} +0 -0
- /package/{src/core/annotation/index.ts → dist/core/annotation/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/utils/elements/index.ts → dist/utils/elements/index.d.ts} +0 -0
- /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2012 Mozilla Foundation
|
|
3
|
-
*
|
|
4
|
-
* The LZWStream class contained in this file is a TypeScript port of the
|
|
5
|
-
* JavaScript LZWStream class in Mozilla's pdf.js project, made available
|
|
6
|
-
* under the Apache 2.0 open source license.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import DecodeStream from './DecodeStream';
|
|
10
|
-
import { StreamType } from './Stream';
|
|
11
|
-
|
|
12
|
-
class LZWStream extends DecodeStream {
|
|
13
|
-
private stream: StreamType;
|
|
14
|
-
private cachedData: number;
|
|
15
|
-
private bitsCached: number;
|
|
16
|
-
private lzwState?: {
|
|
17
|
-
earlyChange: 0 | 1;
|
|
18
|
-
codeLength: number;
|
|
19
|
-
nextCode: number;
|
|
20
|
-
dictionaryValues: Uint8Array;
|
|
21
|
-
dictionaryLengths: Uint16Array;
|
|
22
|
-
dictionaryPrevCodes: Uint16Array;
|
|
23
|
-
currentSequence: Uint8Array;
|
|
24
|
-
currentSequenceLength: number;
|
|
25
|
-
prevCode?: number | null;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
constructor(stream: StreamType, maybeLength: number | undefined, earlyChange: 0 | 1) {
|
|
29
|
-
super(maybeLength);
|
|
30
|
-
|
|
31
|
-
this.stream = stream;
|
|
32
|
-
this.cachedData = 0;
|
|
33
|
-
this.bitsCached = 0;
|
|
34
|
-
|
|
35
|
-
const maxLzwDictionarySize = 4096;
|
|
36
|
-
const lzwState = {
|
|
37
|
-
earlyChange,
|
|
38
|
-
codeLength: 9,
|
|
39
|
-
nextCode: 258,
|
|
40
|
-
dictionaryValues: new Uint8Array(maxLzwDictionarySize),
|
|
41
|
-
dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
|
|
42
|
-
dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
|
|
43
|
-
currentSequence: new Uint8Array(maxLzwDictionarySize),
|
|
44
|
-
currentSequenceLength: 0,
|
|
45
|
-
};
|
|
46
|
-
for (let i = 0; i < 256; ++i) {
|
|
47
|
-
lzwState.dictionaryValues[i] = i;
|
|
48
|
-
lzwState.dictionaryLengths[i] = 1;
|
|
49
|
-
}
|
|
50
|
-
this.lzwState = lzwState;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
protected readBlock() {
|
|
54
|
-
const blockSize = 512;
|
|
55
|
-
|
|
56
|
-
let estimatedDecodedSize = blockSize * 2;
|
|
57
|
-
const decodedSizeDelta = blockSize;
|
|
58
|
-
let i;
|
|
59
|
-
let j;
|
|
60
|
-
let q;
|
|
61
|
-
|
|
62
|
-
const lzwState = this.lzwState;
|
|
63
|
-
if (!lzwState) {
|
|
64
|
-
return; // eof was found
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const earlyChange = lzwState.earlyChange;
|
|
68
|
-
let nextCode = lzwState.nextCode;
|
|
69
|
-
const dictionaryValues = lzwState.dictionaryValues;
|
|
70
|
-
const dictionaryLengths = lzwState.dictionaryLengths;
|
|
71
|
-
const dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
|
|
72
|
-
let codeLength = lzwState.codeLength;
|
|
73
|
-
let prevCode = lzwState.prevCode;
|
|
74
|
-
const currentSequence = lzwState.currentSequence;
|
|
75
|
-
let currentSequenceLength = lzwState.currentSequenceLength;
|
|
76
|
-
|
|
77
|
-
let decodedLength = 0;
|
|
78
|
-
let currentBufferLength = this.bufferLength;
|
|
79
|
-
let buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
|
|
80
|
-
|
|
81
|
-
for (i = 0; i < blockSize; i++) {
|
|
82
|
-
const code = this.readBits(codeLength);
|
|
83
|
-
const hasPrev = currentSequenceLength > 0;
|
|
84
|
-
if (!code || code < 256) {
|
|
85
|
-
currentSequence[0] = code as number;
|
|
86
|
-
currentSequenceLength = 1;
|
|
87
|
-
} else if (code >= 258) {
|
|
88
|
-
if (code < nextCode) {
|
|
89
|
-
currentSequenceLength = dictionaryLengths[code];
|
|
90
|
-
for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
|
|
91
|
-
currentSequence[j] = dictionaryValues[q];
|
|
92
|
-
q = dictionaryPrevCodes[q];
|
|
93
|
-
}
|
|
94
|
-
} else {
|
|
95
|
-
currentSequence[currentSequenceLength++] = currentSequence[0];
|
|
96
|
-
}
|
|
97
|
-
} else if (code === 256) {
|
|
98
|
-
codeLength = 9;
|
|
99
|
-
nextCode = 258;
|
|
100
|
-
currentSequenceLength = 0;
|
|
101
|
-
continue;
|
|
102
|
-
} else {
|
|
103
|
-
this.eof = true;
|
|
104
|
-
delete this.lzwState;
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
if (hasPrev) {
|
|
109
|
-
dictionaryPrevCodes[nextCode] = prevCode as number;
|
|
110
|
-
dictionaryLengths[nextCode] = dictionaryLengths[prevCode as number] + 1;
|
|
111
|
-
dictionaryValues[nextCode] = currentSequence[0];
|
|
112
|
-
nextCode++;
|
|
113
|
-
codeLength =
|
|
114
|
-
(nextCode + earlyChange) & (nextCode + earlyChange - 1)
|
|
115
|
-
? codeLength
|
|
116
|
-
: Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
|
|
117
|
-
}
|
|
118
|
-
prevCode = code;
|
|
119
|
-
|
|
120
|
-
decodedLength += currentSequenceLength;
|
|
121
|
-
if (estimatedDecodedSize < decodedLength) {
|
|
122
|
-
do {
|
|
123
|
-
estimatedDecodedSize += decodedSizeDelta;
|
|
124
|
-
} while (estimatedDecodedSize < decodedLength);
|
|
125
|
-
buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
|
|
126
|
-
}
|
|
127
|
-
for (j = 0; j < currentSequenceLength; j++) {
|
|
128
|
-
buffer[currentBufferLength++] = currentSequence[j];
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
lzwState.nextCode = nextCode;
|
|
132
|
-
lzwState.codeLength = codeLength;
|
|
133
|
-
lzwState.prevCode = prevCode;
|
|
134
|
-
lzwState.currentSequenceLength = currentSequenceLength;
|
|
135
|
-
|
|
136
|
-
this.bufferLength = currentBufferLength;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
private readBits(n: number) {
|
|
140
|
-
let bitsCached = this.bitsCached;
|
|
141
|
-
let cachedData = this.cachedData;
|
|
142
|
-
while (bitsCached < n) {
|
|
143
|
-
const c = this.stream.getByte();
|
|
144
|
-
if (c === -1) {
|
|
145
|
-
this.eof = true;
|
|
146
|
-
return null;
|
|
147
|
-
}
|
|
148
|
-
cachedData = (cachedData << 8) | c;
|
|
149
|
-
bitsCached += 8;
|
|
150
|
-
}
|
|
151
|
-
this.bitsCached = bitsCached -= n;
|
|
152
|
-
this.cachedData = cachedData;
|
|
153
|
-
return (cachedData >>> bitsCached) & ((1 << n) - 1);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
export default LZWStream;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2012 Mozilla Foundation
|
|
3
|
-
*
|
|
4
|
-
* The RunLengthStream class contained in this file is a TypeScript port of the
|
|
5
|
-
* JavaScript RunLengthStream class in Mozilla's pdf.js project, made available
|
|
6
|
-
* under the Apache 2.0 open source license.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import DecodeStream from './DecodeStream';
|
|
10
|
-
import { StreamType } from './Stream';
|
|
11
|
-
|
|
12
|
-
class RunLengthStream extends DecodeStream {
|
|
13
|
-
private stream: StreamType;
|
|
14
|
-
|
|
15
|
-
constructor(stream: StreamType, maybeLength?: number) {
|
|
16
|
-
super(maybeLength);
|
|
17
|
-
this.stream = stream;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
protected readBlock() {
|
|
21
|
-
// The repeatHeader has following format. The first byte defines type of run
|
|
22
|
-
// and amount of bytes to repeat/copy: n = 0 through 127 - copy next n bytes
|
|
23
|
-
// (in addition to the second byte from the header), n = 129 through 255 -
|
|
24
|
-
// duplicate the second byte from the header (257 - n) times, n = 128 - end.
|
|
25
|
-
const repeatHeader = this.stream.getBytes(2);
|
|
26
|
-
if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
|
|
27
|
-
this.eof = true;
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
let buffer;
|
|
32
|
-
let bufferLength = this.bufferLength;
|
|
33
|
-
let n = repeatHeader[0];
|
|
34
|
-
if (n < 128) {
|
|
35
|
-
// copy n bytes
|
|
36
|
-
buffer = this.ensureBuffer(bufferLength + n + 1);
|
|
37
|
-
buffer[bufferLength++] = repeatHeader[1];
|
|
38
|
-
if (n > 0) {
|
|
39
|
-
const source = this.stream.getBytes(n);
|
|
40
|
-
buffer.set(source, bufferLength);
|
|
41
|
-
bufferLength += n;
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
n = 257 - n;
|
|
45
|
-
const b = repeatHeader[1];
|
|
46
|
-
buffer = this.ensureBuffer(bufferLength + n + 1);
|
|
47
|
-
for (let i = 0; i < n; i++) {
|
|
48
|
-
buffer[bufferLength++] = b;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
this.bufferLength = bufferLength;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default RunLengthStream;
|
|
@@ -1,126 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* Copyright 2012 Mozilla Foundation
|
|
3
|
-
*
|
|
4
|
-
* The Stream class contained in this file is a TypeScript port of the
|
|
5
|
-
* JavaScript Stream class in Mozilla's pdf.js project, made available
|
|
6
|
-
* under the Apache 2.0 open source license.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
export interface StreamType {
|
|
10
|
-
isEmpty: boolean;
|
|
11
|
-
getByte(): number;
|
|
12
|
-
getUint16(): number;
|
|
13
|
-
getInt32(): number;
|
|
14
|
-
getBytes(length: number, forceClamped?: boolean): Uint8Array | Uint8ClampedArray;
|
|
15
|
-
peekByte(): number;
|
|
16
|
-
peekBytes(length: number, forceClamped?: boolean): Uint8Array | Uint8ClampedArray;
|
|
17
|
-
skip(n: number): void;
|
|
18
|
-
reset(): void;
|
|
19
|
-
makeSubStream(start: number, length: number): StreamType;
|
|
20
|
-
decode(): Uint8Array;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
class Stream implements StreamType {
|
|
24
|
-
private bytes: Uint8Array;
|
|
25
|
-
private start: number;
|
|
26
|
-
private pos: number;
|
|
27
|
-
private end: number;
|
|
28
|
-
|
|
29
|
-
constructor(buffer: Uint8Array, start?: number, length?: number) {
|
|
30
|
-
this.bytes = buffer;
|
|
31
|
-
this.start = start || 0;
|
|
32
|
-
this.pos = this.start;
|
|
33
|
-
this.end = !!start && !!length ? start + length : this.bytes.length;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
get length() {
|
|
37
|
-
return this.end - this.start;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
get isEmpty() {
|
|
41
|
-
return this.length === 0;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
getByte() {
|
|
45
|
-
if (this.pos >= this.end) {
|
|
46
|
-
return -1;
|
|
47
|
-
}
|
|
48
|
-
return this.bytes[this.pos++];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
getUint16() {
|
|
52
|
-
const b0 = this.getByte();
|
|
53
|
-
const b1 = this.getByte();
|
|
54
|
-
if (b0 === -1 || b1 === -1) {
|
|
55
|
-
return -1;
|
|
56
|
-
}
|
|
57
|
-
return (b0 << 8) + b1;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
getInt32() {
|
|
61
|
-
const b0 = this.getByte();
|
|
62
|
-
const b1 = this.getByte();
|
|
63
|
-
const b2 = this.getByte();
|
|
64
|
-
const b3 = this.getByte();
|
|
65
|
-
return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Returns subarray of original buffer, should only be read.
|
|
69
|
-
getBytes(length: number, forceClamped = false) {
|
|
70
|
-
const bytes = this.bytes;
|
|
71
|
-
const pos = this.pos;
|
|
72
|
-
const strEnd = this.end;
|
|
73
|
-
|
|
74
|
-
if (!length) {
|
|
75
|
-
const subarray = bytes.subarray(pos, strEnd);
|
|
76
|
-
// `this.bytes` is always a `Uint8Array` here.
|
|
77
|
-
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
|
78
|
-
} else {
|
|
79
|
-
let end = pos + length;
|
|
80
|
-
if (end > strEnd) {
|
|
81
|
-
end = strEnd;
|
|
82
|
-
}
|
|
83
|
-
this.pos = end;
|
|
84
|
-
const subarray = bytes.subarray(pos, end);
|
|
85
|
-
// `this.bytes` is always a `Uint8Array` here.
|
|
86
|
-
return forceClamped ? new Uint8ClampedArray(subarray) : subarray;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
peekByte() {
|
|
91
|
-
const peekedByte = this.getByte();
|
|
92
|
-
this.pos--;
|
|
93
|
-
return peekedByte;
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
peekBytes(length: number, forceClamped = false) {
|
|
97
|
-
const bytes = this.getBytes(length, forceClamped);
|
|
98
|
-
this.pos -= bytes.length;
|
|
99
|
-
return bytes;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
skip(n: number) {
|
|
103
|
-
if (!n) {
|
|
104
|
-
n = 1;
|
|
105
|
-
}
|
|
106
|
-
this.pos += n;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
reset() {
|
|
110
|
-
this.pos = this.start;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
moveStart() {
|
|
114
|
-
this.start = this.pos;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
makeSubStream(start: number, length: number) {
|
|
118
|
-
return new Stream(this.bytes, start, length);
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
decode(): Uint8Array {
|
|
122
|
-
return this.bytes;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export default Stream;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { UnexpectedObjectTypeError, UnsupportedEncodingError } from '../errors';
|
|
2
|
-
import PDFArray from '../objects/PDFArray';
|
|
3
|
-
import PDFDict from '../objects/PDFDict';
|
|
4
|
-
import PDFName from '../objects/PDFName';
|
|
5
|
-
import PDFNull from '../objects/PDFNull';
|
|
6
|
-
import PDFNumber from '../objects/PDFNumber';
|
|
7
|
-
import PDFRawStream from '../objects/PDFRawStream';
|
|
8
|
-
import Ascii85Stream from './Ascii85Stream';
|
|
9
|
-
import AsciiHexStream from './AsciiHexStream';
|
|
10
|
-
import FlateStream from './FlateStream';
|
|
11
|
-
import LZWStream from './LZWStream';
|
|
12
|
-
import RunLengthStream from './RunLengthStream';
|
|
13
|
-
import Stream, { StreamType } from './Stream';
|
|
14
|
-
|
|
15
|
-
const decodeStream = (
|
|
16
|
-
stream: StreamType,
|
|
17
|
-
encoding: PDFName,
|
|
18
|
-
params: undefined | typeof PDFNull | PDFDict,
|
|
19
|
-
) => {
|
|
20
|
-
if (encoding === PDFName.of('FlateDecode')) {
|
|
21
|
-
return new FlateStream(stream);
|
|
22
|
-
}
|
|
23
|
-
if (encoding === PDFName.of('LZWDecode')) {
|
|
24
|
-
let earlyChange = 1;
|
|
25
|
-
if (params instanceof PDFDict) {
|
|
26
|
-
const EarlyChange = params.lookup(PDFName.of('EarlyChange'));
|
|
27
|
-
if (EarlyChange instanceof PDFNumber) {
|
|
28
|
-
earlyChange = EarlyChange.asNumber();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return new LZWStream(stream, undefined, earlyChange as 0 | 1);
|
|
32
|
-
}
|
|
33
|
-
if (encoding === PDFName.of('ASCII85Decode')) {
|
|
34
|
-
return new Ascii85Stream(stream);
|
|
35
|
-
}
|
|
36
|
-
if (encoding === PDFName.of('ASCIIHexDecode')) {
|
|
37
|
-
return new AsciiHexStream(stream);
|
|
38
|
-
}
|
|
39
|
-
if (encoding === PDFName.of('RunLengthDecode')) {
|
|
40
|
-
return new RunLengthStream(stream);
|
|
41
|
-
}
|
|
42
|
-
throw new UnsupportedEncodingError(encoding.asString());
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
export const decodePDFRawStream = ({ dict, contents, transform }: PDFRawStream) => {
|
|
46
|
-
let stream: StreamType = new Stream(contents);
|
|
47
|
-
|
|
48
|
-
if (transform) {
|
|
49
|
-
stream = transform.createStream(stream, contents.length);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const Filter = dict.lookup(PDFName.of('Filter'));
|
|
53
|
-
const DecodeParms = dict.lookup(PDFName.of('DecodeParms'));
|
|
54
|
-
|
|
55
|
-
if (Filter instanceof PDFName) {
|
|
56
|
-
stream = decodeStream(stream, Filter, DecodeParms as PDFDict | typeof PDFNull | undefined);
|
|
57
|
-
} else if (Filter instanceof PDFArray) {
|
|
58
|
-
for (let idx = 0, len = Filter.size(); idx < len; idx++) {
|
|
59
|
-
stream = decodeStream(
|
|
60
|
-
stream,
|
|
61
|
-
Filter.lookup(idx, PDFName),
|
|
62
|
-
DecodeParms && (DecodeParms as PDFArray).lookupMaybe(idx, PDFDict),
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
} else if (Filter) {
|
|
66
|
-
throw new UnexpectedObjectTypeError([PDFName, PDFArray], Filter);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
return stream;
|
|
70
|
-
};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import PDFDict, { DictMap } from '../objects/PDFDict';
|
|
2
|
-
import PDFName from '../objects/PDFName';
|
|
3
|
-
import PDFRef from '../objects/PDFRef';
|
|
4
|
-
import PDFContext from '../PDFContext';
|
|
5
|
-
import PDFPageTree from './PDFPageTree';
|
|
6
|
-
import { PDFAcroForm } from '../acroform';
|
|
7
|
-
import ViewerPreferences from '../interactive/ViewerPreferences';
|
|
8
|
-
|
|
9
|
-
class PDFCatalog extends PDFDict {
|
|
10
|
-
static withContextAndPages = (context: PDFContext, pages: PDFPageTree | PDFRef) => {
|
|
11
|
-
const dict = new Map();
|
|
12
|
-
dict.set(PDFName.of('Type'), PDFName.of('Catalog'));
|
|
13
|
-
dict.set(PDFName.of('Pages'), pages);
|
|
14
|
-
return new PDFCatalog(dict, context);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
static fromMapWithContext = (map: DictMap, context: PDFContext) => new PDFCatalog(map, context);
|
|
18
|
-
|
|
19
|
-
Pages(): PDFPageTree {
|
|
20
|
-
return this.lookup(PDFName.of('Pages'), PDFDict) as PDFPageTree;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
AcroForm(): PDFDict | undefined {
|
|
24
|
-
return this.lookupMaybe(PDFName.of('AcroForm'), PDFDict);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
getAcroForm(): PDFAcroForm | undefined {
|
|
28
|
-
const dict = this.AcroForm();
|
|
29
|
-
if (!dict) return undefined;
|
|
30
|
-
return PDFAcroForm.fromDict(dict);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
getOrCreateAcroForm(): PDFAcroForm {
|
|
34
|
-
let acroForm = this.getAcroForm();
|
|
35
|
-
if (!acroForm) {
|
|
36
|
-
acroForm = PDFAcroForm.create(this.context);
|
|
37
|
-
const acroFormRef = this.context.register(acroForm.dict);
|
|
38
|
-
this.set(PDFName.of('AcroForm'), acroFormRef);
|
|
39
|
-
}
|
|
40
|
-
return acroForm;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
ViewerPreferences(): PDFDict | undefined {
|
|
44
|
-
return this.lookupMaybe(PDFName.of('ViewerPreferences'), PDFDict);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
getViewerPreferences(): ViewerPreferences | undefined {
|
|
48
|
-
const dict = this.ViewerPreferences();
|
|
49
|
-
if (!dict) return undefined;
|
|
50
|
-
return ViewerPreferences.fromDict(dict);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
getOrCreateViewerPreferences(): ViewerPreferences {
|
|
54
|
-
let viewerPrefs = this.getViewerPreferences();
|
|
55
|
-
if (!viewerPrefs) {
|
|
56
|
-
viewerPrefs = ViewerPreferences.create(this.context);
|
|
57
|
-
const viewerPrefsRef = this.context.register(viewerPrefs.dict);
|
|
58
|
-
this.set(PDFName.of('ViewerPreferences'), viewerPrefsRef);
|
|
59
|
-
}
|
|
60
|
-
return viewerPrefs;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Inserts the given ref as a leaf node of this catalog's page tree at the
|
|
65
|
-
* specified index (zero-based). Also increments the `Count` of each node in
|
|
66
|
-
* the page tree hierarchy to accomodate the new page.
|
|
67
|
-
*
|
|
68
|
-
* Returns the ref of the PDFPageTree node into which `leafRef` was inserted.
|
|
69
|
-
*/
|
|
70
|
-
insertLeafNode(leafRef: PDFRef, index: number): PDFRef {
|
|
71
|
-
const pagesRef = this.get(PDFName.of('Pages')) as PDFRef;
|
|
72
|
-
const maybeParentRef = this.Pages().insertLeafNode(leafRef, index);
|
|
73
|
-
return maybeParentRef || pagesRef;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
removeLeafNode(index: number): void {
|
|
77
|
-
this.Pages().removeLeafNode(index);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export default PDFCatalog;
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import PDFDict from '../objects/PDFDict';
|
|
2
|
-
import PDFOperator from '../operators/PDFOperator';
|
|
3
|
-
import PDFContext from '../PDFContext';
|
|
4
|
-
import PDFFlateStream from './PDFFlateStream';
|
|
5
|
-
import CharCodes from '../syntax/CharCodes';
|
|
6
|
-
|
|
7
|
-
class PDFContentStream extends PDFFlateStream {
|
|
8
|
-
static of = (dict: PDFDict, operators: PDFOperator[], encode = true) =>
|
|
9
|
-
new PDFContentStream(dict, operators, encode);
|
|
10
|
-
|
|
11
|
-
private readonly operators: PDFOperator[];
|
|
12
|
-
|
|
13
|
-
private constructor(dict: PDFDict, operators: PDFOperator[], encode = true) {
|
|
14
|
-
super(dict, encode);
|
|
15
|
-
this.operators = operators;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
push(...operators: PDFOperator[]): void {
|
|
19
|
-
this.operators.push(...operators);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
clone(context?: PDFContext): PDFContentStream {
|
|
23
|
-
const operators = Array(this.operators.length);
|
|
24
|
-
for (let idx = 0, len = this.operators.length; idx < len; idx++) {
|
|
25
|
-
operators[idx] = this.operators[idx].clone(context);
|
|
26
|
-
}
|
|
27
|
-
const { dict, encode } = this;
|
|
28
|
-
return PDFContentStream.of(dict.clone(context), operators, encode);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
getContentsString(): string {
|
|
32
|
-
let value = '';
|
|
33
|
-
for (let idx = 0, len = this.operators.length; idx < len; idx++) {
|
|
34
|
-
value += `${this.operators[idx]}\n`;
|
|
35
|
-
}
|
|
36
|
-
return value;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getUnencodedContents(): Uint8Array {
|
|
40
|
-
const buffer = new Uint8Array(this.getUnencodedContentsSize());
|
|
41
|
-
let offset = 0;
|
|
42
|
-
for (let idx = 0, len = this.operators.length; idx < len; idx++) {
|
|
43
|
-
offset += this.operators[idx].copyBytesInto(buffer, offset);
|
|
44
|
-
buffer[offset++] = CharCodes.Newline;
|
|
45
|
-
}
|
|
46
|
-
return buffer;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getUnencodedContentsSize(): number {
|
|
50
|
-
let size = 0;
|
|
51
|
-
for (let idx = 0, len = this.operators.length; idx < len; idx++) {
|
|
52
|
-
size += this.operators[idx].sizeInBytes() + 1;
|
|
53
|
-
}
|
|
54
|
-
return size;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
export default PDFContentStream;
|