all files / document/automatic-fields/ pdf-page-number-field.js

88.1% Statements 37/42
76.47% Branches 13/17
100% Functions 13/13
87.18% Lines 34/39
11 statements, 6 functions, 9 branches Ignored     
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61                                20×             20× 20× 20× 20×   20× 20× 20×        
/* istanbul ignore next */ 
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 __());
    };
})();
define(["require", "exports", "./../../graphics/brushes/pdf-brush", "./../../pages/enum", "./pdf-numbers-convertor", "./multiple-value-field"], function (require, exports, pdf_brush_1, enum_1, pdf_numbers_convertor_1, multiple_value_field_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfPageNumberField = (function (_super) {
        __extends(PdfPageNumberField, _super);
        function PdfPageNumberField(font, arg2) {
            var _this = _super.call(this) || this;
            _this.internalNumberStyle = enum_1.PdfNumberStyle.Numeric;
            Eif (typeof arg2 === 'undefined') {
                _this.font = font;
            }
            else if (arg2 instanceof pdf_brush_1.PdfBrush) {
                _this.font = font;
                _this.brush = arg2;
            }
            else {
                _this.font = font;
                _this.bounds = arg2;
            }
            return _this;
        }
        Object.defineProperty(PdfPageNumberField.prototype, "numberStyle", {
            get: function () {
                return this.internalNumberStyle;
            },
            set: function (value) {
                this.internalNumberStyle = value;
            },
            enumerable: true,
            configurable: true
        });
        PdfPageNumberField.prototype.getValue = function (graphics) {
            var result = null;
            var page = this.getPageFromGraphics(graphics);
            result = this.internalGetValue(page);
            return result;
        };
        PdfPageNumberField.prototype.internalGetValue = function (page) {
            var document = page.document;
            var pageIndex = document.pages.indexOf(page) + 1;
            return pdf_numbers_convertor_1.PdfNumbersConvertor.convert(pageIndex, this.numberStyle);
        };
        return PdfPageNumberField;
    }(multiple_value_field_1.PdfMultipleValueField));
    exports.PdfPageNumberField = PdfPageNumberField;
});