@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
package/src/api/operations.ts
DELETED
|
@@ -1,873 +0,0 @@
|
|
|
1
|
-
import { Color, setFillingColor, setStrokingColor } from './colors';
|
|
2
|
-
import {
|
|
3
|
-
beginText,
|
|
4
|
-
closePath,
|
|
5
|
-
drawObject,
|
|
6
|
-
endText,
|
|
7
|
-
fill,
|
|
8
|
-
fillAndStroke,
|
|
9
|
-
lineTo,
|
|
10
|
-
moveTo,
|
|
11
|
-
nextLine,
|
|
12
|
-
popGraphicsState,
|
|
13
|
-
pushGraphicsState,
|
|
14
|
-
rotateAndSkewTextRadiansAndTranslate,
|
|
15
|
-
rotateRadians,
|
|
16
|
-
scale,
|
|
17
|
-
setFontAndSize,
|
|
18
|
-
setLineHeight,
|
|
19
|
-
setLineWidth,
|
|
20
|
-
showText,
|
|
21
|
-
skewRadians,
|
|
22
|
-
stroke,
|
|
23
|
-
translate,
|
|
24
|
-
LineCapStyle,
|
|
25
|
-
setLineCap,
|
|
26
|
-
rotateDegrees,
|
|
27
|
-
setGraphicsState,
|
|
28
|
-
setDashPattern,
|
|
29
|
-
beginMarkedContent,
|
|
30
|
-
endMarkedContent,
|
|
31
|
-
clip,
|
|
32
|
-
endPath,
|
|
33
|
-
appendBezierCurve,
|
|
34
|
-
FillRule,
|
|
35
|
-
fillEvenOdd,
|
|
36
|
-
concatTransformationMatrix,
|
|
37
|
-
} from './operators';
|
|
38
|
-
import { Rotation, degrees, toRadians } from './rotations';
|
|
39
|
-
import { svgPathToOperators } from './svgPath';
|
|
40
|
-
import { PDFHexString, PDFName, PDFNumber, PDFOperator } from '../core';
|
|
41
|
-
import { asNumber } from './objects';
|
|
42
|
-
import type { Space, TransformationMatrix } from '../types';
|
|
43
|
-
|
|
44
|
-
export interface DrawTextOptions {
|
|
45
|
-
color: Color;
|
|
46
|
-
font: string | PDFName;
|
|
47
|
-
size: number | PDFNumber;
|
|
48
|
-
rotate: Rotation;
|
|
49
|
-
xSkew: Rotation;
|
|
50
|
-
ySkew: Rotation;
|
|
51
|
-
x: number | PDFNumber;
|
|
52
|
-
y: number | PDFNumber;
|
|
53
|
-
graphicsState?: string | PDFName;
|
|
54
|
-
matrix?: TransformationMatrix;
|
|
55
|
-
clipSpaces?: Space[];
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const clipSpace = ({ topLeft, topRight, bottomRight, bottomLeft }: Space) => [
|
|
59
|
-
moveTo(topLeft.x, topLeft.y),
|
|
60
|
-
lineTo(topRight.x, topRight.y),
|
|
61
|
-
lineTo(bottomRight.x, bottomRight.y),
|
|
62
|
-
lineTo(bottomLeft.x, bottomLeft.y),
|
|
63
|
-
closePath(),
|
|
64
|
-
clip(),
|
|
65
|
-
endPath(),
|
|
66
|
-
];
|
|
67
|
-
const clipSpaces = (spaces: Space[]) => spaces.flatMap(clipSpace);
|
|
68
|
-
|
|
69
|
-
export const drawText = (line: PDFHexString, options: DrawTextOptions): PDFOperator[] =>
|
|
70
|
-
[
|
|
71
|
-
pushGraphicsState(),
|
|
72
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
73
|
-
beginText(),
|
|
74
|
-
setFillingColor(options.color),
|
|
75
|
-
setFontAndSize(options.font, options.size),
|
|
76
|
-
rotateAndSkewTextRadiansAndTranslate(
|
|
77
|
-
toRadians(options.rotate),
|
|
78
|
-
toRadians(options.xSkew),
|
|
79
|
-
toRadians(options.ySkew),
|
|
80
|
-
options.x,
|
|
81
|
-
options.y,
|
|
82
|
-
),
|
|
83
|
-
showText(line),
|
|
84
|
-
endText(),
|
|
85
|
-
popGraphicsState(),
|
|
86
|
-
].filter(Boolean) as PDFOperator[];
|
|
87
|
-
|
|
88
|
-
export interface DrawLinesOfTextOptions extends DrawTextOptions {
|
|
89
|
-
lineHeight: number | PDFNumber;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export const drawLinesOfText = (
|
|
93
|
-
lines: PDFHexString[],
|
|
94
|
-
options: DrawLinesOfTextOptions,
|
|
95
|
-
): PDFOperator[] => {
|
|
96
|
-
const operators = [
|
|
97
|
-
pushGraphicsState(),
|
|
98
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
99
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
100
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
101
|
-
beginText(),
|
|
102
|
-
setFillingColor(options.color),
|
|
103
|
-
setFontAndSize(options.font, options.size),
|
|
104
|
-
setLineHeight(options.lineHeight),
|
|
105
|
-
rotateAndSkewTextRadiansAndTranslate(
|
|
106
|
-
toRadians(options.rotate),
|
|
107
|
-
toRadians(options.xSkew),
|
|
108
|
-
toRadians(options.ySkew),
|
|
109
|
-
options.x,
|
|
110
|
-
options.y,
|
|
111
|
-
),
|
|
112
|
-
].filter(Boolean) as PDFOperator[];
|
|
113
|
-
|
|
114
|
-
for (let idx = 0, len = lines.length; idx < len; idx++) {
|
|
115
|
-
operators.push(showText(lines[idx]), nextLine());
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
operators.push(endText(), popGraphicsState());
|
|
119
|
-
return operators;
|
|
120
|
-
};
|
|
121
|
-
|
|
122
|
-
export const drawImage = (
|
|
123
|
-
name: string | PDFName,
|
|
124
|
-
options: {
|
|
125
|
-
x: number | PDFNumber;
|
|
126
|
-
y: number | PDFNumber;
|
|
127
|
-
width: number | PDFNumber;
|
|
128
|
-
height: number | PDFNumber;
|
|
129
|
-
rotate: Rotation;
|
|
130
|
-
xSkew: Rotation;
|
|
131
|
-
ySkew: Rotation;
|
|
132
|
-
graphicsState?: string | PDFName;
|
|
133
|
-
matrix?: TransformationMatrix;
|
|
134
|
-
clipSpaces?: Space[];
|
|
135
|
-
},
|
|
136
|
-
): PDFOperator[] =>
|
|
137
|
-
[
|
|
138
|
-
pushGraphicsState(),
|
|
139
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
140
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
141
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
142
|
-
translate(options.x, options.y),
|
|
143
|
-
rotateRadians(toRadians(options.rotate)),
|
|
144
|
-
scale(options.width, options.height),
|
|
145
|
-
skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),
|
|
146
|
-
drawObject(name),
|
|
147
|
-
popGraphicsState(),
|
|
148
|
-
].filter(Boolean) as PDFOperator[];
|
|
149
|
-
|
|
150
|
-
export const drawPage = (
|
|
151
|
-
name: string | PDFName,
|
|
152
|
-
options: {
|
|
153
|
-
x: number | PDFNumber;
|
|
154
|
-
y: number | PDFNumber;
|
|
155
|
-
xScale: number | PDFNumber;
|
|
156
|
-
yScale: number | PDFNumber;
|
|
157
|
-
rotate: Rotation;
|
|
158
|
-
xSkew: Rotation;
|
|
159
|
-
ySkew: Rotation;
|
|
160
|
-
graphicsState?: string | PDFName;
|
|
161
|
-
},
|
|
162
|
-
): PDFOperator[] =>
|
|
163
|
-
[
|
|
164
|
-
pushGraphicsState(),
|
|
165
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
166
|
-
translate(options.x, options.y),
|
|
167
|
-
rotateRadians(toRadians(options.rotate)),
|
|
168
|
-
scale(options.xScale, options.yScale),
|
|
169
|
-
skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),
|
|
170
|
-
drawObject(name),
|
|
171
|
-
popGraphicsState(),
|
|
172
|
-
].filter(Boolean) as PDFOperator[];
|
|
173
|
-
|
|
174
|
-
export const drawLine = (options: {
|
|
175
|
-
start: { x: number | PDFNumber; y: number | PDFNumber };
|
|
176
|
-
end: { x: number | PDFNumber; y: number | PDFNumber };
|
|
177
|
-
thickness: number | PDFNumber;
|
|
178
|
-
color: Color | undefined;
|
|
179
|
-
dashArray?: (number | PDFNumber)[];
|
|
180
|
-
dashPhase?: number | PDFNumber;
|
|
181
|
-
lineCap?: LineCapStyle;
|
|
182
|
-
graphicsState?: string | PDFName;
|
|
183
|
-
matrix?: TransformationMatrix;
|
|
184
|
-
clipSpaces?: Space[];
|
|
185
|
-
}) =>
|
|
186
|
-
[
|
|
187
|
-
pushGraphicsState(),
|
|
188
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
189
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
190
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
191
|
-
options.color && setStrokingColor(options.color),
|
|
192
|
-
setLineWidth(options.thickness),
|
|
193
|
-
setDashPattern(options.dashArray ?? [], options.dashPhase ?? 0),
|
|
194
|
-
moveTo(options.start.x, options.start.y),
|
|
195
|
-
options.lineCap && setLineCap(options.lineCap),
|
|
196
|
-
moveTo(options.start.x, options.start.y),
|
|
197
|
-
lineTo(options.end.x, options.end.y),
|
|
198
|
-
stroke(),
|
|
199
|
-
popGraphicsState(),
|
|
200
|
-
].filter(Boolean) as PDFOperator[];
|
|
201
|
-
|
|
202
|
-
export const drawRectangle = (options: {
|
|
203
|
-
x: number | PDFNumber;
|
|
204
|
-
y: number | PDFNumber;
|
|
205
|
-
width: number | PDFNumber;
|
|
206
|
-
height: number | PDFNumber;
|
|
207
|
-
borderWidth: number | PDFNumber;
|
|
208
|
-
color: Color | undefined;
|
|
209
|
-
borderColor: Color | undefined;
|
|
210
|
-
rotate: Rotation;
|
|
211
|
-
xSkew: Rotation;
|
|
212
|
-
ySkew: Rotation;
|
|
213
|
-
borderLineCap?: LineCapStyle;
|
|
214
|
-
borderDashArray?: (number | PDFNumber)[];
|
|
215
|
-
borderDashPhase?: number | PDFNumber;
|
|
216
|
-
graphicsState?: string | PDFName;
|
|
217
|
-
matrix?: TransformationMatrix;
|
|
218
|
-
clipSpaces?: Space[];
|
|
219
|
-
radius?: number | PDFNumber;
|
|
220
|
-
}) => {
|
|
221
|
-
let ops = [];
|
|
222
|
-
|
|
223
|
-
if (!options.radius || asNumber(options.radius) <= 0) {
|
|
224
|
-
ops = [
|
|
225
|
-
moveTo(0, 0),
|
|
226
|
-
lineTo(0, options.height),
|
|
227
|
-
lineTo(options.width, options.height),
|
|
228
|
-
lineTo(options.width, 0),
|
|
229
|
-
closePath(),
|
|
230
|
-
];
|
|
231
|
-
} else {
|
|
232
|
-
let radius = asNumber(options.radius);
|
|
233
|
-
const width = asNumber(options.width);
|
|
234
|
-
const height = asNumber(options.height);
|
|
235
|
-
|
|
236
|
-
if (radius > width / 2.0 || radius > height / 2.0) {
|
|
237
|
-
radius = Math.min(width / 2.0, height / 2.0);
|
|
238
|
-
}
|
|
239
|
-
const offset = KAPPA * radius;
|
|
240
|
-
ops = [
|
|
241
|
-
moveTo(0, radius),
|
|
242
|
-
appendBezierCurve(0, radius - offset, radius - offset, 0, radius, 0),
|
|
243
|
-
lineTo(width - radius, 0),
|
|
244
|
-
appendBezierCurve(width - radius + offset, 0, width, radius - offset, width, radius),
|
|
245
|
-
lineTo(width, height - radius),
|
|
246
|
-
appendBezierCurve(
|
|
247
|
-
width,
|
|
248
|
-
height - radius + offset,
|
|
249
|
-
width - radius + offset,
|
|
250
|
-
height,
|
|
251
|
-
width - radius,
|
|
252
|
-
height,
|
|
253
|
-
),
|
|
254
|
-
lineTo(radius, height),
|
|
255
|
-
appendBezierCurve(radius - offset, height, 0, height - radius + offset, 0, height - radius),
|
|
256
|
-
closePath(),
|
|
257
|
-
];
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
return [
|
|
261
|
-
pushGraphicsState(),
|
|
262
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
263
|
-
options.color && setFillingColor(options.color),
|
|
264
|
-
options.borderColor && setStrokingColor(options.borderColor),
|
|
265
|
-
setLineWidth(options.borderWidth),
|
|
266
|
-
options.borderLineCap && setLineCap(options.borderLineCap),
|
|
267
|
-
setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),
|
|
268
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
269
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
270
|
-
translate(options.x, options.y),
|
|
271
|
-
rotateRadians(toRadians(options.rotate)),
|
|
272
|
-
skewRadians(toRadians(options.xSkew), toRadians(options.ySkew)),
|
|
273
|
-
|
|
274
|
-
...ops,
|
|
275
|
-
|
|
276
|
-
// prettier-ignore
|
|
277
|
-
options.color && options.borderWidth ? fillAndStroke()
|
|
278
|
-
: options.color ? fill()
|
|
279
|
-
: options.borderColor ? stroke()
|
|
280
|
-
: closePath(),
|
|
281
|
-
|
|
282
|
-
popGraphicsState(),
|
|
283
|
-
].filter(Boolean) as PDFOperator[];
|
|
284
|
-
};
|
|
285
|
-
|
|
286
|
-
const KAPPA = 4.0 * ((Math.sqrt(2) - 1.0) / 3.0);
|
|
287
|
-
|
|
288
|
-
/** @deprecated */
|
|
289
|
-
export const drawEllipsePath = (config: {
|
|
290
|
-
x: number | PDFNumber;
|
|
291
|
-
y: number | PDFNumber;
|
|
292
|
-
xScale: number | PDFNumber;
|
|
293
|
-
yScale: number | PDFNumber;
|
|
294
|
-
}): PDFOperator[] => {
|
|
295
|
-
let x = asNumber(config.x);
|
|
296
|
-
let y = asNumber(config.y);
|
|
297
|
-
const xScale = asNumber(config.xScale);
|
|
298
|
-
const yScale = asNumber(config.yScale);
|
|
299
|
-
|
|
300
|
-
x -= xScale;
|
|
301
|
-
y -= yScale;
|
|
302
|
-
|
|
303
|
-
const ox = xScale * KAPPA;
|
|
304
|
-
const oy = yScale * KAPPA;
|
|
305
|
-
const xe = x + xScale * 2;
|
|
306
|
-
const ye = y + yScale * 2;
|
|
307
|
-
const xm = x + xScale;
|
|
308
|
-
const ym = y + yScale;
|
|
309
|
-
|
|
310
|
-
return [
|
|
311
|
-
pushGraphicsState(),
|
|
312
|
-
moveTo(x, ym),
|
|
313
|
-
appendBezierCurve(x, ym - oy, xm - ox, y, xm, y),
|
|
314
|
-
appendBezierCurve(xm + ox, y, xe, ym - oy, xe, ym),
|
|
315
|
-
appendBezierCurve(xe, ym + oy, xm + ox, ye, xm, ye),
|
|
316
|
-
appendBezierCurve(xm - ox, ye, x, ym + oy, x, ym),
|
|
317
|
-
popGraphicsState(),
|
|
318
|
-
];
|
|
319
|
-
};
|
|
320
|
-
|
|
321
|
-
const drawEllipseCurves = (config: {
|
|
322
|
-
x: number | PDFNumber;
|
|
323
|
-
y: number | PDFNumber;
|
|
324
|
-
xScale: number | PDFNumber;
|
|
325
|
-
yScale: number | PDFNumber;
|
|
326
|
-
rotate: Rotation;
|
|
327
|
-
}): PDFOperator[] => {
|
|
328
|
-
const centerX = asNumber(config.x);
|
|
329
|
-
const centerY = asNumber(config.y);
|
|
330
|
-
const xScale = asNumber(config.xScale);
|
|
331
|
-
const yScale = asNumber(config.yScale);
|
|
332
|
-
|
|
333
|
-
const x = -xScale;
|
|
334
|
-
const y = -yScale;
|
|
335
|
-
|
|
336
|
-
const ox = xScale * KAPPA;
|
|
337
|
-
const oy = yScale * KAPPA;
|
|
338
|
-
const xe = x + xScale * 2;
|
|
339
|
-
const ye = y + yScale * 2;
|
|
340
|
-
const xm = x + xScale;
|
|
341
|
-
const ym = y + yScale;
|
|
342
|
-
|
|
343
|
-
return [
|
|
344
|
-
translate(centerX, centerY),
|
|
345
|
-
rotateRadians(toRadians(config.rotate)),
|
|
346
|
-
moveTo(x, ym),
|
|
347
|
-
appendBezierCurve(x, ym - oy, xm - ox, y, xm, y),
|
|
348
|
-
appendBezierCurve(xm + ox, y, xe, ym - oy, xe, ym),
|
|
349
|
-
appendBezierCurve(xe, ym + oy, xm + ox, ye, xm, ye),
|
|
350
|
-
appendBezierCurve(xm - ox, ye, x, ym + oy, x, ym),
|
|
351
|
-
];
|
|
352
|
-
};
|
|
353
|
-
|
|
354
|
-
export const drawEllipse = (options: {
|
|
355
|
-
x: number | PDFNumber;
|
|
356
|
-
y: number | PDFNumber;
|
|
357
|
-
xScale: number | PDFNumber;
|
|
358
|
-
yScale: number | PDFNumber;
|
|
359
|
-
rotate?: Rotation;
|
|
360
|
-
color: Color | undefined;
|
|
361
|
-
borderColor: Color | undefined;
|
|
362
|
-
borderWidth: number | PDFNumber;
|
|
363
|
-
borderDashArray?: (number | PDFNumber)[];
|
|
364
|
-
borderDashPhase?: number | PDFNumber;
|
|
365
|
-
graphicsState?: string | PDFName;
|
|
366
|
-
borderLineCap?: LineCapStyle;
|
|
367
|
-
matrix?: TransformationMatrix;
|
|
368
|
-
clipSpaces?: Space[];
|
|
369
|
-
}) =>
|
|
370
|
-
[
|
|
371
|
-
pushGraphicsState(),
|
|
372
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
373
|
-
options.color && setFillingColor(options.color),
|
|
374
|
-
options.borderColor && setStrokingColor(options.borderColor),
|
|
375
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
376
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
377
|
-
setLineWidth(options.borderWidth),
|
|
378
|
-
options.borderLineCap && setLineCap(options.borderLineCap),
|
|
379
|
-
setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),
|
|
380
|
-
|
|
381
|
-
// The `drawEllipsePath` branch is only here for backwards compatibility.
|
|
382
|
-
// See https://github.com/Hopding/pdf-lib/pull/511#issuecomment-667685655.
|
|
383
|
-
...(options.rotate === undefined
|
|
384
|
-
? drawEllipsePath({
|
|
385
|
-
x: options.x,
|
|
386
|
-
y: options.y,
|
|
387
|
-
xScale: options.xScale,
|
|
388
|
-
yScale: options.yScale,
|
|
389
|
-
})
|
|
390
|
-
: drawEllipseCurves({
|
|
391
|
-
x: options.x,
|
|
392
|
-
y: options.y,
|
|
393
|
-
xScale: options.xScale,
|
|
394
|
-
yScale: options.yScale,
|
|
395
|
-
rotate: options.rotate ?? degrees(0),
|
|
396
|
-
})),
|
|
397
|
-
|
|
398
|
-
// prettier-ignore
|
|
399
|
-
options.color && options.borderWidth ? fillAndStroke()
|
|
400
|
-
: options.color ? fill()
|
|
401
|
-
: options.borderColor ? stroke()
|
|
402
|
-
: closePath(),
|
|
403
|
-
|
|
404
|
-
popGraphicsState(),
|
|
405
|
-
].filter(Boolean) as PDFOperator[];
|
|
406
|
-
|
|
407
|
-
export const drawSvgPath = (
|
|
408
|
-
path: string,
|
|
409
|
-
options: {
|
|
410
|
-
x: number | PDFNumber;
|
|
411
|
-
y: number | PDFNumber;
|
|
412
|
-
rotate?: Rotation;
|
|
413
|
-
scale: number | PDFNumber | undefined;
|
|
414
|
-
color: Color | undefined;
|
|
415
|
-
borderColor: Color | undefined;
|
|
416
|
-
borderWidth: number | PDFNumber;
|
|
417
|
-
borderDashArray?: (number | PDFNumber)[];
|
|
418
|
-
borderDashPhase?: number | PDFNumber;
|
|
419
|
-
borderLineCap?: LineCapStyle;
|
|
420
|
-
graphicsState?: string | PDFName;
|
|
421
|
-
fillRule?: FillRule;
|
|
422
|
-
matrix?: TransformationMatrix;
|
|
423
|
-
clipSpaces?: Space[];
|
|
424
|
-
},
|
|
425
|
-
) =>
|
|
426
|
-
[
|
|
427
|
-
pushGraphicsState(),
|
|
428
|
-
options.graphicsState && setGraphicsState(options.graphicsState),
|
|
429
|
-
...(options.clipSpaces ? clipSpaces(options.clipSpaces) : []),
|
|
430
|
-
options.matrix && concatTransformationMatrix(...options.matrix),
|
|
431
|
-
|
|
432
|
-
translate(options.x, options.y),
|
|
433
|
-
rotateRadians(toRadians(options.rotate ?? degrees(0))),
|
|
434
|
-
|
|
435
|
-
options.scale && scale(options.scale, options.scale),
|
|
436
|
-
options.color && setFillingColor(options.color),
|
|
437
|
-
options.borderColor && setStrokingColor(options.borderColor),
|
|
438
|
-
options.borderWidth && setLineWidth(options.borderWidth),
|
|
439
|
-
options.borderLineCap && setLineCap(options.borderLineCap),
|
|
440
|
-
|
|
441
|
-
setDashPattern(options.borderDashArray ?? [], options.borderDashPhase ?? 0),
|
|
442
|
-
|
|
443
|
-
...svgPathToOperators(path),
|
|
444
|
-
|
|
445
|
-
// prettier-ignore
|
|
446
|
-
options.color && options.borderWidth ? fillAndStroke()
|
|
447
|
-
: options.color ? options.fillRule === FillRule.EvenOdd ? fillEvenOdd() : fill()
|
|
448
|
-
: options.borderColor ? stroke()
|
|
449
|
-
: closePath(),
|
|
450
|
-
|
|
451
|
-
popGraphicsState(),
|
|
452
|
-
].filter(Boolean) as PDFOperator[];
|
|
453
|
-
|
|
454
|
-
export const drawCheckMark = (options: {
|
|
455
|
-
x: number | PDFNumber;
|
|
456
|
-
y: number | PDFNumber;
|
|
457
|
-
size: number | PDFNumber;
|
|
458
|
-
thickness: number | PDFNumber;
|
|
459
|
-
color: Color | undefined;
|
|
460
|
-
}) => {
|
|
461
|
-
const size = asNumber(options.size);
|
|
462
|
-
|
|
463
|
-
/*********************** Define Check Mark Points ***************************/
|
|
464
|
-
// A check mark is defined by three points in some coordinate space. Here, we
|
|
465
|
-
// define these points in a unit coordinate system, where the range of the x
|
|
466
|
-
// and y axis are both [-1, 1].
|
|
467
|
-
//
|
|
468
|
-
// Note that we do not hard code `p1y` in case we wish to change the
|
|
469
|
-
// size/shape of the check mark in the future. We want the check mark to
|
|
470
|
-
// always form a right angle. This means that the dot product between (p1-p2)
|
|
471
|
-
// and (p3-p2) should be zero:
|
|
472
|
-
//
|
|
473
|
-
// (p1x-p2x) * (p3x-p2x) + (p1y-p2y) * (p3y-p2y) = 0
|
|
474
|
-
//
|
|
475
|
-
// We can now rejigger this equation to solve for `p1y`:
|
|
476
|
-
//
|
|
477
|
-
// (p1y-p2y) * (p3y-p2y) = -((p1x-p2x) * (p3x-p2x))
|
|
478
|
-
// (p1y-p2y) = -((p1x-p2x) * (p3x-p2x)) / (p3y-p2y)
|
|
479
|
-
// p1y = -((p1x-p2x) * (p3x-p2x)) / (p3y-p2y) + p2y
|
|
480
|
-
//
|
|
481
|
-
// Thanks to my friend Joel Walker (https://github.com/JWalker1995) for
|
|
482
|
-
// devising the above equation and unit coordinate system approach!
|
|
483
|
-
|
|
484
|
-
// (x, y) coords of the check mark's bottommost point
|
|
485
|
-
const p2x = -1 + 0.75;
|
|
486
|
-
const p2y = -1 + 0.51;
|
|
487
|
-
|
|
488
|
-
// (x, y) coords of the check mark's topmost point
|
|
489
|
-
const p3y = 1 - 0.525;
|
|
490
|
-
const p3x = 1 - 0.31;
|
|
491
|
-
|
|
492
|
-
// (x, y) coords of the check mark's center (vertically) point
|
|
493
|
-
const p1x = -1 + 0.325;
|
|
494
|
-
const p1y = -((p1x - p2x) * (p3x - p2x)) / (p3y - p2y) + p2y;
|
|
495
|
-
/****************************************************************************/
|
|
496
|
-
|
|
497
|
-
return [
|
|
498
|
-
pushGraphicsState(),
|
|
499
|
-
options.color && setStrokingColor(options.color),
|
|
500
|
-
setLineWidth(options.thickness),
|
|
501
|
-
|
|
502
|
-
translate(options.x, options.y),
|
|
503
|
-
moveTo(p1x * size, p1y * size),
|
|
504
|
-
lineTo(p2x * size, p2y * size),
|
|
505
|
-
lineTo(p3x * size, p3y * size),
|
|
506
|
-
|
|
507
|
-
stroke(),
|
|
508
|
-
popGraphicsState(),
|
|
509
|
-
].filter(Boolean) as PDFOperator[];
|
|
510
|
-
};
|
|
511
|
-
|
|
512
|
-
// prettier-ignore
|
|
513
|
-
export const rotateInPlace = (options: {
|
|
514
|
-
width: number | PDFNumber;
|
|
515
|
-
height: number | PDFNumber;
|
|
516
|
-
rotation: 0 | 90 | 180 | 270;
|
|
517
|
-
}) =>
|
|
518
|
-
options.rotation === 0 ? [
|
|
519
|
-
translate(0, 0),
|
|
520
|
-
rotateDegrees(0)
|
|
521
|
-
]
|
|
522
|
-
: options.rotation === 90 ? [
|
|
523
|
-
translate(options.width, 0),
|
|
524
|
-
rotateDegrees(90)
|
|
525
|
-
]
|
|
526
|
-
: options.rotation === 180 ? [
|
|
527
|
-
translate(options.width, options.height),
|
|
528
|
-
rotateDegrees(180)
|
|
529
|
-
]
|
|
530
|
-
: options.rotation === 270 ? [
|
|
531
|
-
translate(0, options.height),
|
|
532
|
-
rotateDegrees(270)
|
|
533
|
-
]
|
|
534
|
-
: []; // Invalid rotation - noop
|
|
535
|
-
|
|
536
|
-
export const drawCheckBox = (options: {
|
|
537
|
-
x: number | PDFNumber;
|
|
538
|
-
y: number | PDFNumber;
|
|
539
|
-
width: number | PDFNumber;
|
|
540
|
-
height: number | PDFNumber;
|
|
541
|
-
thickness: number | PDFNumber;
|
|
542
|
-
borderWidth: number | PDFNumber;
|
|
543
|
-
markColor: Color | undefined;
|
|
544
|
-
color: Color | undefined;
|
|
545
|
-
borderColor: Color | undefined;
|
|
546
|
-
filled: boolean;
|
|
547
|
-
}) => {
|
|
548
|
-
const outline = drawRectangle({
|
|
549
|
-
x: options.x,
|
|
550
|
-
y: options.y,
|
|
551
|
-
width: options.width,
|
|
552
|
-
height: options.height,
|
|
553
|
-
borderWidth: options.borderWidth,
|
|
554
|
-
color: options.color,
|
|
555
|
-
borderColor: options.borderColor,
|
|
556
|
-
rotate: degrees(0),
|
|
557
|
-
xSkew: degrees(0),
|
|
558
|
-
ySkew: degrees(0),
|
|
559
|
-
});
|
|
560
|
-
|
|
561
|
-
if (!options.filled) return outline;
|
|
562
|
-
|
|
563
|
-
const width = asNumber(options.width);
|
|
564
|
-
const height = asNumber(options.height);
|
|
565
|
-
|
|
566
|
-
const checkMarkSize = Math.min(width, height) / 2;
|
|
567
|
-
|
|
568
|
-
const checkMark = drawCheckMark({
|
|
569
|
-
x: width / 2,
|
|
570
|
-
y: height / 2,
|
|
571
|
-
size: checkMarkSize,
|
|
572
|
-
thickness: options.thickness,
|
|
573
|
-
color: options.markColor,
|
|
574
|
-
});
|
|
575
|
-
|
|
576
|
-
return [pushGraphicsState(), ...outline, ...checkMark, popGraphicsState()];
|
|
577
|
-
};
|
|
578
|
-
|
|
579
|
-
export const drawRadioButton = (options: {
|
|
580
|
-
x: number | PDFNumber;
|
|
581
|
-
y: number | PDFNumber;
|
|
582
|
-
width: number | PDFNumber;
|
|
583
|
-
height: number | PDFNumber;
|
|
584
|
-
borderWidth: number | PDFNumber;
|
|
585
|
-
dotColor: Color | undefined;
|
|
586
|
-
color: Color | undefined;
|
|
587
|
-
borderColor: Color | undefined;
|
|
588
|
-
filled: boolean;
|
|
589
|
-
}) => {
|
|
590
|
-
const width = asNumber(options.width);
|
|
591
|
-
const height = asNumber(options.height);
|
|
592
|
-
|
|
593
|
-
const outlineScale = Math.min(width, height) / 2;
|
|
594
|
-
|
|
595
|
-
const outline = drawEllipse({
|
|
596
|
-
x: options.x,
|
|
597
|
-
y: options.y,
|
|
598
|
-
xScale: outlineScale,
|
|
599
|
-
yScale: outlineScale,
|
|
600
|
-
color: options.color,
|
|
601
|
-
borderColor: options.borderColor,
|
|
602
|
-
borderWidth: options.borderWidth,
|
|
603
|
-
});
|
|
604
|
-
|
|
605
|
-
if (!options.filled) return outline;
|
|
606
|
-
|
|
607
|
-
const dot = drawEllipse({
|
|
608
|
-
x: options.x,
|
|
609
|
-
y: options.y,
|
|
610
|
-
xScale: outlineScale * 0.45,
|
|
611
|
-
yScale: outlineScale * 0.45,
|
|
612
|
-
color: options.dotColor,
|
|
613
|
-
borderColor: undefined,
|
|
614
|
-
borderWidth: 0,
|
|
615
|
-
});
|
|
616
|
-
|
|
617
|
-
return [pushGraphicsState(), ...outline, ...dot, popGraphicsState()];
|
|
618
|
-
};
|
|
619
|
-
|
|
620
|
-
export const drawButton = (options: {
|
|
621
|
-
x: number | PDFNumber;
|
|
622
|
-
y: number | PDFNumber;
|
|
623
|
-
width: number | PDFNumber;
|
|
624
|
-
height: number | PDFNumber;
|
|
625
|
-
borderWidth: number | PDFNumber;
|
|
626
|
-
color: Color | undefined;
|
|
627
|
-
borderColor: Color | undefined;
|
|
628
|
-
textLines: { encoded: PDFHexString; x: number; y: number }[];
|
|
629
|
-
textColor: Color;
|
|
630
|
-
font: string | PDFName;
|
|
631
|
-
fontSize: number | PDFNumber;
|
|
632
|
-
}) => {
|
|
633
|
-
const x = asNumber(options.x);
|
|
634
|
-
const y = asNumber(options.y);
|
|
635
|
-
const width = asNumber(options.width);
|
|
636
|
-
const height = asNumber(options.height);
|
|
637
|
-
|
|
638
|
-
const background = drawRectangle({
|
|
639
|
-
x,
|
|
640
|
-
y,
|
|
641
|
-
width,
|
|
642
|
-
height,
|
|
643
|
-
borderWidth: options.borderWidth,
|
|
644
|
-
color: options.color,
|
|
645
|
-
borderColor: options.borderColor,
|
|
646
|
-
rotate: degrees(0),
|
|
647
|
-
xSkew: degrees(0),
|
|
648
|
-
ySkew: degrees(0),
|
|
649
|
-
});
|
|
650
|
-
|
|
651
|
-
const lines = drawTextLines(options.textLines, {
|
|
652
|
-
color: options.textColor,
|
|
653
|
-
font: options.font,
|
|
654
|
-
size: options.fontSize,
|
|
655
|
-
rotate: degrees(0),
|
|
656
|
-
xSkew: degrees(0),
|
|
657
|
-
ySkew: degrees(0),
|
|
658
|
-
});
|
|
659
|
-
|
|
660
|
-
return [pushGraphicsState(), ...background, ...lines, popGraphicsState()];
|
|
661
|
-
};
|
|
662
|
-
|
|
663
|
-
export interface DrawTextLinesOptions {
|
|
664
|
-
color: Color;
|
|
665
|
-
font: string | PDFName;
|
|
666
|
-
size: number | PDFNumber;
|
|
667
|
-
rotate: Rotation;
|
|
668
|
-
xSkew: Rotation;
|
|
669
|
-
ySkew: Rotation;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
export const drawTextLines = (
|
|
673
|
-
lines: { encoded: PDFHexString; x: number; y: number }[],
|
|
674
|
-
options: DrawTextLinesOptions,
|
|
675
|
-
): PDFOperator[] => {
|
|
676
|
-
const operators = [
|
|
677
|
-
beginText(),
|
|
678
|
-
setFillingColor(options.color),
|
|
679
|
-
setFontAndSize(options.font, options.size),
|
|
680
|
-
];
|
|
681
|
-
|
|
682
|
-
for (let idx = 0, len = lines.length; idx < len; idx++) {
|
|
683
|
-
const { encoded, x, y } = lines[idx];
|
|
684
|
-
operators.push(
|
|
685
|
-
rotateAndSkewTextRadiansAndTranslate(
|
|
686
|
-
toRadians(options.rotate),
|
|
687
|
-
toRadians(options.xSkew),
|
|
688
|
-
toRadians(options.ySkew),
|
|
689
|
-
x,
|
|
690
|
-
y,
|
|
691
|
-
),
|
|
692
|
-
showText(encoded),
|
|
693
|
-
);
|
|
694
|
-
}
|
|
695
|
-
|
|
696
|
-
operators.push(endText());
|
|
697
|
-
|
|
698
|
-
return operators;
|
|
699
|
-
};
|
|
700
|
-
|
|
701
|
-
export const drawTextField = (options: {
|
|
702
|
-
x: number | PDFNumber;
|
|
703
|
-
y: number | PDFNumber;
|
|
704
|
-
width: number | PDFNumber;
|
|
705
|
-
height: number | PDFNumber;
|
|
706
|
-
borderWidth: number | PDFNumber;
|
|
707
|
-
color: Color | undefined;
|
|
708
|
-
borderColor: Color | undefined;
|
|
709
|
-
textLines: { encoded: PDFHexString; x: number; y: number }[];
|
|
710
|
-
textColor: Color;
|
|
711
|
-
font: string | PDFName;
|
|
712
|
-
fontSize: number | PDFNumber;
|
|
713
|
-
padding: number | PDFNumber;
|
|
714
|
-
}) => {
|
|
715
|
-
const x = asNumber(options.x);
|
|
716
|
-
const y = asNumber(options.y);
|
|
717
|
-
const width = asNumber(options.width);
|
|
718
|
-
const height = asNumber(options.height);
|
|
719
|
-
const borderWidth = asNumber(options.borderWidth);
|
|
720
|
-
const padding = asNumber(options.padding);
|
|
721
|
-
|
|
722
|
-
const clipX = x + borderWidth / 2 + padding;
|
|
723
|
-
const clipY = y + borderWidth / 2 + padding;
|
|
724
|
-
const clipWidth = width - (borderWidth / 2 + padding) * 2;
|
|
725
|
-
const clipHeight = height - (borderWidth / 2 + padding) * 2;
|
|
726
|
-
|
|
727
|
-
const clippingArea = [
|
|
728
|
-
moveTo(clipX, clipY),
|
|
729
|
-
lineTo(clipX, clipY + clipHeight),
|
|
730
|
-
lineTo(clipX + clipWidth, clipY + clipHeight),
|
|
731
|
-
lineTo(clipX + clipWidth, clipY),
|
|
732
|
-
closePath(),
|
|
733
|
-
clip(),
|
|
734
|
-
endPath(),
|
|
735
|
-
];
|
|
736
|
-
|
|
737
|
-
const background = drawRectangle({
|
|
738
|
-
x,
|
|
739
|
-
y,
|
|
740
|
-
width,
|
|
741
|
-
height,
|
|
742
|
-
borderWidth: options.borderWidth,
|
|
743
|
-
color: options.color,
|
|
744
|
-
borderColor: options.borderColor,
|
|
745
|
-
rotate: degrees(0),
|
|
746
|
-
xSkew: degrees(0),
|
|
747
|
-
ySkew: degrees(0),
|
|
748
|
-
});
|
|
749
|
-
|
|
750
|
-
const lines = drawTextLines(options.textLines, {
|
|
751
|
-
color: options.textColor,
|
|
752
|
-
font: options.font,
|
|
753
|
-
size: options.fontSize,
|
|
754
|
-
rotate: degrees(0),
|
|
755
|
-
xSkew: degrees(0),
|
|
756
|
-
ySkew: degrees(0),
|
|
757
|
-
});
|
|
758
|
-
|
|
759
|
-
const markedContent = [
|
|
760
|
-
beginMarkedContent('Tx'),
|
|
761
|
-
pushGraphicsState(),
|
|
762
|
-
...lines,
|
|
763
|
-
popGraphicsState(),
|
|
764
|
-
endMarkedContent(),
|
|
765
|
-
];
|
|
766
|
-
|
|
767
|
-
return [
|
|
768
|
-
pushGraphicsState(),
|
|
769
|
-
...background,
|
|
770
|
-
...clippingArea,
|
|
771
|
-
...markedContent,
|
|
772
|
-
popGraphicsState(),
|
|
773
|
-
];
|
|
774
|
-
};
|
|
775
|
-
|
|
776
|
-
export const drawOptionList = (options: {
|
|
777
|
-
x: number | PDFNumber;
|
|
778
|
-
y: number | PDFNumber;
|
|
779
|
-
width: number | PDFNumber;
|
|
780
|
-
height: number | PDFNumber;
|
|
781
|
-
borderWidth: number | PDFNumber;
|
|
782
|
-
color: Color | undefined;
|
|
783
|
-
borderColor: Color | undefined;
|
|
784
|
-
textLines: { encoded: PDFHexString; x: number; y: number; height: number }[];
|
|
785
|
-
textColor: Color;
|
|
786
|
-
font: string | PDFName;
|
|
787
|
-
fontSize: number | PDFNumber;
|
|
788
|
-
lineHeight: number | PDFNumber;
|
|
789
|
-
selectedLines: number[];
|
|
790
|
-
selectedColor: Color;
|
|
791
|
-
padding: number | PDFNumber;
|
|
792
|
-
}) => {
|
|
793
|
-
const x = asNumber(options.x);
|
|
794
|
-
const y = asNumber(options.y);
|
|
795
|
-
const width = asNumber(options.width);
|
|
796
|
-
const height = asNumber(options.height);
|
|
797
|
-
const lineHeight = asNumber(options.lineHeight);
|
|
798
|
-
const borderWidth = asNumber(options.borderWidth);
|
|
799
|
-
const padding = asNumber(options.padding);
|
|
800
|
-
|
|
801
|
-
const clipX = x + borderWidth / 2 + padding;
|
|
802
|
-
const clipY = y + borderWidth / 2 + padding;
|
|
803
|
-
const clipWidth = width - (borderWidth / 2 + padding) * 2;
|
|
804
|
-
const clipHeight = height - (borderWidth / 2 + padding) * 2;
|
|
805
|
-
|
|
806
|
-
const clippingArea = [
|
|
807
|
-
moveTo(clipX, clipY),
|
|
808
|
-
lineTo(clipX, clipY + clipHeight),
|
|
809
|
-
lineTo(clipX + clipWidth, clipY + clipHeight),
|
|
810
|
-
lineTo(clipX + clipWidth, clipY),
|
|
811
|
-
closePath(),
|
|
812
|
-
clip(),
|
|
813
|
-
endPath(),
|
|
814
|
-
];
|
|
815
|
-
|
|
816
|
-
const background = drawRectangle({
|
|
817
|
-
x,
|
|
818
|
-
y,
|
|
819
|
-
width,
|
|
820
|
-
height,
|
|
821
|
-
borderWidth: options.borderWidth,
|
|
822
|
-
color: options.color,
|
|
823
|
-
borderColor: options.borderColor,
|
|
824
|
-
rotate: degrees(0),
|
|
825
|
-
xSkew: degrees(0),
|
|
826
|
-
ySkew: degrees(0),
|
|
827
|
-
});
|
|
828
|
-
|
|
829
|
-
const highlights: PDFOperator[] = [];
|
|
830
|
-
for (let idx = 0, len = options.selectedLines.length; idx < len; idx++) {
|
|
831
|
-
const line = options.textLines[options.selectedLines[idx]];
|
|
832
|
-
highlights.push(
|
|
833
|
-
...drawRectangle({
|
|
834
|
-
x: line.x - padding,
|
|
835
|
-
y: line.y - (lineHeight - line.height) / 2,
|
|
836
|
-
width: width - borderWidth,
|
|
837
|
-
height: line.height + (lineHeight - line.height) / 2,
|
|
838
|
-
borderWidth: 0,
|
|
839
|
-
color: options.selectedColor,
|
|
840
|
-
borderColor: undefined,
|
|
841
|
-
rotate: degrees(0),
|
|
842
|
-
xSkew: degrees(0),
|
|
843
|
-
ySkew: degrees(0),
|
|
844
|
-
}),
|
|
845
|
-
);
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
const lines = drawTextLines(options.textLines, {
|
|
849
|
-
color: options.textColor,
|
|
850
|
-
font: options.font,
|
|
851
|
-
size: options.fontSize,
|
|
852
|
-
rotate: degrees(0),
|
|
853
|
-
xSkew: degrees(0),
|
|
854
|
-
ySkew: degrees(0),
|
|
855
|
-
});
|
|
856
|
-
|
|
857
|
-
const markedContent = [
|
|
858
|
-
beginMarkedContent('Tx'),
|
|
859
|
-
pushGraphicsState(),
|
|
860
|
-
...lines,
|
|
861
|
-
popGraphicsState(),
|
|
862
|
-
endMarkedContent(),
|
|
863
|
-
];
|
|
864
|
-
|
|
865
|
-
return [
|
|
866
|
-
pushGraphicsState(),
|
|
867
|
-
...background,
|
|
868
|
-
...highlights,
|
|
869
|
-
...clippingArea,
|
|
870
|
-
...markedContent,
|
|
871
|
-
popGraphicsState(),
|
|
872
|
-
];
|
|
873
|
-
};
|