@pdfme/pdf-lib 6.0.3 → 6.0.4-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,30 +0,0 @@
|
|
|
1
|
-
import { PDFNull } from '../../../src/core';
|
|
2
|
-
import { toCharCode, typedArrayFor } from '../../../src/utils';
|
|
3
|
-
|
|
4
|
-
describe(`PDFNull`, () => {
|
|
5
|
-
it(`cannot be publicly constructed`, () => {
|
|
6
|
-
expect(() => new (PDFNull as any)()).toThrow();
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it(`can be converted to null`, () => {
|
|
10
|
-
expect(PDFNull.asNull()).toBe(null);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it(`can be cloned`, () => {
|
|
14
|
-
expect(PDFNull.clone()).toBe(PDFNull);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it(`can be converted to a string`, () => {
|
|
18
|
-
expect(String(PDFNull)).toBe('null');
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
it(`can provide its size in bytes`, () => {
|
|
22
|
-
expect(PDFNull.sizeInBytes()).toBe(4);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it(`can be serialized`, () => {
|
|
26
|
-
const buffer = new Uint8Array(8).fill(toCharCode(' '));
|
|
27
|
-
expect(PDFNull.copyBytesInto(buffer, 3)).toBe(4);
|
|
28
|
-
expect(buffer).toEqual(typedArrayFor(' null '));
|
|
29
|
-
});
|
|
30
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import { PDFNumber } from '../../../src/core';
|
|
2
|
-
import { toCharCode, typedArrayFor } from '../../../src/utils';
|
|
3
|
-
|
|
4
|
-
describe(`PDFNumber`, () => {
|
|
5
|
-
it(`can be constructed from PDFNumber.of(...)`, () => {
|
|
6
|
-
expect(PDFNumber.of(21)).toBeInstanceOf(PDFNumber);
|
|
7
|
-
expect(PDFNumber.of(-43)).toBeInstanceOf(PDFNumber);
|
|
8
|
-
expect(PDFNumber.of(-0.1e7)).toBeInstanceOf(PDFNumber);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it(`can be cloned`, () => {
|
|
12
|
-
const original = PDFNumber.of(-21.42);
|
|
13
|
-
const clone = original.clone();
|
|
14
|
-
expect(clone).not.toBe(original);
|
|
15
|
-
expect(clone.toString()).toBe(original.toString());
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it(`can be converted to a string`, () => {
|
|
19
|
-
expect(String(PDFNumber.of(21))).toEqual('21');
|
|
20
|
-
expect(String(PDFNumber.of(-43))).toEqual('-43');
|
|
21
|
-
expect(String(PDFNumber.of(3.403e38))).toEqual(
|
|
22
|
-
'340300000000000000000000000000000000000',
|
|
23
|
-
);
|
|
24
|
-
expect(String(PDFNumber.of(-3.403e38))).toEqual(
|
|
25
|
-
'-340300000000000000000000000000000000000',
|
|
26
|
-
);
|
|
27
|
-
expect(String(PDFNumber.of(-3.403e-38))).toContain(
|
|
28
|
-
'-0.00000000000000000000000000000000000003403',
|
|
29
|
-
);
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
it(`can provide its size in bytes`, () => {
|
|
33
|
-
expect(PDFNumber.of(21).sizeInBytes()).toBe(2);
|
|
34
|
-
expect(PDFNumber.of(-43).sizeInBytes()).toBe(3);
|
|
35
|
-
expect(PDFNumber.of(3.403e38).sizeInBytes()).toBe(39);
|
|
36
|
-
expect(PDFNumber.of(-3.403e38).sizeInBytes()).toBe(40);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it(`can be serialized`, () => {
|
|
40
|
-
const buffer1 = new Uint8Array(8).fill(toCharCode(' '));
|
|
41
|
-
expect(PDFNumber.of(21).copyBytesInto(buffer1, 3)).toBe(2);
|
|
42
|
-
expect(buffer1).toEqual(typedArrayFor(' 21 '));
|
|
43
|
-
|
|
44
|
-
const buffer2 = new Uint8Array(40).fill(toCharCode(' '));
|
|
45
|
-
expect(PDFNumber.of(-3.403e38).copyBytesInto(buffer2, 0)).toBe(40);
|
|
46
|
-
expect(buffer2).toEqual(
|
|
47
|
-
typedArrayFor('-340300000000000000000000000000000000000'),
|
|
48
|
-
);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { MethodNotImplementedError, PDFObject } from '../../../src/core';
|
|
2
|
-
|
|
3
|
-
describe(`PDFObject`, () => {
|
|
4
|
-
const pdfObject = new PDFObject();
|
|
5
|
-
|
|
6
|
-
it(`does not implement clone()`, () => {
|
|
7
|
-
expect(() => pdfObject.clone()).toThrow(
|
|
8
|
-
new MethodNotImplementedError(PDFObject.name, 'clone'),
|
|
9
|
-
);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it(`does not implement toString()`, () => {
|
|
13
|
-
expect(() => pdfObject.toString()).toThrow(
|
|
14
|
-
new MethodNotImplementedError(PDFObject.name, 'toString'),
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it(`does not implement sizeInBytes()`, () => {
|
|
19
|
-
expect(() => pdfObject.sizeInBytes()).toThrow(
|
|
20
|
-
new MethodNotImplementedError(PDFObject.name, 'sizeInBytes'),
|
|
21
|
-
);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it(`does not implement copyBytesInto()`, () => {
|
|
25
|
-
expect(() => pdfObject.copyBytesInto(new Uint8Array(), 0)).toThrow(
|
|
26
|
-
new MethodNotImplementedError(PDFObject.name, 'copyBytesInto'),
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
});
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { PDFContext, PDFDict, PDFRawStream } from '../../../src/core';
|
|
2
|
-
import { mergeIntoTypedArray, toCharCode } from '../../../src/utils';
|
|
3
|
-
|
|
4
|
-
describe(`PDFRawStream`, () => {
|
|
5
|
-
const context = PDFContext.create();
|
|
6
|
-
const dict = PDFDict.withContext(context);
|
|
7
|
-
const data = new Uint8Array([12, 39, 92, 38, 38, 28, 49]);
|
|
8
|
-
|
|
9
|
-
it(`can be constructed from PDFRawStream.of(...)`, () => {
|
|
10
|
-
expect(PDFRawStream.of(dict, data)).toBeInstanceOf(PDFRawStream);
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it(`can be converted to a Uint8Array`, () => {
|
|
14
|
-
expect(PDFRawStream.of(dict, data).asUint8Array()).toEqual(data);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it(`can be cloned`, () => {
|
|
18
|
-
const original = PDFRawStream.of(dict, data);
|
|
19
|
-
const clone = original.clone();
|
|
20
|
-
expect(clone).not.toBe(original);
|
|
21
|
-
expect(clone.toString()).toEqual(original.toString());
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it(`can be converted to a string`, () => {
|
|
25
|
-
expect(String(PDFRawStream.of(dict, data))).toEqual(
|
|
26
|
-
`<<\n/Length 7\n>>\nstream\n\f'\\&&\u001c1\nendstream`,
|
|
27
|
-
);
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
it(`can provide its size in bytes`, () => {
|
|
31
|
-
expect(PDFRawStream.of(dict, data).sizeInBytes()).toBe(40);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
it(`can be serialized`, () => {
|
|
35
|
-
const buffer = new Uint8Array(44).fill(toCharCode(' '));
|
|
36
|
-
expect(PDFRawStream.of(dict, data).copyBytesInto(buffer, 3));
|
|
37
|
-
expect(buffer).toEqual(
|
|
38
|
-
mergeIntoTypedArray(
|
|
39
|
-
' <<\n/Length 7\n>>\nstream\n',
|
|
40
|
-
data,
|
|
41
|
-
'\nendstream ',
|
|
42
|
-
),
|
|
43
|
-
);
|
|
44
|
-
});
|
|
45
|
-
});
|
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { PDFRef, PrivateConstructorError } from '../../../src/core';
|
|
2
|
-
import { toCharCode, typedArrayFor } from '../../../src/utils';
|
|
3
|
-
|
|
4
|
-
describe(`PDFRef`, () => {
|
|
5
|
-
it(`can be constructed from PDFRef.of(...)`, () => {
|
|
6
|
-
expect(PDFRef.of(0)).toBeInstanceOf(PDFRef);
|
|
7
|
-
expect(PDFRef.of(0, 21)).toBeInstanceOf(PDFRef);
|
|
8
|
-
expect(PDFRef.of(94, 0)).toBeInstanceOf(PDFRef);
|
|
9
|
-
expect(PDFRef.of(4678, 9120)).toBeInstanceOf(PDFRef);
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
it(`cannot be publicly constructed`, () => {
|
|
13
|
-
expect(() => new (PDFRef as any)({}, 'stuff')).toThrow(
|
|
14
|
-
new PrivateConstructorError(PDFRef.name),
|
|
15
|
-
);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
it(`returns the same instance when given the same object and generation numbers`, () => {
|
|
19
|
-
expect(PDFRef.of(0)).toBe(PDFRef.of(0));
|
|
20
|
-
expect(PDFRef.of(0, 21)).toBe(PDFRef.of(0, 21));
|
|
21
|
-
expect(PDFRef.of(94, 0)).toBe(PDFRef.of(94, 0));
|
|
22
|
-
expect(PDFRef.of(4678, 9120)).toBe(PDFRef.of(4678, 9120));
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
it(`can be cloned`, () => {
|
|
26
|
-
expect(PDFRef.of(4678, 9120).clone()).toBe(PDFRef.of(4678, 9120));
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
it(`can be converted to a string`, () => {
|
|
30
|
-
expect(String(PDFRef.of(0))).toBe(`0 0 R`);
|
|
31
|
-
expect(String(PDFRef.of(0, 21))).toBe(`0 21 R`);
|
|
32
|
-
expect(String(PDFRef.of(94, 0))).toBe(`94 0 R`);
|
|
33
|
-
expect(String(PDFRef.of(4678, 9120))).toBe(`4678 9120 R`);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it(`can provide its size in bytes`, () => {
|
|
37
|
-
expect(PDFRef.of(0).sizeInBytes()).toBe(5);
|
|
38
|
-
expect(PDFRef.of(0, 21).sizeInBytes()).toBe(6);
|
|
39
|
-
expect(PDFRef.of(94, 0).sizeInBytes()).toBe(6);
|
|
40
|
-
expect(PDFRef.of(4678, 9120).sizeInBytes()).toBe(11);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it(`can be serialized`, () => {
|
|
44
|
-
const buffer1 = new Uint8Array(9).fill(toCharCode(' '));
|
|
45
|
-
expect(PDFRef.of(0).copyBytesInto(buffer1, 3)).toBe(5);
|
|
46
|
-
expect(buffer1).toEqual(typedArrayFor(' 0 0 R '));
|
|
47
|
-
|
|
48
|
-
const buffer2 = new Uint8Array(9).fill(toCharCode(' '));
|
|
49
|
-
expect(PDFRef.of(0, 21).copyBytesInto(buffer2, 1)).toBe(6);
|
|
50
|
-
expect(buffer2).toEqual(typedArrayFor(' 0 21 R '));
|
|
51
|
-
|
|
52
|
-
const buffer3 = new Uint8Array(9).fill(toCharCode(' '));
|
|
53
|
-
expect(PDFRef.of(94, 0).copyBytesInto(buffer3, 2)).toBe(6);
|
|
54
|
-
expect(buffer3).toEqual(typedArrayFor(' 94 0 R '));
|
|
55
|
-
|
|
56
|
-
const buffer4 = new Uint8Array(13).fill(toCharCode(' '));
|
|
57
|
-
expect(PDFRef.of(4678, 9120).copyBytesInto(buffer4, 0)).toBe(11);
|
|
58
|
-
expect(buffer4).toEqual(typedArrayFor('4678 9120 R '));
|
|
59
|
-
});
|
|
60
|
-
});
|
|
@@ -1,237 +0,0 @@
|
|
|
1
|
-
import { PDFString } from '../../../src/core';
|
|
2
|
-
import { toCharCode, typedArrayFor } from '../../../src/utils';
|
|
3
|
-
|
|
4
|
-
describe(`PDFString`, () => {
|
|
5
|
-
it(`can be constructed from PDFString.of(...)`, () => {
|
|
6
|
-
expect(PDFString.of('foobar')).toBeInstanceOf(PDFString);
|
|
7
|
-
expect(PDFString.of(' (foo(bar))')).toBeInstanceOf(PDFString);
|
|
8
|
-
expect(PDFString.of(')b\\a/z(')).toBeInstanceOf(PDFString);
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it(`can be constructed from a Date object`, () => {
|
|
12
|
-
const date1 = new Date('2018-06-24T01:58:37.228Z');
|
|
13
|
-
expect(String(PDFString.fromDate(date1))).toBe('(D:20180624015837Z)');
|
|
14
|
-
|
|
15
|
-
const date2 = new Date('2019-12-21T07:00:11.000Z');
|
|
16
|
-
expect(String(PDFString.fromDate(date2))).toBe('(D:20191221070011Z)');
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
it(`can be converted to a string`, () => {
|
|
20
|
-
expect(PDFString.of('foobar').asString()).toBe('foobar');
|
|
21
|
-
|
|
22
|
-
const date = new Date('2018-06-24T01:58:37.228Z');
|
|
23
|
-
expect(PDFString.fromDate(date).asString()).toBe('D:20180624015837Z');
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it(`can be cloned`, () => {
|
|
27
|
-
const original = PDFString.of(')b\\a/z(');
|
|
28
|
-
const clone = original.clone();
|
|
29
|
-
expect(clone).not.toBe(original);
|
|
30
|
-
expect(clone.toString()).toBe(original.toString());
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
describe(`conversion to string`, () => {
|
|
34
|
-
it(`can be converted to a string`, () => {
|
|
35
|
-
expect(String(PDFString.of('foobar'))).toBe('(foobar)');
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
it(`does not escape backslashes`, () => {
|
|
39
|
-
expect(String(PDFString.of('Foo\\Bar\\Qux'))).toBe('(Foo\\Bar\\Qux)');
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
it(`does not escape nested parenthesis`, () => {
|
|
43
|
-
expect(String(PDFString.of('(Foo((Bar))Qux)'))).toBe('((Foo((Bar))Qux))');
|
|
44
|
-
});
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
describe(`converting to bytes`, () => {
|
|
48
|
-
it(`can interpret escaped octal codes`, () => {
|
|
49
|
-
const literal =
|
|
50
|
-
'\\376\\377\\000\\105\\000\\147\\000\\147\\000\\040\\330\\074\\337\\163';
|
|
51
|
-
|
|
52
|
-
// prettier-ignore
|
|
53
|
-
expect(PDFString.of(literal).asBytes()).toEqual(Uint8Array.of(
|
|
54
|
-
0o376, 0o377,
|
|
55
|
-
0o000, 0o105,
|
|
56
|
-
0o000, 0o147,
|
|
57
|
-
0o000, 0o147,
|
|
58
|
-
0o000, 0o040,
|
|
59
|
-
0o330, 0o074,
|
|
60
|
-
0o337, 0o163,
|
|
61
|
-
));
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it(`can interpret ASCII symbols`, () => {
|
|
65
|
-
const literal = '\\376\\377\0E\0g\0g\0 \\330<\\337s';
|
|
66
|
-
|
|
67
|
-
// prettier-ignore
|
|
68
|
-
expect(PDFString.of(literal).asBytes()).toEqual(Uint8Array.of(
|
|
69
|
-
0o376, 0o377,
|
|
70
|
-
toCharCode('\0'), toCharCode('E'),
|
|
71
|
-
toCharCode('\0'), toCharCode('g'),
|
|
72
|
-
toCharCode('\0'), toCharCode('g'),
|
|
73
|
-
toCharCode('\0'), toCharCode(' '),
|
|
74
|
-
0o330, toCharCode('<'),
|
|
75
|
-
0o337, toCharCode('s'),
|
|
76
|
-
));
|
|
77
|
-
});
|
|
78
|
-
|
|
79
|
-
it(`can ignore line breaks`, () => {
|
|
80
|
-
const literal = '\\376\\377\0E\\\n\\0g\0g\0 \\330<\\337s';
|
|
81
|
-
|
|
82
|
-
// prettier-ignore
|
|
83
|
-
expect(PDFString.of(literal).asBytes()).toEqual(Uint8Array.of(
|
|
84
|
-
0o376, 0o377,
|
|
85
|
-
toCharCode('\0'), toCharCode('E'),
|
|
86
|
-
toCharCode('\0'), toCharCode('g'),
|
|
87
|
-
toCharCode('\0'), toCharCode('g'),
|
|
88
|
-
toCharCode('\0'), toCharCode(' '),
|
|
89
|
-
0o330, toCharCode('<'),
|
|
90
|
-
0o337, toCharCode('s'),
|
|
91
|
-
));
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it(`can interpret EOLs and line breaks`, () => {
|
|
95
|
-
const literal = 'a\nb\rc\\\nd\\\re';
|
|
96
|
-
|
|
97
|
-
// prettier-ignore
|
|
98
|
-
expect(PDFString.of(literal).asBytes()).toEqual(Uint8Array.of(
|
|
99
|
-
toCharCode('a'), toCharCode('\n'),
|
|
100
|
-
toCharCode('b'), toCharCode('\r'),
|
|
101
|
-
toCharCode('c'), toCharCode('d'),
|
|
102
|
-
toCharCode('e'),
|
|
103
|
-
));
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it(`can interpret invalid escapes`, () => {
|
|
107
|
-
const literal = 'a\nb\rc\\xd\\;';
|
|
108
|
-
|
|
109
|
-
// prettier-ignore
|
|
110
|
-
expect(PDFString.of(literal).asBytes()).toEqual(Uint8Array.of(
|
|
111
|
-
toCharCode('a'), toCharCode('\n'),
|
|
112
|
-
toCharCode('b'), toCharCode('\r'),
|
|
113
|
-
toCharCode('c'), toCharCode('x'),
|
|
114
|
-
toCharCode('d'), toCharCode(';'),
|
|
115
|
-
));
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
describe(`decoding to string`, () => {
|
|
120
|
-
it(`can interpret UTF-16BE strings with escaped octal codes`, () => {
|
|
121
|
-
const literal =
|
|
122
|
-
'\\376\\377\\000\\105\\000\\147\\000\\147\\000\\040\\330\\074\\337\\163';
|
|
123
|
-
expect(PDFString.of(literal).decodeText()).toBe('Egg 🍳');
|
|
124
|
-
});
|
|
125
|
-
|
|
126
|
-
it(`can interpret UTF-16BE strings with ASCII symbols`, () => {
|
|
127
|
-
const literal = '\\376\\377\0E\0g\0g\0 \\330<\\337s';
|
|
128
|
-
expect(PDFString.of(literal).decodeText()).toBe('Egg 🍳');
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
it(`can interpret UTF-16BE strings with line breaks`, () => {
|
|
132
|
-
const literal = '\\376\\377\0E\\\n\\0g\0g\0 \\330<\\337s';
|
|
133
|
-
expect(PDFString.of(literal).decodeText()).toBe('Egg 🍳');
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
it(`can interpret UTF-16LE strings with escaped octal codes`, () => {
|
|
137
|
-
const literal =
|
|
138
|
-
'\\377\\376\\105\\000\\147\\000\\147\\000\\040\\000\\074\\330\\163\\337';
|
|
139
|
-
expect(PDFString.of(literal).decodeText()).toBe('Egg 🍳');
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it(`can interpret PDFDocEncoded strings`, () => {
|
|
143
|
-
const literal = 'a\\105b\\163\\0b6';
|
|
144
|
-
expect(PDFString.of(literal).decodeText()).toBe('aEbs\0b6');
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it(`can interpret PDFDocEncoded strings with EOLs and line breaks`, () => {
|
|
148
|
-
const literal = 'a\nb\rc\\\nd\\\re';
|
|
149
|
-
expect(PDFString.of(literal).decodeText()).toBe('a\nb\rcde');
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
it(`can interpret PDFDocEncoded strings with ignored escapes`, () => {
|
|
153
|
-
const literal = 'a\nb\rc\\xd\\;';
|
|
154
|
-
expect(PDFString.of(literal).decodeText()).toBe('a\nb\rcxd;');
|
|
155
|
-
});
|
|
156
|
-
});
|
|
157
|
-
|
|
158
|
-
describe(`decoding to date`, () => {
|
|
159
|
-
it(`can interpret date strings of the form D:YYYYMMDDHHmmSSOHH'mm`, () => {
|
|
160
|
-
expect(PDFString.of(`D:20200321165011+01'01`).decodeDate()).toStrictEqual(
|
|
161
|
-
new Date('2020-03-21T15:49:11Z'),
|
|
162
|
-
);
|
|
163
|
-
expect(PDFString.of(`D:20200321165011-01'01`).decodeDate()).toStrictEqual(
|
|
164
|
-
new Date('2020-03-21T17:51:11Z'),
|
|
165
|
-
);
|
|
166
|
-
expect(PDFString.of(`D:20200321165011Z00'00`).decodeDate()).toStrictEqual(
|
|
167
|
-
new Date('2020-03-21T16:50:11Z'),
|
|
168
|
-
);
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
it(`can interpret date strings of the form D:YYYYMMDDHHmmSSOHH`, () => {
|
|
172
|
-
expect(PDFString.of('D:20200321165011+01').decodeDate()).toStrictEqual(
|
|
173
|
-
new Date('2020-03-21T15:50:11Z'),
|
|
174
|
-
);
|
|
175
|
-
expect(PDFString.of('D:20200321165011-01').decodeDate()).toStrictEqual(
|
|
176
|
-
new Date('2020-03-21T17:50:11Z'),
|
|
177
|
-
);
|
|
178
|
-
expect(PDFString.of('D:20200321165011Z00').decodeDate()).toStrictEqual(
|
|
179
|
-
new Date('2020-03-21T16:50:11Z'),
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
it(`can interpret date strings of the form D:YYYYMMDDHHmmSSO`, () => {
|
|
184
|
-
expect(PDFString.of('D:20200321165011Z').decodeDate()).toStrictEqual(
|
|
185
|
-
new Date('2020-03-21T16:50:11Z'),
|
|
186
|
-
);
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it(`can interpret date strings of the form D:YYYYMMDDHHmmSS`, () => {
|
|
190
|
-
expect(PDFString.of('D:20200321165011').decodeDate()).toStrictEqual(
|
|
191
|
-
new Date('2020-03-21T16:50:11Z'),
|
|
192
|
-
);
|
|
193
|
-
});
|
|
194
|
-
|
|
195
|
-
it(`can interpret date strings of the form D:YYYYMMDDHHmm`, () => {
|
|
196
|
-
expect(PDFString.of('D:202003211650').decodeDate()).toStrictEqual(
|
|
197
|
-
new Date('2020-03-21T16:50:00Z'),
|
|
198
|
-
);
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
it(`can interpret date strings of the form D:YYYYMMDDHH`, () => {
|
|
202
|
-
expect(PDFString.of('D:2020032116').decodeDate()).toStrictEqual(
|
|
203
|
-
new Date('2020-03-21T16:00:00Z'),
|
|
204
|
-
);
|
|
205
|
-
});
|
|
206
|
-
|
|
207
|
-
it(`can interpret date strings of the form D:YYYYMMDD`, () => {
|
|
208
|
-
expect(PDFString.of('D:20200321').decodeDate()).toStrictEqual(
|
|
209
|
-
new Date('2020-03-21T00:00:00Z'),
|
|
210
|
-
);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it(`can interpret date strings of the form D:YYYYMM`, () => {
|
|
214
|
-
expect(PDFString.of('D:202003').decodeDate()).toStrictEqual(
|
|
215
|
-
new Date('2020-03-01T00:00:00Z'),
|
|
216
|
-
);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it(`can interpret date strings of the form D:YYYY`, () => {
|
|
220
|
-
expect(PDFString.of('D:2020').decodeDate()).toStrictEqual(
|
|
221
|
-
new Date('2020-01-01T00:00:00Z'),
|
|
222
|
-
);
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
it(`can provide its size in bytes`, () => {
|
|
227
|
-
expect(PDFString.of('foobar').sizeInBytes()).toBe(8);
|
|
228
|
-
expect(PDFString.of(' (foo(bar))').sizeInBytes()).toBe(13);
|
|
229
|
-
expect(PDFString.of(')b\\a/z(').sizeInBytes()).toBe(9);
|
|
230
|
-
});
|
|
231
|
-
|
|
232
|
-
it(`can be serialized`, () => {
|
|
233
|
-
const buffer = new Uint8Array(20).fill(toCharCode(' '));
|
|
234
|
-
expect(PDFString.of(')(b\\a/))z(').copyBytesInto(buffer, 3)).toBe(12);
|
|
235
|
-
expect(buffer).toEqual(typedArrayFor(' ()(b\\a/))z() '));
|
|
236
|
-
});
|
|
237
|
-
});
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
PDFNumber,
|
|
3
|
-
PDFOperator,
|
|
4
|
-
PDFOperatorNames as Ops,
|
|
5
|
-
PDFString,
|
|
6
|
-
toCharCode,
|
|
7
|
-
typedArrayFor,
|
|
8
|
-
} from '../../../src/index';
|
|
9
|
-
|
|
10
|
-
describe(`PDFOperator`, () => {
|
|
11
|
-
it(`can be constructed with args`, () => {
|
|
12
|
-
const str = PDFString.of('FooBar');
|
|
13
|
-
expect(PDFOperator.of(Ops.ShowText, [str])).toBeInstanceOf(PDFOperator);
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
it(`can be constructed without args`, () => {
|
|
17
|
-
expect(PDFOperator.of(Ops.BeginText)).toBeInstanceOf(PDFOperator);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it(`can be cloned without args`, () => {
|
|
21
|
-
const original = PDFOperator.of(Ops.ClipNonZero);
|
|
22
|
-
const clone = original.clone();
|
|
23
|
-
expect(clone).not.toBe(original);
|
|
24
|
-
expect(String(clone)).toBe(String(original));
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it(`can be cloned with args`, () => {
|
|
28
|
-
const original = PDFOperator.of(Ops.MoveText, [
|
|
29
|
-
PDFNumber.of(25),
|
|
30
|
-
PDFNumber.of(50),
|
|
31
|
-
]);
|
|
32
|
-
const clone = original.clone();
|
|
33
|
-
expect(clone).not.toBe(original);
|
|
34
|
-
expect(String(clone)).toBe(String(original));
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
it(`can be converted to a string without args`, () => {
|
|
38
|
-
expect(String(PDFOperator.of(Ops.ClosePath))).toBe('h');
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it(`can be converted to a string with args`, () => {
|
|
42
|
-
const op = PDFOperator.of(Ops.MoveText, [
|
|
43
|
-
PDFNumber.of(25.43),
|
|
44
|
-
PDFNumber.of(-50),
|
|
45
|
-
]);
|
|
46
|
-
expect(String(op)).toBe('25.43 -50 Td');
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
it(`can provide its size in bytes without args`, () => {
|
|
50
|
-
expect(PDFOperator.of(Ops.ClosePath).sizeInBytes()).toBe(1);
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
it(`can provide its size in bytes with args`, () => {
|
|
54
|
-
const op = PDFOperator.of(Ops.MoveText, [
|
|
55
|
-
PDFNumber.of(25.43),
|
|
56
|
-
PDFNumber.of(-50),
|
|
57
|
-
]);
|
|
58
|
-
expect(op.sizeInBytes()).toBe(12);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it(`can be serialized without args`, () => {
|
|
62
|
-
const op = PDFOperator.of(Ops.ClosePath);
|
|
63
|
-
const buffer = new Uint8Array(op.sizeInBytes() + 3).fill(toCharCode(' '));
|
|
64
|
-
expect(op.copyBytesInto(buffer, 2)).toBe(1);
|
|
65
|
-
expect(buffer).toEqual(typedArrayFor(' h '));
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
it(`can be serialized with args`, () => {
|
|
69
|
-
const op = PDFOperator.of(Ops.MoveText, [
|
|
70
|
-
PDFNumber.of(25.43),
|
|
71
|
-
PDFNumber.of(-50),
|
|
72
|
-
]);
|
|
73
|
-
const buffer = new Uint8Array(op.sizeInBytes() + 3).fill(toCharCode(' '));
|
|
74
|
-
expect(op.copyBytesInto(buffer, 2)).toBe(12);
|
|
75
|
-
expect(buffer).toEqual(typedArrayFor(' 25.43 -50 Td '));
|
|
76
|
-
});
|
|
77
|
-
});
|