@syncfusion/ej2-pdf
Version:
Feature-rich JavaScript PDF library with built-in support for loading and manipulating PDF document.
68 lines (67 loc) • 2.29 kB
JavaScript
var __extends = (this && this.__extends) || (function () {
var extendStatics = function (d, b) {
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 extendStatics(d, b);
};
return function (d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
import { _PdfDecodeStream } from '../decode-stream';
/**
* Provides a JPEG stream wrapper that reads JPEG bytes from the underlying base stream.
*
* @private
*/
var _PdfJpegStream = /** @class */ (function (_super) {
__extends(_PdfJpegStream, _super);
function _PdfJpegStream(stream, maybeLength, params) {
var _this = _super.call(this, maybeLength) || this;
/**
* Byte offset at which the JPEG stream data begins.
*
* @private
*/
_this._jpegStreamStart = 0;
/**
* Indicates whether the stream requires reprocessing due to parameters.
*
* @private
*/
_this._needsReprocessing = false;
_this.stream = stream;
_this.params = params;
_this.maybeLength = maybeLength;
return _this;
}
_PdfJpegStream.prototype.readBlock = function () {
this.decodeImage();
};
_PdfJpegStream.prototype.decodeImage = function (bytes) {
if (this.eof) {
return this.buffer;
}
bytes = this.skipUselessBytes(bytes || this.stream.getBytes(this.maybeLength));
this.buffer = bytes;
this.bufferLength = bytes.length;
this.eof = true;
return this.buffer;
};
_PdfJpegStream.prototype.skipUselessBytes = function (data) {
for (var i = 0, ii = data.length - 1; i < ii; i++) {
if (data[i] === 0xff && data[i + 1] === 0xd8) {
if (i > 0) {
data = data.subarray(i);
}
break;
}
}
return data;
};
return _PdfJpegStream;
}(_PdfDecodeStream));
export { _PdfJpegStream };