all files / pages/ pdf-page-base.js

86.54% Statements 45/52
75% Branches 12/16
85.71% Functions 12/14
86.54% Lines 45/52
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105   15× 15× 15× 15×     6197×     15×           60×           30×           93× 93× 93× 93×           93× 15× 15×   93×                             93× 15×   93×         2532× 15× 15×   2532×     30× 30× 30× 30× 15× 15×   30×                      
define(["require", "exports", "./../primitives/pdf-array", "./pdf-page-layer-collection", "./../input-output/pdf-dictionary-properties", "./../graphics/pdf-resources"], function (require, exports, pdf_array_1, pdf_page_layer_collection_1, pdf_dictionary_properties_1, pdf_resources_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PdfPageBase = (function () {
        function PdfPageBase(dictionary) {
            this.defLayerIndex = -1;
            this.modified = false;
            this.dictionaryProperties = new pdf_dictionary_properties_1.DictionaryProperties();
            this.pageDictionary = dictionary;
        }
        Object.defineProperty(PdfPageBase.prototype, "section", {
            get: function () {
                return this.pdfSection;
            },
            set: function (value) {
                this.pdfSection = value;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfPageBase.prototype, "dictionary", {
            get: function () {
                return this.pageDictionary;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfPageBase.prototype, "element", {
            get: function () {
                return this.pageDictionary;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfPageBase.prototype, "defaultLayer", {
            get: function () {
                var layer = this.layers;
                var index = this.defaultLayerIndex;
                var returnlayer = layer.items(index);
                return returnlayer;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfPageBase.prototype, "defaultLayerIndex", {
            get: function () {
                if (this.layerCollection.count === 0 || this.defLayerIndex === -1) {
                    var layer = this.layerCollection.add();
                    this.defLayerIndex = this.layerCollection.indexOf(layer);
                }
                return this.defLayerIndex;
            },
            set: function (value) {
                if (value < 0 || value > this.layers.count - 1) {
                    throw new Error('ArgumentOutOfRangeException : value, Index can not be less 0 and greater Layers.Count - 1');
                }
                else {
                    this.defLayerIndex = value;
                    this.modified = true;
                }
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(PdfPageBase.prototype, "layers", {
            get: function () {
                if (this.layerCollection == null || typeof this.layerCollection === 'undefined') {
                    this.layerCollection = new pdf_page_layer_collection_1.PdfPageLayerCollection(this);
                }
                return this.layerCollection;
            },
            enumerable: true,
            configurable: true
        });
        PdfPageBase.prototype.getResources = function () {
            if (this.resources == null) {
                this.resources = new pdf_resources_1.PdfResources();
                this.dictionary.items.setValue(this.dictionaryProperties.resources, this.resources);
            }
            return this.resources;
        };
        Object.defineProperty(PdfPageBase.prototype, "contents", {
            get: function () {
                var obj = this.pageDictionary.items.getValue(this.dictionaryProperties.contents);
                var contents = obj;
                var rh = obj;
                if (contents == null) {
                    contents = new pdf_array_1.PdfArray();
                    this.pageDictionary.items.setValue(this.dictionaryProperties.contents, contents);
                }
                return contents;
            },
            enumerable: true,
            configurable: true
        });
        PdfPageBase.prototype.setResources = function (res) {
            this.resources = res;
            this.dictionary.items.setValue(this.dictionaryProperties.resources, this.resources);
            this.modified = true;
        };
        return PdfPageBase;
    }());
    exports.PdfPageBase = PdfPageBase;
});