UNPKG

pdf-lib

Version:

Library for creating and modifying PDF files in JavaScript

49 lines (48 loc) 2.09 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var utils_1 = require("../../utils"); var validate_1 = require("../../utils/validate"); var _1 = require("."); var PDFRawStream = /** @class */ (function (_super) { __extends(PDFRawStream, _super); function PDFRawStream(dictionary, content) { var _this = _super.call(this, dictionary) || this; _this.clone = function () { return PDFRawStream.from(_this.dictionary.clone(), _this.content.slice()); }; _this.bytesSize = function () { return _this.dictionary.bytesSize() + 1 + // "\n" 7 + // "stream\n" _this.content.length + 10; }; // "\nendstream" _this.copyBytesInto = function (buffer) { _this.validateDictionary(); var remaining = _this.dictionary.copyBytesInto(buffer); remaining = utils_1.addStringToBuffer('\nstream\n', remaining); remaining.set(_this.content, 0); remaining = remaining.subarray(_this.content.length); remaining = utils_1.addStringToBuffer('\nendstream', remaining); return remaining; }; validate_1.validate(content, validate_1.isInstance(Uint8Array), 'PDFRawStream.content must be a Uint8Array'); _this.content = content; return _this; } PDFRawStream.from = function (dictionary, content) { return new PDFRawStream(dictionary, content); }; return PDFRawStream; }(_1.PDFStream)); exports.default = PDFRawStream;