UNPKG

pdf-lib

Version:

Library for creating and modifying PDF files in JavaScript

52 lines (51 loc) 2.1 kB
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 __()); }; })(); /* tslint:disable:max-classes-per-file class-name */ import PDFOperator from '../../../pdf-operators/PDFOperator'; import { addStringToBuffer } from '../../../../utils'; import { isNumber, validate } from '../../../../utils/validate'; /** * Append a rectangle to the current path as a complete subpath, with lower-left * corner (x, y) and dimensions width and height in user space. * The operation `x y width height re` is equivalent to * ``` * x y m * (x + width) y l * (x + width) (y + height) l * x (y + height) l * h * ``` */ var re = /** @class */ (function (_super) { __extends(re, _super); function re(x, y, width, height) { var _this = _super.call(this) || this; _this.toString = function () { return _this.x + " " + _this.y + " " + _this.width + " " + _this.height + " re\n"; }; _this.bytesSize = function () { return _this.toString().length; }; _this.copyBytesInto = function (buffer) { return addStringToBuffer(_this.toString(), buffer); }; validate(x, isNumber, 're operator arg "x" must be a number.'); validate(y, isNumber, 're operator arg "y" must be a number.'); validate(width, isNumber, 're operator arg "width" must be a number.'); validate(height, isNumber, 're operator arg "height" must be a number.'); _this.x = x; _this.y = y; _this.width = width; _this.height = height; return _this; } re.of = function (x, y, width, height) { return new re(x, y, width, height); }; return re; }(PDFOperator)); export default re;