UNPKG

pdf-lib

Version:

Create and modify PDF files with JavaScript

35 lines (26 loc) 836 B
import PDFDict from 'src/core/objects/PDFDict'; import PDFStream from 'src/core/objects/PDFStream'; import PDFContext from 'src/core/PDFContext'; import { arrayAsString } from 'src/utils'; class PDFRawStream extends PDFStream { static of = (dict: PDFDict, contents: Uint8Array) => new PDFRawStream(dict, contents); readonly contents: Uint8Array; private constructor(dict: PDFDict, contents: Uint8Array) { super(dict); this.contents = contents; } clone(context?: PDFContext): PDFRawStream { return PDFRawStream.of(this.dict.clone(context), this.contents.slice()); } getContentsString(): string { return arrayAsString(this.contents); } getContents(): Uint8Array { return this.contents; } getContentsSize(): number { return this.contents.length; } } export default PDFRawStream;