@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
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import GraphElement from './GraphElement';
|
|
2
|
+
import Point from './Point';
|
|
3
|
+
export default class Circle extends GraphElement {
|
|
4
|
+
O: Point;
|
|
5
|
+
r: number;
|
|
6
|
+
constructor(O?: Point, r?: number);
|
|
7
|
+
ray(): number;
|
|
8
|
+
center(): Point;
|
|
9
|
+
/** This is used to standardize type Circle | Arc */
|
|
10
|
+
getCircle(): this;
|
|
11
|
+
isEqual(element: GraphElement): boolean;
|
|
12
|
+
includes(P: Point): boolean;
|
|
13
|
+
orthoProjection(P: Point): Point;
|
|
14
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { Size } from '../../types';
|
|
2
|
+
import GraphElement from './GraphElement';
|
|
3
|
+
import Point from './Point';
|
|
4
|
+
import Segment from './Segment';
|
|
5
|
+
export default class Ellipse extends GraphElement {
|
|
6
|
+
A: Point;
|
|
7
|
+
B: Point;
|
|
8
|
+
C: Point;
|
|
9
|
+
constructor(A?: Point, B?: Point, C?: Point);
|
|
10
|
+
center(): Point;
|
|
11
|
+
axis(): Segment;
|
|
12
|
+
a(): number;
|
|
13
|
+
b(): number;
|
|
14
|
+
rotation(): number;
|
|
15
|
+
getSize(): Size;
|
|
16
|
+
isEqual(element: GraphElement): boolean;
|
|
17
|
+
includes(P: Point): boolean;
|
|
18
|
+
orthoProjection(P: Point): Point;
|
|
19
|
+
polarRay(teta: number): number;
|
|
20
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Coordinates } from '../../types';
|
|
2
|
+
import GraphElement from './GraphElement';
|
|
3
|
+
import Point from './Point';
|
|
4
|
+
export default class Line extends GraphElement {
|
|
5
|
+
origin(): Point;
|
|
6
|
+
dirVect(): Coordinates;
|
|
7
|
+
A: Point;
|
|
8
|
+
B: Point;
|
|
9
|
+
constructor(A?: Point, B?: Point);
|
|
10
|
+
/** Line equation */
|
|
11
|
+
y(x: number): number;
|
|
12
|
+
/** The slope */
|
|
13
|
+
a(): number;
|
|
14
|
+
/** Origin y coordinate */
|
|
15
|
+
b(): number;
|
|
16
|
+
isEqual(element: GraphElement): boolean;
|
|
17
|
+
/** Reversed line equation */
|
|
18
|
+
x(y: number): number;
|
|
19
|
+
includes(P: Point): boolean;
|
|
20
|
+
/** This is used to standarsize type Segment | HalfLine | Line */
|
|
21
|
+
getLine(): Line;
|
|
22
|
+
orthoProjection(P: Point): Point;
|
|
23
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Coordinates } from '../../types';
|
|
2
|
+
import GraphElement from './GraphElement';
|
|
3
|
+
import Point from './Point';
|
|
4
|
+
export default class Plot extends GraphElement {
|
|
5
|
+
points: Coordinates[];
|
|
6
|
+
constructor(points?: Coordinates[]);
|
|
7
|
+
getPoints(): Coordinates[];
|
|
8
|
+
translate(translationVector: Coordinates): void;
|
|
9
|
+
isEqual(element: GraphElement): boolean;
|
|
10
|
+
orthoProjection(P: Point): Point;
|
|
11
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Coordinates } from '../../types';
|
|
2
|
+
import GraphElement from './GraphElement';
|
|
3
|
+
export default class Point extends GraphElement {
|
|
4
|
+
static type: string;
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
constructor(coords?: {
|
|
8
|
+
x: number;
|
|
9
|
+
y: number;
|
|
10
|
+
});
|
|
11
|
+
toCoords(): {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
};
|
|
15
|
+
isEqual(element: GraphElement): boolean;
|
|
16
|
+
orthoProjection(): Point;
|
|
17
|
+
plus(vect: Coordinates): Point;
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import GraphElement from './GraphElement';
|
|
2
|
+
import Point from './Point';
|
|
3
|
+
export default class Rectangle extends GraphElement {
|
|
4
|
+
static type: string;
|
|
5
|
+
start: Point;
|
|
6
|
+
end: Point;
|
|
7
|
+
constructor(start?: Point, end?: Point);
|
|
8
|
+
getSize(): {
|
|
9
|
+
width: number;
|
|
10
|
+
height: number;
|
|
11
|
+
};
|
|
12
|
+
getCoords(): {
|
|
13
|
+
x: number;
|
|
14
|
+
y: number;
|
|
15
|
+
};
|
|
16
|
+
getStart(): Point;
|
|
17
|
+
getEnd(): Point;
|
|
18
|
+
center(): Point;
|
|
19
|
+
isEqual(element: GraphElement): boolean;
|
|
20
|
+
orthoProjection(P: Point): Point;
|
|
21
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import GraphElement from './GraphElement';
|
|
2
|
+
import Line from './Line';
|
|
3
|
+
import Point from './Point';
|
|
4
|
+
export default class Segment extends GraphElement {
|
|
5
|
+
static type: string;
|
|
6
|
+
A: Point;
|
|
7
|
+
B: Point;
|
|
8
|
+
constructor(A?: Point, B?: Point);
|
|
9
|
+
origin(): Point;
|
|
10
|
+
destination(): Point;
|
|
11
|
+
dirVect(): import("../..").Coordinates;
|
|
12
|
+
length(): number;
|
|
13
|
+
isEqual(element: GraphElement): boolean;
|
|
14
|
+
/** Returns an equivalent line object */
|
|
15
|
+
getLine(): Line;
|
|
16
|
+
includes(P: Point): boolean;
|
|
17
|
+
middle(): Point;
|
|
18
|
+
orthoProjection(P: Point): Point;
|
|
19
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const error: (msg: string) => never;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import Circle from './elements/Circle';
|
|
2
|
+
import Line from './elements/Line';
|
|
3
|
+
import { Coordinates, GraphicElement } from '../types';
|
|
4
|
+
export declare function intersections(A: GraphicElement, B: GraphicElement): Coordinates[];
|
|
5
|
+
export declare function intersection(A: GraphicElement, B: GraphicElement): Coordinates | undefined;
|
|
6
|
+
export declare function intersectionLine(A: Line, B: Line): Coordinates[];
|
|
7
|
+
export declare function intersectionCircleLine(A: Circle, B: Line): Coordinates[];
|
|
8
|
+
export declare function intersectionCircle(A: Circle, B: Circle): Coordinates[];
|
|
9
|
+
export declare function getIntersections(elements: GraphicElement[]): Coordinates[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import Point from './elements/Point';
|
|
2
|
+
import { Coordinates } from '../types';
|
|
3
|
+
/** This value represents the precision we accept for float values */
|
|
4
|
+
export declare const FLOAT_APPROXIMATION = 0.000001;
|
|
5
|
+
/** Calculates the distance between 2 points */
|
|
6
|
+
export declare const distance: (A: Point, B: Point) => number;
|
|
7
|
+
export declare const distanceCoords: (A: Coordinates, B: Coordinates) => number;
|
|
8
|
+
/** Calculates the distance denoted by a vector */
|
|
9
|
+
export declare const norm: (vect: Coordinates) => number;
|
|
10
|
+
/** Calculates the orthogonal vector of provided vector */
|
|
11
|
+
export declare const orthogonal: ({ x, y }: Coordinates) => Coordinates;
|
|
12
|
+
/** Check if 2 vectors are proportional */
|
|
13
|
+
export declare const isColinear: ({ x: ux, y: uy }: Coordinates, { x: vx, y: vy }: Coordinates) => boolean;
|
|
14
|
+
/** Check if 2 floating values can be considered equals */
|
|
15
|
+
export declare const isEqual: (a: number, b: number) => boolean;
|
|
16
|
+
/** Return true if a is proportional to b: (a = kb), considering float imprecision */
|
|
17
|
+
export declare const isProportional: (a: number, b: number) => boolean;
|
|
18
|
+
/** Calculate the scalar product between 2 vectors */
|
|
19
|
+
export declare const scalar: ({ x: ux, y: uy }: Coordinates, { x: vx, y: vy }: Coordinates) => number;
|
|
20
|
+
/** Calculate the sum of 2 vectors */
|
|
21
|
+
export declare const plus: ({ x: ux, y: uy }: Coordinates, { x: vx, y: vy }: Coordinates) => Coordinates;
|
|
22
|
+
/** Calculate the vector multiplied by a scalar */
|
|
23
|
+
export declare const times: ({ x, y }: Coordinates, k?: number) => Coordinates;
|
|
24
|
+
/** Calculate the difference of 2 vectors */
|
|
25
|
+
export declare const minus: (u: Coordinates, v: Coordinates) => Coordinates;
|
|
26
|
+
/** Returns the vector between 2 points. */
|
|
27
|
+
export declare const vector: (A: Point, B: Point) => Coordinates;
|
|
28
|
+
/**
|
|
29
|
+
* Returns the angle between the vector and the horizontal axis (Ox).
|
|
30
|
+
* The return value is between -PI and PI.
|
|
31
|
+
* @returns {number} angle in radian between -Pi and Pi
|
|
32
|
+
*/
|
|
33
|
+
export declare const orientation: ({ x, y }: Coordinates) => number;
|
|
34
|
+
/** Returns the unit vector associated to the provided vector,
|
|
35
|
+
* or the Null vector (0, 0) if the vector is null
|
|
36
|
+
*/
|
|
37
|
+
export declare const unitVector: (u: Coordinates) => Coordinates;
|
|
38
|
+
/** Returns the angle from u to v in radian */
|
|
39
|
+
export declare const angle: (u: Coordinates, v: Coordinates, previousAngle?: number) => number;
|
|
40
|
+
/** Returns the angle between the lines (BA) and (BC) in radian
|
|
41
|
+
* @returns {number} the angle in radian, between -Pi and Pi
|
|
42
|
+
*/
|
|
43
|
+
export declare const angleABC: (A: Point, B: Point, C: Point, previousAngle?: number) => number;
|
|
44
|
+
/** Rotate the vector by an angle in radian */
|
|
45
|
+
export declare const rotate: (vect: Coordinates, teta: number) => Coordinates;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a number to its string representation in decimal. This function
|
|
3
|
+
* differs from simply converting a number to a string with `.toString()`
|
|
4
|
+
* because this function's output string will **not** contain exponential
|
|
5
|
+
* notation.
|
|
6
|
+
*
|
|
7
|
+
* Credit: https://stackoverflow.com/a/46545519
|
|
8
|
+
*/
|
|
9
|
+
export declare const numberToString: (num: number) => string;
|
|
10
|
+
export declare const sizeInBytes: (n: number) => number;
|
|
11
|
+
/**
|
|
12
|
+
* Converts a number into its constituent bytes and returns them as
|
|
13
|
+
* a number[].
|
|
14
|
+
*
|
|
15
|
+
* Returns most significant byte as first element in array. It may be necessary
|
|
16
|
+
* to call .reverse() to get the bits in the desired order.
|
|
17
|
+
*
|
|
18
|
+
* Example:
|
|
19
|
+
* bytesFor(0x02A41E) => [ 0b10, 0b10100100, 0b11110 ]
|
|
20
|
+
*
|
|
21
|
+
* Credit for algorithm: https://stackoverflow.com/a/1936865
|
|
22
|
+
*/
|
|
23
|
+
export declare const bytesFor: (n: number) => Uint8Array<ArrayBuffer>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { FontNames } from '@pdf-lib/standard-fonts';
|
|
2
|
+
export declare const values: (obj: any) => any[];
|
|
3
|
+
export declare const StandardFontValues: any[];
|
|
4
|
+
export declare const isStandardFont: (input: any) => input is FontNames;
|
|
5
|
+
export declare const rectanglesAreEqual: (a: {
|
|
6
|
+
x: number;
|
|
7
|
+
y: number;
|
|
8
|
+
width: number;
|
|
9
|
+
height: number;
|
|
10
|
+
}, b: {
|
|
11
|
+
x: number;
|
|
12
|
+
y: number;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
}) => boolean;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare enum PngType {
|
|
2
|
+
Greyscale = "Greyscale",
|
|
3
|
+
Truecolour = "Truecolour",
|
|
4
|
+
IndexedColour = "IndexedColour",
|
|
5
|
+
GreyscaleWithAlpha = "GreyscaleWithAlpha",
|
|
6
|
+
TruecolourWithAlpha = "TruecolourWithAlpha"
|
|
7
|
+
}
|
|
8
|
+
export declare class PNG {
|
|
9
|
+
static load: (pngData: Uint8Array) => PNG;
|
|
10
|
+
readonly rgbChannel: Uint8Array;
|
|
11
|
+
readonly alphaChannel?: Uint8Array;
|
|
12
|
+
readonly type: PngType;
|
|
13
|
+
readonly width: number;
|
|
14
|
+
readonly height: number;
|
|
15
|
+
readonly bitsPerComponent: number;
|
|
16
|
+
private constructor();
|
|
17
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a pseudo random number. Although it is not cryptographically secure
|
|
3
|
+
* and uniformly distributed, it is not a concern for the intended use-case,
|
|
4
|
+
* which is to generate distinct numbers.
|
|
5
|
+
*
|
|
6
|
+
* Credit: https://stackoverflow.com/a/19303725/10254049
|
|
7
|
+
*/
|
|
8
|
+
export declare class SimpleRNG {
|
|
9
|
+
static withSeed: (seed: number) => SimpleRNG;
|
|
10
|
+
private seed;
|
|
11
|
+
private constructor();
|
|
12
|
+
nextInt(): number;
|
|
13
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export declare const toCharCode: (character: string) => number;
|
|
2
|
+
export declare const toCodePoint: (character: string) => number | undefined;
|
|
3
|
+
export declare const toHexStringOfMinLength: (num: number, minLength: number) => string;
|
|
4
|
+
export declare const toHexString: (num: number) => string;
|
|
5
|
+
export declare const charFromCode: (code: number) => string;
|
|
6
|
+
export declare const charFromHexCode: (hex: string) => string;
|
|
7
|
+
export declare const padStart: (value: string, length: number, padChar: string) => string;
|
|
8
|
+
export declare const stringAsByteArray: (str: string) => Uint8Array;
|
|
9
|
+
export declare const copyStringIntoBuffer: (str: string, buffer: Uint8Array, offset: number) => number;
|
|
10
|
+
export declare const addRandomSuffix: (prefix: string, suffixLength?: number) => string;
|
|
11
|
+
export declare const escapeRegExp: (str: string) => string;
|
|
12
|
+
export declare const cleanText: (text: string) => string;
|
|
13
|
+
export declare const escapedNewlineChars: string[];
|
|
14
|
+
export declare const newlineChars: string[];
|
|
15
|
+
export declare const isNewlineChar: (text: string) => boolean;
|
|
16
|
+
export declare const lineSplit: (text: string) => string[];
|
|
17
|
+
export declare const mergeLines: (text: string) => string;
|
|
18
|
+
export declare const charAtIndex: (text: string, index: number) => [string, number];
|
|
19
|
+
export declare const charSplit: (text: string) => string[];
|
|
20
|
+
export declare const breakTextIntoLines: (text: string, wordBreaks: string[], maxWidth: number, computeWidthOfText: (t: string) => number) => string[];
|
|
21
|
+
export declare const parseDate: (dateStr: string) => Date | undefined;
|
|
22
|
+
export declare const findLastMatch: (value: string, regex: RegExp) => {
|
|
23
|
+
match: RegExpMatchArray | undefined;
|
|
24
|
+
pos: number;
|
|
25
|
+
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { toHexString } from './strings';
|
|
2
|
-
|
|
3
1
|
/**
|
|
4
2
|
* Encodes a string to UTF-8.
|
|
5
3
|
*
|
|
@@ -87,55 +85,7 @@ import { toHexString } from './strings';
|
|
|
87
85
|
* - [4] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#Description
|
|
88
86
|
*
|
|
89
87
|
*/
|
|
90
|
-
export const utf8Encode
|
|
91
|
-
const encoded = [];
|
|
92
|
-
|
|
93
|
-
if (byteOrderMark) encoded.push(0xef, 0xbb, 0xbf);
|
|
94
|
-
|
|
95
|
-
for (let idx = 0, len = input.length; idx < len; ) {
|
|
96
|
-
const codePoint = input.codePointAt(idx)!;
|
|
97
|
-
|
|
98
|
-
// One byte encoding
|
|
99
|
-
if (codePoint < 0x80) {
|
|
100
|
-
const byte1 = codePoint & 0x7f;
|
|
101
|
-
encoded.push(byte1);
|
|
102
|
-
idx += 1;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Two byte encoding
|
|
106
|
-
else if (codePoint < 0x0800) {
|
|
107
|
-
const byte1 = ((codePoint >> 6) & 0x1f) | 0xc0;
|
|
108
|
-
const byte2 = (codePoint & 0x3f) | 0x80;
|
|
109
|
-
encoded.push(byte1, byte2);
|
|
110
|
-
idx += 1;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
// Three byte encoding
|
|
114
|
-
else if (codePoint < 0x010000) {
|
|
115
|
-
const byte1 = ((codePoint >> 12) & 0x0f) | 0xe0;
|
|
116
|
-
const byte2 = ((codePoint >> 6) & 0x3f) | 0x80;
|
|
117
|
-
const byte3 = (codePoint & 0x3f) | 0x80;
|
|
118
|
-
encoded.push(byte1, byte2, byte3);
|
|
119
|
-
idx += 1;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
// Four byte encoding (surrogate pair)
|
|
123
|
-
else if (codePoint < 0x110000) {
|
|
124
|
-
const byte1 = ((codePoint >> 18) & 0x07) | 0xf0;
|
|
125
|
-
const byte2 = ((codePoint >> 12) & 0x3f) | 0x80;
|
|
126
|
-
const byte3 = ((codePoint >> 6) & 0x3f) | 0x80;
|
|
127
|
-
const byte4 = ((codePoint >> 0) & 0x3f) | 0x80;
|
|
128
|
-
encoded.push(byte1, byte2, byte3, byte4);
|
|
129
|
-
idx += 2;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
// Should never reach this case
|
|
133
|
-
else throw new Error(`Invalid code point: 0x${toHexString(codePoint)}`);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
return new Uint8Array(encoded);
|
|
137
|
-
};
|
|
138
|
-
|
|
88
|
+
export declare const utf8Encode: (input: string, byteOrderMark?: boolean) => Uint8Array;
|
|
139
89
|
/**
|
|
140
90
|
* Encodes a string to UTF-16.
|
|
141
91
|
*
|
|
@@ -200,33 +150,7 @@ export const utf8Encode = (input: string, byteOrderMark = true): Uint8Array => {
|
|
|
200
150
|
* - [3] https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/length#Description
|
|
201
151
|
*
|
|
202
152
|
*/
|
|
203
|
-
export const utf16Encode
|
|
204
|
-
const encoded = [];
|
|
205
|
-
|
|
206
|
-
if (byteOrderMark) encoded.push(0xfeff);
|
|
207
|
-
|
|
208
|
-
for (let idx = 0, len = input.length; idx < len; ) {
|
|
209
|
-
const codePoint = input.codePointAt(idx)!;
|
|
210
|
-
|
|
211
|
-
// Two byte encoding
|
|
212
|
-
if (codePoint < 0x010000) {
|
|
213
|
-
encoded.push(codePoint);
|
|
214
|
-
idx += 1;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Four byte encoding (surrogate pair)
|
|
218
|
-
else if (codePoint < 0x110000) {
|
|
219
|
-
encoded.push(highSurrogate(codePoint), lowSurrogate(codePoint));
|
|
220
|
-
idx += 2;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
// Should never reach this case
|
|
224
|
-
else throw new Error(`Invalid code point: 0x${toHexString(codePoint)}`);
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
return new Uint16Array(encoded);
|
|
228
|
-
};
|
|
229
|
-
|
|
153
|
+
export declare const utf16Encode: (input: string, byteOrderMark?: boolean) => Uint16Array;
|
|
230
154
|
/**
|
|
231
155
|
* Returns `true` if the `codePoint` is within the
|
|
232
156
|
* Basic Multilingual Plane (BMP). Code points inside the BMP are not encoded
|
|
@@ -235,8 +159,7 @@ export const utf16Encode = (input: string, byteOrderMark = true): Uint16Array =>
|
|
|
235
159
|
*
|
|
236
160
|
* Reference: https://en.wikipedia.org/wiki/UTF-16#Description
|
|
237
161
|
*/
|
|
238
|
-
export const isWithinBMP
|
|
239
|
-
|
|
162
|
+
export declare const isWithinBMP: (codePoint: number) => boolean;
|
|
240
163
|
/**
|
|
241
164
|
* Returns `true` if the given `codePoint` is valid and must be represented
|
|
242
165
|
* with a surrogate pair when encoded.
|
|
@@ -244,24 +167,9 @@ export const isWithinBMP = (codePoint: number) => codePoint >= 0 && codePoint <=
|
|
|
244
167
|
*
|
|
245
168
|
* Reference: https://en.wikipedia.org/wiki/UTF-16#Description
|
|
246
169
|
*/
|
|
247
|
-
export const hasSurrogates
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// http://unicode.org/versions/Unicode3.0.0/ch03.pdf
|
|
251
|
-
export const highSurrogate = (codePoint: number) =>
|
|
252
|
-
Math.floor((codePoint - 0x10000) / 0x400) + 0xd800;
|
|
253
|
-
|
|
254
|
-
// From Unicode 3.0 spec, section 3.7:
|
|
255
|
-
// http://unicode.org/versions/Unicode3.0.0/ch03.pdf
|
|
256
|
-
export const lowSurrogate = (codePoint: number) => ((codePoint - 0x10000) % 0x400) + 0xdc00;
|
|
257
|
-
|
|
258
|
-
enum ByteOrder {
|
|
259
|
-
BigEndian = 'BigEndian',
|
|
260
|
-
LittleEndian = 'LittleEndian',
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
const REPLACEMENT = '�'.codePointAt(0)!;
|
|
264
|
-
|
|
170
|
+
export declare const hasSurrogates: (codePoint: number) => boolean;
|
|
171
|
+
export declare const highSurrogate: (codePoint: number) => number;
|
|
172
|
+
export declare const lowSurrogate: (codePoint: number) => number;
|
|
265
173
|
/**
|
|
266
174
|
* Decodes a Uint8Array of data to a string using UTF-16.
|
|
267
175
|
*
|
|
@@ -274,100 +182,5 @@ const REPLACEMENT = '�'.codePointAt(0)!;
|
|
|
274
182
|
* at the start of the encoding. (default `true`)
|
|
275
183
|
* @returns The decoded string.
|
|
276
184
|
*/
|
|
277
|
-
export const utf16Decode
|
|
278
|
-
|
|
279
|
-
if (input.length <= 1) return String.fromCodePoint(REPLACEMENT);
|
|
280
|
-
|
|
281
|
-
const byteOrder = byteOrderMark ? readBOM(input) : ByteOrder.BigEndian;
|
|
282
|
-
|
|
283
|
-
// Skip byte order mark if needed
|
|
284
|
-
let idx = byteOrderMark ? 2 : 0;
|
|
285
|
-
|
|
286
|
-
const codePoints: number[] = [];
|
|
287
|
-
|
|
288
|
-
while (input.length - idx >= 2) {
|
|
289
|
-
const first = decodeValues(input[idx++], input[idx++], byteOrder);
|
|
290
|
-
|
|
291
|
-
if (isHighSurrogate(first)) {
|
|
292
|
-
if (input.length - idx < 2) {
|
|
293
|
-
// Need at least 2 bytes left for the low surrogate that is required
|
|
294
|
-
codePoints.push(REPLACEMENT);
|
|
295
|
-
} else {
|
|
296
|
-
const second = decodeValues(input[idx++], input[idx++], byteOrder);
|
|
297
|
-
if (isLowSurrogate(second)) {
|
|
298
|
-
codePoints.push(first, second);
|
|
299
|
-
} else {
|
|
300
|
-
// Low surrogates should always follow high surrogates
|
|
301
|
-
codePoints.push(REPLACEMENT);
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
} else if (isLowSurrogate(first)) {
|
|
305
|
-
// High surrogates should always come first since `decodeValues()`
|
|
306
|
-
// accounts for the byte ordering
|
|
307
|
-
idx += 2;
|
|
308
|
-
codePoints.push(REPLACEMENT);
|
|
309
|
-
} else {
|
|
310
|
-
codePoints.push(first);
|
|
311
|
-
}
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// There shouldn't be extra byte(s) left over
|
|
315
|
-
if (idx < input.length) codePoints.push(REPLACEMENT);
|
|
316
|
-
|
|
317
|
-
return String.fromCodePoint(...codePoints);
|
|
318
|
-
};
|
|
319
|
-
|
|
320
|
-
/**
|
|
321
|
-
* Returns `true` if the given `codePoint` is a high surrogate.
|
|
322
|
-
* @param codePoint The code point to be evaluated.
|
|
323
|
-
*
|
|
324
|
-
* Reference: https://en.wikipedia.org/wiki/UTF-16#Description
|
|
325
|
-
*/
|
|
326
|
-
const isHighSurrogate = (codePoint: number) => codePoint >= 0xd800 && codePoint <= 0xdbff;
|
|
327
|
-
|
|
328
|
-
/**
|
|
329
|
-
* Returns `true` if the given `codePoint` is a low surrogate.
|
|
330
|
-
* @param codePoint The code point to be evaluated.
|
|
331
|
-
*
|
|
332
|
-
* Reference: https://en.wikipedia.org/wiki/UTF-16#Description
|
|
333
|
-
*/
|
|
334
|
-
const isLowSurrogate = (codePoint: number) => codePoint >= 0xdc00 && codePoint <= 0xdfff;
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Decodes the given utf-16 values first and second using the specified
|
|
338
|
-
* byte order.
|
|
339
|
-
* @param first The first byte of the encoding.
|
|
340
|
-
* @param second The second byte of the encoding.
|
|
341
|
-
* @param byteOrder The byte order of the encoding.
|
|
342
|
-
* Reference: https://en.wikipedia.org/wiki/UTF-16#Examples
|
|
343
|
-
*/
|
|
344
|
-
const decodeValues = (first: number, second: number, byteOrder: ByteOrder) => {
|
|
345
|
-
// Append the binary representation of the preceding byte by shifting the
|
|
346
|
-
// first one 8 to the left and than applying a bitwise or-operator to append
|
|
347
|
-
// the second one.
|
|
348
|
-
if (byteOrder === ByteOrder.LittleEndian) return (second << 8) | first;
|
|
349
|
-
if (byteOrder === ByteOrder.BigEndian) return (first << 8) | second;
|
|
350
|
-
throw new Error(`Invalid byteOrder: ${byteOrder}`);
|
|
351
|
-
};
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Returns whether the given array contains a byte order mark for the
|
|
355
|
-
* UTF-16BE or UTF-16LE encoding. If it has neither, BigEndian is assumed.
|
|
356
|
-
*
|
|
357
|
-
* Reference: https://en.wikipedia.org/wiki/Byte_order_mark#UTF-16
|
|
358
|
-
*
|
|
359
|
-
* @param bytes The byte array to be evaluated.
|
|
360
|
-
*/
|
|
361
|
-
// prettier-ignore
|
|
362
|
-
const readBOM = (bytes: Uint8Array): ByteOrder => (
|
|
363
|
-
hasUtf16BigEndianBOM(bytes) ? ByteOrder.BigEndian
|
|
364
|
-
: hasUtf16LittleEndianBOM(bytes) ? ByteOrder.LittleEndian
|
|
365
|
-
: ByteOrder.BigEndian
|
|
366
|
-
);
|
|
367
|
-
|
|
368
|
-
const hasUtf16BigEndianBOM = (bytes: Uint8Array) => bytes[0] === 0xfe && bytes[1] === 0xff;
|
|
369
|
-
|
|
370
|
-
const hasUtf16LittleEndianBOM = (bytes: Uint8Array) => bytes[0] === 0xff && bytes[1] === 0xfe;
|
|
371
|
-
|
|
372
|
-
export const hasUtf16BOM = (bytes: Uint8Array) =>
|
|
373
|
-
hasUtf16BigEndianBOM(bytes) || hasUtf16LittleEndianBOM(bytes);
|
|
185
|
+
export declare const utf16Decode: (input: Uint8Array, byteOrderMark?: boolean) => string;
|
|
186
|
+
export declare const hasUtf16BOM: (bytes: Uint8Array) => boolean;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const backtick: (val: any) => string;
|
|
2
|
+
export declare const singleQuote: (val: any) => string;
|
|
3
|
+
type Primitive = string | number | boolean | undefined | null;
|
|
4
|
+
export declare const createValueErrorMsg: (value: any, valueName: string, values: Primitive[]) => string;
|
|
5
|
+
export declare const assertIsOneOf: (value: any, valueName: string, allowedValues: Primitive[] | {
|
|
6
|
+
[key: string]: Primitive;
|
|
7
|
+
}) => void;
|
|
8
|
+
export declare const assertIsOneOfOrUndefined: (value: any, valueName: string, allowedValues: Primitive[] | {
|
|
9
|
+
[key: string]: Primitive;
|
|
10
|
+
}) => void;
|
|
11
|
+
export declare const assertIsSubset: (values: any[], valueName: string, allowedValues: Primitive[] | {
|
|
12
|
+
[key: string]: Primitive;
|
|
13
|
+
}) => void;
|
|
14
|
+
export declare const getType: (val: any) => any;
|
|
15
|
+
export type TypeDescriptor = 'null' | 'undefined' | 'string' | 'number' | 'boolean' | 'symbol' | 'bigint' | DateConstructor | ArrayConstructor | Uint8ArrayConstructor | ArrayBufferConstructor | FunctionConstructor | [Function, string];
|
|
16
|
+
export declare const isType: (value: any, type: TypeDescriptor) => boolean;
|
|
17
|
+
export declare const createTypeErrorMsg: (value: any, valueName: string, types: TypeDescriptor[]) => string;
|
|
18
|
+
export declare const assertIs: (value: any, valueName: string, types: TypeDescriptor[]) => void;
|
|
19
|
+
export declare const assertOrUndefined: (value: any, valueName: string, types: TypeDescriptor[]) => void;
|
|
20
|
+
export declare const assertEachIs: (values: any[], valueName: string, types: TypeDescriptor[]) => void;
|
|
21
|
+
export declare const assertRange: (value: any, valueName: string, min: number, max: number) => void;
|
|
22
|
+
export declare const assertRangeOrUndefined: (value: any, valueName: string, min: number, max: number) => void;
|
|
23
|
+
export declare const assertMultiple: (value: any, valueName: string, multiplier: number) => void;
|
|
24
|
+
export declare const assertInteger: (value: any, valueName: string) => void;
|
|
25
|
+
export declare const assertPositive: (value: number, valueName: string) => void;
|
|
26
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pdfme/pdf-lib",
|
|
3
|
-
"version": "6.0.
|
|
3
|
+
"version": "6.0.5-dev.1",
|
|
4
4
|
"description": "Create and modify PDF files with JavaScript",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"create",
|
|
@@ -28,6 +28,11 @@
|
|
|
28
28
|
},
|
|
29
29
|
"type": "module",
|
|
30
30
|
"sideEffects": false,
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE.md"
|
|
35
|
+
],
|
|
31
36
|
"main": "./dist/index.js",
|
|
32
37
|
"module": "./dist/index.js",
|
|
33
38
|
"types": "./dist/index.d.ts",
|