pdf-codec 4.0.13 → 4.1.0

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.
Files changed (66) hide show
  1. package/README.md +6 -5
  2. package/dist/annotations.d.cts +1 -1
  3. package/dist/annotations.d.ts +1 -1
  4. package/dist/attachments.d.cts +1 -1
  5. package/dist/attachments.d.ts +1 -1
  6. package/dist/content-read.d.cts +1 -1
  7. package/dist/content-read.d.ts +1 -1
  8. package/dist/crypto/random.cjs +9 -0
  9. package/dist/crypto/random.d.cts +4 -0
  10. package/dist/crypto/random.d.ts +4 -0
  11. package/dist/crypto/random.js +8 -0
  12. package/dist/document.d.cts +1 -1
  13. package/dist/document.d.ts +1 -1
  14. package/dist/embedded-font-write.d.cts +1 -1
  15. package/dist/embedded-font-write.d.ts +1 -1
  16. package/dist/encrypt-write.cjs +234 -0
  17. package/dist/encrypt-write.d.cts +31 -0
  18. package/dist/encrypt-write.d.ts +31 -0
  19. package/dist/encrypt-write.js +231 -0
  20. package/dist/encrypt.cjs +50 -20
  21. package/dist/encrypt.d.cts +18 -2
  22. package/dist/encrypt.d.ts +18 -2
  23. package/dist/encrypt.js +35 -21
  24. package/dist/filters.d.cts +1 -1
  25. package/dist/filters.d.ts +1 -1
  26. package/dist/font-read.d.cts +1 -1
  27. package/dist/font-read.d.ts +1 -1
  28. package/dist/form.d.cts +1 -1
  29. package/dist/form.d.ts +1 -1
  30. package/dist/images-read.d.cts +1 -1
  31. package/dist/images-read.d.ts +1 -1
  32. package/dist/index.cjs +2 -0
  33. package/dist/index.d.cts +2 -1
  34. package/dist/index.d.ts +2 -1
  35. package/dist/index.js +2 -1
  36. package/dist/interpret.d.cts +1 -1
  37. package/dist/interpret.d.ts +1 -1
  38. package/dist/math-font-write.d.cts +1 -1
  39. package/dist/math-font-write.d.ts +1 -1
  40. package/dist/names.d.cts +1 -1
  41. package/dist/names.d.ts +1 -1
  42. package/dist/navigation.d.cts +1 -1
  43. package/dist/navigation.d.ts +1 -1
  44. package/dist/objects-B7HdMeWS.d.cts +59 -0
  45. package/dist/objects-B7HdMeWS.d.ts +59 -0
  46. package/dist/objects.d.cts +1 -58
  47. package/dist/objects.d.ts +1 -58
  48. package/dist/optional-content.d.cts +1 -1
  49. package/dist/optional-content.d.ts +1 -1
  50. package/dist/parse.d.cts +1 -1
  51. package/dist/parse.d.ts +1 -1
  52. package/dist/predictors.d.cts +1 -1
  53. package/dist/predictors.d.ts +1 -1
  54. package/dist/serialize.d.cts +1 -1
  55. package/dist/serialize.d.ts +1 -1
  56. package/dist/structure.d.cts +1 -1
  57. package/dist/structure.d.ts +1 -1
  58. package/dist/tounicode.d.cts +1 -1
  59. package/dist/tounicode.d.ts +1 -1
  60. package/dist/write.cjs +29 -6
  61. package/dist/write.d.cts +2 -0
  62. package/dist/write.d.ts +2 -0
  63. package/dist/write.js +29 -6
  64. package/dist/xref.d.cts +1 -1
  65. package/dist/xref.d.ts +1 -1
  66. package/package.json +1 -1
package/dist/index.d.cts CHANGED
@@ -5,6 +5,7 @@ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.cjs";
5
5
  import { PdfBytesSchema, pdfCodec } from "./codec.cjs";
6
6
  import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-BU6Jgcof.cjs";
7
7
  import { WinAnsiSubstitution } from "./winansi.cjs";
8
+ import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.cjs";
8
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.cjs";
9
10
  import { FontRegistry, ResolvedFace, createFontRegistry, resolveFaceWithRegistry } from "./font-registry.cjs";
10
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.cjs";
@@ -24,4 +25,4 @@ import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } fro
24
25
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.cjs";
25
26
  import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
26
27
  export * from "byte-codec";
27
- export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
28
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ import { t as GlyphInkBounds } from "./glyph-bounds-BV_Z40KS.js";
5
5
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
6
6
  import { n as EmbeddedFaceMetrics, r as EmbeddedFaceSubstitution, t as EmbeddedFace } from "./embedded-font-fREdbxnr.js";
7
7
  import { WinAnsiSubstitution } from "./winansi.js";
8
+ import { PdfEncryptionError, PdfEncryptionOptions, PdfEncryptionPermissions, PdfEncryptionScheme } from "./encrypt-write.js";
8
9
  import { FontFace, FontFaceParseError, readFontFace } from "./font-face.js";
9
10
  import { FontRegistry, ResolvedFace, createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
10
11
  import { ResolvedFont, resolveStandardFont } from "./fonts.js";
@@ -24,4 +25,4 @@ import { LoadedMathFont, MathFont, MathFontDescriptorMetrics, loadMathFont } fro
24
25
  import { DEFAULT_VERTICAL_METRIC_POLICY, FontMeasurerOptions, StandardFontMeasurerOptions, VerticalMetricPolicy, createFontMeasurer, createStandardFontMeasurer } from "./measure.js";
25
26
  import { FontRegistryOptions, FontSubstitution, MathAssembledGlyphs, MathBox, MathColor, MathFontMetrics, MathGlyphMetrics, MathGlyphPlacement, MathGlyphRun, MathLayoutItem, MathRule, MathStretchAxis, MathStretchGlyph, MathStretchResult, MathStroke, Point, PositionedFormula, ProvidedFont, StyledFragment, StyledRun, TextMeasurer, UnderlineMetrics, WrapOptions, WrappedLine } from "document-schema.js";
26
27
  export * from "byte-codec";
27
- export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
28
+ export { type CcittFaxImage, type CcittFaxOptions, DEFAULT_VERTICAL_METRIC_POLICY, type EmbeddedFace, type EmbeddedFaceMetrics, type EmbeddedFaceSubstitution, type FontFace, FontFaceParseError, type FontMeasurerOptions, type FontMetrics, type FontRegistry, type FontRegistryOptions, type FontSubstitution, type GlyphInkBounds, type Jbig2DecodeOptions, type Jbig2Image, Jbig2ParseError, Jbig2UnsupportedError, type Jp2ChannelDefinition, type Jp2ColourSpace, type Jp2Container, type Jp2ImageHeader, type Jpeg2000ComponentMetadata, type Jpeg2000DecodeOptions, type Jpeg2000Image, type Jpeg2000Metadata, Jpeg2000ParseError, type Jpeg2000ProgressionOrder, type Jpeg2000QuantizationStyle, type Jpeg2000Transform, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotation, LayoutAnnotationQuad, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachment, LayoutAttachmentSchema, LayoutDestination, LayoutDestinationSchema, LayoutDestinationTarget, LayoutDestinationTargetSchema, LayoutDocument, LayoutDocumentSchema, LayoutEllipse, LayoutEllipseSchema, LayoutFormField, LayoutFormFieldSchema, LayoutFormWidget, LayoutFormWidgetSchema, LayoutImage, LayoutImageAsset, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLink, LayoutInternalLinkSchema, LayoutItem, LayoutItemSchema, LayoutLayer, LayoutLayerSchema, LayoutLine, LayoutLineSchema, LayoutLink, LayoutLinkSchema, LayoutOutlineItem, LayoutOutlineItemSchema, LayoutPage, LayoutPageSchema, LayoutPath, LayoutPathSchema, LayoutPathSegment, LayoutPathSegmentSchema, LayoutRect, LayoutRectSchema, LayoutStructureElement, LayoutStructureElementSchema, LayoutSubpath, LayoutSubpathSchema, LayoutText, LayoutTextSchema, type LoadedMathFont, type MathAssembledGlyphs, type MathBox, type MathColor, type MathFont, type MathFontDescriptorMetrics, type MathFontMetrics, type MathGlyphAssembly, type MathGlyphConstruction, type MathGlyphMetrics, type MathGlyphPart, type MathGlyphPlacement, type MathGlyphRun, type MathGlyphVariant, type MathLayoutItem, type MathRule, type MathStretchAxis, type MathStretchConstruction, type MathStretchGlyph, type MathStretchOptions, type MathStretchPlacement, type MathStretchResult, type MathStroke, type MathVariants, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, type PdfDiagnostic, type PdfDiagnosticSeverity, type PdfDiagnosticSink, PdfEncryptedError, PdfEncryptionError, type PdfEncryptionOptions, type PdfEncryptionPermissions, type PdfEncryptionScheme, PdfParseError, PdfPasswordRequiredError, type Point, type PositionedFormula, type ProvidedFont, type ReadPdfOptions, type ResolvedFace, type ResolvedFont, STANDARD_METRICS, type StandardFontMeasurerOptions, type StandardFontName, type StyledFragment, type StyledRun, type TextMeasurer, type UnderlineMetrics, type VerticalMetricPolicy, type WinAnsiSubstitution, type WrapOptions, type WrappedLine, type WritePdfOptions, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
package/dist/index.js CHANGED
@@ -10,6 +10,7 @@ import { Jpeg2000ParseError, Jpeg2000UnsupportedError } from "./image/jpeg2000-e
10
10
  import { looksLikeBareCodestream, parseJp2Container } from "./image/jp2-boxes.js";
11
11
  import { decodeJpeg2000, readJpeg2000Metadata } from "./image/jpeg2000.js";
12
12
  import { readPdf } from "./read.js";
13
+ import { PdfEncryptionError } from "./encrypt-write.js";
13
14
  import { createFontRegistry, resolveFaceWithRegistry } from "./font-registry.js";
14
15
  import { assembleStretchyGlyph, scaleMathStretchConstruction } from "./math-stretch.js";
15
16
  import { loadMathFont } from "./math-font.js";
@@ -18,4 +19,4 @@ import { writePdf } from "./write.js";
18
19
  import { PdfBytesSchema, pdfCodec } from "./codec.js";
19
20
  import { FontFaceParseError, readFontFace } from "./font-face.js";
20
21
  export * from "byte-codec";
21
- export { DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
22
+ export { DEFAULT_VERTICAL_METRIC_POLICY, FontFaceParseError, Jbig2ParseError, Jbig2UnsupportedError, Jpeg2000ParseError, Jpeg2000UnsupportedError, LAYOUT_FORMAT_VERSION, LayoutAnnotationQuadSchema, LayoutAnnotationSchema, LayoutAttachmentSchema, LayoutDestinationSchema, LayoutDestinationTargetSchema, LayoutDocumentSchema, LayoutEllipseSchema, LayoutFormFieldSchema, LayoutFormWidgetSchema, LayoutImageAssetSchema, LayoutImageSchema, LayoutInternalLinkSchema, LayoutItemSchema, LayoutLayerSchema, LayoutLineSchema, LayoutLinkSchema, LayoutOutlineItemSchema, LayoutPageSchema, LayoutPathSchema, LayoutPathSegmentSchema, LayoutRectSchema, LayoutStructureElementSchema, LayoutSubpathSchema, LayoutTextSchema, NOOP_DIAGNOSTIC_SINK, PdfBytesSchema, PdfEncryptedError, PdfEncryptionError, PdfParseError, PdfPasswordRequiredError, STANDARD_METRICS, assembleStretchyGlyph, createFontMeasurer, createFontRegistry, createStandardFontMeasurer, decodeCcittFax, decodeJbig2Embedded, decodeJpeg2000, filterScanlines, loadMathFont, looksLikeBareCodestream, parseJp2Container, pdfCodec, readFontFace, readJpeg2000Metadata, readPdf, resolveFaceWithRegistry, resolveStandardFont, scaleMathStretchConstruction, unfilterScanlines, writePdf };
@@ -1,6 +1,6 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
2
  import { r as Matrix } from "./matrix-B7_SBKQ5.cjs";
3
- import { PdfDict, PdfObject } from "./objects.cjs";
3
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
4
4
  import { Color, ContentStrokeStyle } from "document-schema.js";
5
5
  //#region src/interpret.d.ts
6
6
  interface ExtractedTextRun {
@@ -1,6 +1,6 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
2
  import { r as Matrix } from "./matrix-B7_SBKQ5.js";
3
- import { PdfDict, PdfObject } from "./objects.js";
3
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
4
4
  import { Color, ContentStrokeStyle } from "document-schema.js";
5
5
  //#region src/interpret.d.ts
6
6
  interface ExtractedTextRun {
@@ -1,4 +1,4 @@
1
- import { PdfDict, PdfObject } from "./objects.cjs";
1
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
2
2
  import { MathFont } from "./math-font.cjs";
3
3
  //#region src/math-font-write.d.ts
4
4
  interface MathFontObjectRefs {
@@ -1,4 +1,4 @@
1
- import { PdfDict, PdfObject } from "./objects.js";
1
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
2
2
  import { MathFont } from "./math-font.js";
3
3
  //#region src/math-font-write.d.ts
4
4
  interface MathFontObjectRefs {
package/dist/names.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfObject } from "./objects.cjs";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  import { PdfObjectResolver } from "./interpret.cjs";
4
4
  //#region src/names.d.ts
5
5
  interface NameTreeEntry {
package/dist/names.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfObject } from "./objects.js";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  import { PdfObjectResolver } from "./interpret.js";
4
4
  //#region src/names.d.ts
5
5
  interface NameTreeEntry {
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfDict, PdfObject } from "./objects.cjs";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  import { PdfObjectResolver } from "./interpret.cjs";
4
4
  import { LayoutDestination, LayoutDestinationTarget, LayoutOutlineItem } from "./layout.cjs";
5
5
  //#region src/navigation.d.ts
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfDict, PdfObject } from "./objects.js";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  import { PdfObjectResolver } from "./interpret.js";
4
4
  import { LayoutDestination, LayoutDestinationTarget, LayoutOutlineItem } from "./layout.js";
5
5
  //#region src/navigation.d.ts
@@ -0,0 +1,59 @@
1
+ //#region src/objects.d.ts
2
+ type PdfObject = {
3
+ kind: "null";
4
+ } | {
5
+ kind: "bool";
6
+ value: boolean;
7
+ } | {
8
+ kind: "number";
9
+ value: number;
10
+ } | {
11
+ kind: "name";
12
+ name: string;
13
+ } | {
14
+ kind: "string";
15
+ bytes: Uint8Array<ArrayBuffer>;
16
+ hex: boolean;
17
+ } | {
18
+ kind: "array";
19
+ items: PdfObject[];
20
+ } | {
21
+ kind: "dict";
22
+ entries: Map<string, PdfObject>;
23
+ } | {
24
+ kind: "stream";
25
+ dict: PdfDict;
26
+ raw: Uint8Array<ArrayBuffer>;
27
+ } | {
28
+ kind: "ref";
29
+ num: number;
30
+ gen: number;
31
+ };
32
+ type PdfDict = Extract<PdfObject, {
33
+ kind: "dict";
34
+ }>;
35
+ type PdfArray = Extract<PdfObject, {
36
+ kind: "array";
37
+ }>;
38
+ type PdfStream = Extract<PdfObject, {
39
+ kind: "stream";
40
+ }>;
41
+ declare function pdfNull(): PdfObject;
42
+ declare function pdfBool(value: boolean): PdfObject;
43
+ declare function pdfNum(value: number): PdfObject;
44
+ declare function pdfName(name: string): PdfObject;
45
+ declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
46
+ declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
47
+ declare function pdfArray(items: PdfObject[]): PdfObject;
48
+ declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
49
+ declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
50
+ declare function pdfRef(num: number, gen: number): PdfObject;
51
+ declare function isName(obj: PdfObject | undefined, name: string): boolean;
52
+ declare function asNumber(obj: PdfObject | undefined): number | undefined;
53
+ declare function asName(obj: PdfObject | undefined): string | undefined;
54
+ declare function asBool(obj: PdfObject | undefined): boolean | undefined;
55
+ declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
56
+ declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
57
+ declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
58
+ //#endregion
59
+ export { pdfName as _, asArray as a, pdfRef as b, asName as c, isName as d, pdfArray as f, pdfLiteralString as g, pdfHexString as h, PdfStream as i, asNumber as l, pdfDict as m, PdfDict as n, asBool as o, pdfBool as p, PdfObject as r, asDict as s, PdfArray as t, dictGet as u, pdfNull as v, pdfStream as x, pdfNum as y };
@@ -0,0 +1,59 @@
1
+ //#region src/objects.d.ts
2
+ type PdfObject = {
3
+ kind: "null";
4
+ } | {
5
+ kind: "bool";
6
+ value: boolean;
7
+ } | {
8
+ kind: "number";
9
+ value: number;
10
+ } | {
11
+ kind: "name";
12
+ name: string;
13
+ } | {
14
+ kind: "string";
15
+ bytes: Uint8Array<ArrayBuffer>;
16
+ hex: boolean;
17
+ } | {
18
+ kind: "array";
19
+ items: PdfObject[];
20
+ } | {
21
+ kind: "dict";
22
+ entries: Map<string, PdfObject>;
23
+ } | {
24
+ kind: "stream";
25
+ dict: PdfDict;
26
+ raw: Uint8Array<ArrayBuffer>;
27
+ } | {
28
+ kind: "ref";
29
+ num: number;
30
+ gen: number;
31
+ };
32
+ type PdfDict = Extract<PdfObject, {
33
+ kind: "dict";
34
+ }>;
35
+ type PdfArray = Extract<PdfObject, {
36
+ kind: "array";
37
+ }>;
38
+ type PdfStream = Extract<PdfObject, {
39
+ kind: "stream";
40
+ }>;
41
+ declare function pdfNull(): PdfObject;
42
+ declare function pdfBool(value: boolean): PdfObject;
43
+ declare function pdfNum(value: number): PdfObject;
44
+ declare function pdfName(name: string): PdfObject;
45
+ declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
46
+ declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
47
+ declare function pdfArray(items: PdfObject[]): PdfObject;
48
+ declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
49
+ declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
50
+ declare function pdfRef(num: number, gen: number): PdfObject;
51
+ declare function isName(obj: PdfObject | undefined, name: string): boolean;
52
+ declare function asNumber(obj: PdfObject | undefined): number | undefined;
53
+ declare function asName(obj: PdfObject | undefined): string | undefined;
54
+ declare function asBool(obj: PdfObject | undefined): boolean | undefined;
55
+ declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
56
+ declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
57
+ declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
58
+ //#endregion
59
+ export { pdfName as _, asArray as a, pdfRef as b, asName as c, isName as d, pdfArray as f, pdfLiteralString as g, pdfHexString as h, PdfStream as i, asNumber as l, pdfDict as m, PdfDict as n, asBool as o, pdfBool as p, PdfObject as r, asDict as s, PdfArray as t, dictGet as u, pdfNull as v, pdfStream as x, pdfNum as y };
@@ -1,59 +1,2 @@
1
- //#region src/objects.d.ts
2
- type PdfObject = {
3
- kind: "null";
4
- } | {
5
- kind: "bool";
6
- value: boolean;
7
- } | {
8
- kind: "number";
9
- value: number;
10
- } | {
11
- kind: "name";
12
- name: string;
13
- } | {
14
- kind: "string";
15
- bytes: Uint8Array<ArrayBuffer>;
16
- hex: boolean;
17
- } | {
18
- kind: "array";
19
- items: PdfObject[];
20
- } | {
21
- kind: "dict";
22
- entries: Map<string, PdfObject>;
23
- } | {
24
- kind: "stream";
25
- dict: PdfDict;
26
- raw: Uint8Array<ArrayBuffer>;
27
- } | {
28
- kind: "ref";
29
- num: number;
30
- gen: number;
31
- };
32
- type PdfDict = Extract<PdfObject, {
33
- kind: "dict";
34
- }>;
35
- type PdfArray = Extract<PdfObject, {
36
- kind: "array";
37
- }>;
38
- type PdfStream = Extract<PdfObject, {
39
- kind: "stream";
40
- }>;
41
- declare function pdfNull(): PdfObject;
42
- declare function pdfBool(value: boolean): PdfObject;
43
- declare function pdfNum(value: number): PdfObject;
44
- declare function pdfName(name: string): PdfObject;
45
- declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
46
- declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
47
- declare function pdfArray(items: PdfObject[]): PdfObject;
48
- declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
49
- declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
50
- declare function pdfRef(num: number, gen: number): PdfObject;
51
- declare function isName(obj: PdfObject | undefined, name: string): boolean;
52
- declare function asNumber(obj: PdfObject | undefined): number | undefined;
53
- declare function asName(obj: PdfObject | undefined): string | undefined;
54
- declare function asBool(obj: PdfObject | undefined): boolean | undefined;
55
- declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
56
- declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
57
- declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
58
- //#endregion
1
+ import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-B7HdMeWS.cjs";
59
2
  export { PdfArray, PdfDict, PdfObject, PdfStream, asArray, asBool, asDict, asName, asNumber, dictGet, isName, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream };
package/dist/objects.d.ts CHANGED
@@ -1,59 +1,2 @@
1
- //#region src/objects.d.ts
2
- type PdfObject = {
3
- kind: "null";
4
- } | {
5
- kind: "bool";
6
- value: boolean;
7
- } | {
8
- kind: "number";
9
- value: number;
10
- } | {
11
- kind: "name";
12
- name: string;
13
- } | {
14
- kind: "string";
15
- bytes: Uint8Array<ArrayBuffer>;
16
- hex: boolean;
17
- } | {
18
- kind: "array";
19
- items: PdfObject[];
20
- } | {
21
- kind: "dict";
22
- entries: Map<string, PdfObject>;
23
- } | {
24
- kind: "stream";
25
- dict: PdfDict;
26
- raw: Uint8Array<ArrayBuffer>;
27
- } | {
28
- kind: "ref";
29
- num: number;
30
- gen: number;
31
- };
32
- type PdfDict = Extract<PdfObject, {
33
- kind: "dict";
34
- }>;
35
- type PdfArray = Extract<PdfObject, {
36
- kind: "array";
37
- }>;
38
- type PdfStream = Extract<PdfObject, {
39
- kind: "stream";
40
- }>;
41
- declare function pdfNull(): PdfObject;
42
- declare function pdfBool(value: boolean): PdfObject;
43
- declare function pdfNum(value: number): PdfObject;
44
- declare function pdfName(name: string): PdfObject;
45
- declare function pdfHexString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
46
- declare function pdfLiteralString(bytes: Uint8Array<ArrayBuffer>): PdfObject;
47
- declare function pdfArray(items: PdfObject[]): PdfObject;
48
- declare function pdfDict(entries: Record<string, PdfObject> | Map<string, PdfObject>): PdfDict;
49
- declare function pdfStream(dict: PdfDict, raw: Uint8Array<ArrayBuffer>): PdfObject;
50
- declare function pdfRef(num: number, gen: number): PdfObject;
51
- declare function isName(obj: PdfObject | undefined, name: string): boolean;
52
- declare function asNumber(obj: PdfObject | undefined): number | undefined;
53
- declare function asName(obj: PdfObject | undefined): string | undefined;
54
- declare function asBool(obj: PdfObject | undefined): boolean | undefined;
55
- declare function asArray(obj: PdfObject | undefined): PdfObject[] | undefined;
56
- declare function asDict(obj: PdfObject | undefined): PdfDict | undefined;
57
- declare function dictGet(dict: PdfDict, key: string): PdfObject | undefined;
58
- //#endregion
1
+ import { _ as pdfName, a as asArray, b as pdfRef, c as asName, d as isName, f as pdfArray, g as pdfLiteralString, h as pdfHexString, i as PdfStream, l as asNumber, m as pdfDict, n as PdfDict, o as asBool, p as pdfBool, r as PdfObject, s as asDict, t as PdfArray, u as dictGet, v as pdfNull, x as pdfStream, y as pdfNum } from "./objects-B7HdMeWS.js";
59
2
  export { PdfArray, PdfDict, PdfObject, PdfStream, asArray, asBool, asDict, asName, asNumber, dictGet, isName, pdfArray, pdfBool, pdfDict, pdfHexString, pdfLiteralString, pdfName, pdfNull, pdfNum, pdfRef, pdfStream };
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfDict, PdfObject } from "./objects.cjs";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  import { PdfObjectResolver } from "./interpret.cjs";
4
4
  import { LayoutLayer } from "./layout.cjs";
5
5
  //#region src/optional-content.d.ts
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfDict, PdfObject } from "./objects.js";
2
+ import { n as PdfDict, r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  import { PdfObjectResolver } from "./interpret.js";
4
4
  import { LayoutLayer } from "./layout.js";
5
5
  //#region src/optional-content.d.ts
package/dist/parse.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfObject } from "./objects.cjs";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
3
3
  import { ByteReader } from "./bytes/reader.cjs";
4
4
  //#region src/parse.d.ts
5
5
  declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
package/dist/parse.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfObject } from "./objects.js";
2
+ import { r as PdfObject } from "./objects-B7HdMeWS.js";
3
3
  import { ByteReader } from "./bytes/reader.js";
4
4
  //#region src/parse.d.ts
5
5
  declare function parseValue(reader: ByteReader, sink: PdfDiagnosticSink): PdfObject | undefined;
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfDict } from "./objects.cjs";
2
+ import { n as PdfDict } from "./objects-B7HdMeWS.cjs";
3
3
  //#region src/predictors.d.ts
4
4
  interface PredictorParams {
5
5
  readonly predictor: number;
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfDict } from "./objects.js";
2
+ import { n as PdfDict } from "./objects-B7HdMeWS.js";
3
3
  //#region src/predictors.d.ts
4
4
  interface PredictorParams {
5
5
  readonly predictor: number;
@@ -1,4 +1,4 @@
1
- import { PdfObject } from "./objects.cjs";
1
+ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
2
2
  import { ByteWriter } from "./bytes/writer.cjs";
3
3
  //#region src/serialize.d.ts
4
4
  declare function formatNumber(n: number): string;
@@ -1,4 +1,4 @@
1
- import { PdfObject } from "./objects.js";
1
+ import { r as PdfObject } from "./objects-B7HdMeWS.js";
2
2
  import { ByteWriter } from "./bytes/writer.js";
3
3
  //#region src/serialize.d.ts
4
4
  declare function formatNumber(n: number): string;
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.cjs";
2
- import { PdfDict } from "./objects.cjs";
2
+ import { n as PdfDict } from "./objects-B7HdMeWS.cjs";
3
3
  import { PdfObjectResolver } from "./interpret.cjs";
4
4
  import { LayoutStructureElement } from "./layout.cjs";
5
5
  //#region src/structure.d.ts
@@ -1,5 +1,5 @@
1
1
  import { PdfDiagnosticSink } from "./diagnostics.js";
2
- import { PdfDict } from "./objects.js";
2
+ import { n as PdfDict } from "./objects-B7HdMeWS.js";
3
3
  import { PdfObjectResolver } from "./interpret.js";
4
4
  import { LayoutStructureElement } from "./layout.js";
5
5
  //#region src/structure.d.ts
@@ -1,4 +1,4 @@
1
- import { PdfObject } from "./objects.cjs";
1
+ import { r as PdfObject } from "./objects-B7HdMeWS.cjs";
2
2
  //#region src/tounicode.d.ts
3
3
  declare function buildToUnicodeCMap(codeToCodePoint: ReadonlyMap<number, number>): PdfObject;
4
4
  //#endregion
@@ -1,4 +1,4 @@
1
- import { PdfObject } from "./objects.js";
1
+ import { r as PdfObject } from "./objects-B7HdMeWS.js";
2
2
  //#region src/tounicode.d.ts
3
3
  declare function buildToUnicodeCMap(codeToCodePoint: ReadonlyMap<number, number>): PdfObject;
4
4
  //#endregion
package/dist/write.cjs CHANGED
@@ -7,6 +7,8 @@ const require_serialize = require("./serialize.cjs");
7
7
  const require_bytes_flate = require("./bytes/flate.cjs");
8
8
  const require_util_base64 = require("./util/base64.cjs");
9
9
  const require_util_abort = require("./util/abort.cjs");
10
+ const require_crypto_random = require("./crypto/random.cjs");
11
+ const require_encrypt_write = require("./encrypt-write.cjs");
10
12
  const require_image_jpeg_info = require("./image/jpeg-info.cjs");
11
13
  const require_image_png_decode = require("./image/png-decode.cjs");
12
14
  const require_embedded_font = require("./embedded-font.cjs");
@@ -30,6 +32,7 @@ const FLAG_SERIF = 2;
30
32
  const FLAG_NONSYMBOLIC = 32;
31
33
  const FLAG_ITALIC = 64;
32
34
  const FLAG_FORCE_BOLD = 262144;
35
+ const FILE_ID_BYTES = 16;
33
36
  function textToPdfString(text) {
34
37
  const bytes = new Uint8Array(2 + text.length * 2);
35
38
  bytes[0] = 254;
@@ -318,6 +321,7 @@ function writePdf(doc, options = {}) {
318
321
  pageNum: nextObjNum++,
319
322
  contentsNum: nextObjNum++
320
323
  }));
324
+ const encryptDictNum = options.encryption === void 0 ? void 0 : nextObjNum++;
321
325
  const objects = [];
322
326
  objects.push({
323
327
  num: catalogNum,
@@ -502,10 +506,24 @@ function writePdf(doc, options = {}) {
502
506
  value: require_objects.pdfDict(pageEntries)
503
507
  });
504
508
  });
509
+ let fileId;
510
+ let encryptedObjects = objects;
511
+ if (options.encryption !== void 0 && encryptDictNum !== void 0) {
512
+ fileId = require_crypto_random.randomBytes(FILE_ID_BYTES);
513
+ const encryptor = require_encrypt_write.createStandardEncryptor(options.encryption, fileId);
514
+ encryptedObjects = objects.map(({ num, value }) => ({
515
+ num,
516
+ value: require_encrypt_write.encryptIndirectObject(value, num, 0, encryptor)
517
+ }));
518
+ encryptedObjects.push({
519
+ num: encryptDictNum,
520
+ value: encryptor.encryptDict
521
+ });
522
+ }
505
523
  const writer = new require_bytes_writer.ByteWriter();
506
524
  writer.writeAscii("%PDF-1.7\n");
507
525
  const offsets = /* @__PURE__ */ new Map();
508
- for (const { num, value } of objects) {
526
+ for (const { num, value } of encryptedObjects) {
509
527
  offsets.set(num, writer.length);
510
528
  writer.writeAscii(`${num} 0 obj\n`);
511
529
  require_serialize.writeObject(writer, value);
@@ -521,12 +539,17 @@ function writePdf(doc, options = {}) {
521
539
  if (offset === void 0) throw new Error(`object ${num} was allocated but never written -- this is a writePdf internal invariant violation`);
522
540
  writer.writeAscii(xrefEntry(offset, 0, true));
523
541
  }
542
+ const trailerEntries = /* @__PURE__ */ new Map([
543
+ ["Size", require_objects.pdfNum(maxObjNum + 1)],
544
+ ["Root", require_objects.pdfRef(catalogNum, 0)],
545
+ ["Info", require_objects.pdfRef(infoNum, 0)]
546
+ ]);
547
+ if (fileId !== void 0 && encryptDictNum !== void 0) {
548
+ trailerEntries.set("ID", require_objects.pdfArray([require_objects.pdfHexString(fileId), require_objects.pdfHexString(fileId)]));
549
+ trailerEntries.set("Encrypt", require_objects.pdfRef(encryptDictNum, 0));
550
+ }
524
551
  writer.writeAscii("trailer\n");
525
- require_serialize.writeObject(writer, require_objects.pdfDict({
526
- Size: require_objects.pdfNum(maxObjNum + 1),
527
- Root: require_objects.pdfRef(catalogNum, 0),
528
- Info: require_objects.pdfRef(infoNum, 0)
529
- }));
552
+ require_serialize.writeObject(writer, require_objects.pdfDict(trailerEntries));
530
553
  writer.writeAscii("\nstartxref\n");
531
554
  writer.writeAscii(`${xrefOffset}\n`);
532
555
  writer.writeAscii("%%EOF");
package/dist/write.d.cts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { LayoutDocument } from "./layout.cjs";
2
2
  import { r as EmbeddedFaceSubstitution } from "./embedded-font-BU6Jgcof.cjs";
3
3
  import { WinAnsiSubstitution } from "./winansi.cjs";
4
+ import { PdfEncryptionOptions } from "./encrypt-write.cjs";
4
5
  import { FontRegistry } from "./font-registry.cjs";
5
6
  import { PositionedFormula } from "document-schema.js";
6
7
  //#region src/write.d.ts
@@ -15,6 +16,7 @@ interface WritePdfOptions {
15
16
  }) => void;
16
17
  readonly fonts?: FontRegistry;
17
18
  readonly formulas?: readonly PositionedFormula[];
19
+ readonly encryption?: PdfEncryptionOptions;
18
20
  }
19
21
  declare function writePdf(doc: LayoutDocument, options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
20
22
  //#endregion
package/dist/write.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { LayoutDocument } from "./layout.js";
2
2
  import { r as EmbeddedFaceSubstitution } from "./embedded-font-fREdbxnr.js";
3
3
  import { WinAnsiSubstitution } from "./winansi.js";
4
+ import { PdfEncryptionOptions } from "./encrypt-write.js";
4
5
  import { FontRegistry } from "./font-registry.js";
5
6
  import { PositionedFormula } from "document-schema.js";
6
7
  //#region src/write.d.ts
@@ -15,6 +16,7 @@ interface WritePdfOptions {
15
16
  }) => void;
16
17
  readonly fonts?: FontRegistry;
17
18
  readonly formulas?: readonly PositionedFormula[];
19
+ readonly encryption?: PdfEncryptionOptions;
18
20
  }
19
21
  declare function writePdf(doc: LayoutDocument, options?: WritePdfOptions): Uint8Array<ArrayBuffer>;
20
22
  //#endregion