| 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 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 | 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 25× 25× 25× 1× 50× 1× 1× 25× 25× 25× 25× 25× 25× 25× 25× 14× 11× 10× 1× 1× 25× 1× 51× 25× 51× 51× 51× 1× 1417× 1417× 1417× 25× 25× 1417× 1417× 79× 1× 1× 25× 25× 1× 25× 14× 14× 14× 14× 14× 14× 11× 10× 10× 10× 10× 10× 10× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 1× 25× 775× 775× 775× 1× 1× | /* 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", "./../primitives/pdf-dictionary", "./../collections/object-object-pair/dictionary", "./../primitives/pdf-name", "./../primitives/pdf-array", "./../primitives/pdf-reference", "./../input-output/pdf-cross-table", "./fonts/pdf-font", "./figures/pdf-template", "./brushes/pdf-brush", "./pdf-transparency", "./../graphics/images/pdf-bitmap", "./../graphics/images/pdf-image", "./brushes/pdf-gradient-brush", "./brushes/pdf-tiling-brush"], function (require, exports, pdf_dictionary_1, dictionary_1, pdf_name_1, pdf_array_1, pdf_reference_1, pdf_cross_table_1, pdf_font_1, pdf_template_1, pdf_brush_1, pdf_transparency_1, pdf_bitmap_1, pdf_image_1, pdf_gradient_brush_1, pdf_tiling_brush_1) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var PdfResources = (function (_super) { __extends(PdfResources, _super); function PdfResources(baseDictionary) { var _this = _super.call(this, baseDictionary) || this; _this.properties = new pdf_dictionary_1.PdfDictionary(); return _this; } Object.defineProperty(PdfResources.prototype, "names", { get: function () { return this.getNames(); }, enumerable: true, configurable: true }); Object.defineProperty(PdfResources.prototype, "document", { get: function () { return this.pdfDocument; }, set: function (value) { this.pdfDocument = value; }, enumerable: true, configurable: true }); PdfResources.prototype.getName = function (obj) { var primitive = obj.element; var name = null; Iif (this.names.containsKey(primitive)) { name = this.names.getValue(primitive); } Eif (name == null) { var sName = this.generateName(); name = new pdf_name_1.PdfName(sName); this.names.setValue(primitive, name); if (obj instanceof pdf_font_1.PdfFont) { this.add(obj, name); } else if (obj instanceof pdf_template_1.PdfTemplate) { this.add(obj, name); } else Eif (obj instanceof pdf_gradient_brush_1.PdfGradientBrush || obj instanceof pdf_tiling_brush_1.PdfTilingBrush) { this.add(obj, name); } else if (obj instanceof pdf_transparency_1.PdfTransparency) { this.add(obj, name); } else if (obj instanceof pdf_image_1.PdfImage || obj instanceof pdf_bitmap_1.PdfBitmap) { this.add(obj, name); } } return name; }; PdfResources.prototype.getNames = function () { if (this.pdfNames == null) { this.pdfNames = new dictionary_1.TemporaryDictionary(); } var fonts = this.items.getValue(this.dictionaryProperties.font); Iif (fonts != null) { var reference = fonts; var dictionary = fonts; dictionary = pdf_cross_table_1.PdfCrossTable.dereference(fonts); } return this.pdfNames; }; PdfResources.prototype.requireProcedureSet = function (procedureSetName) { Iif (procedureSetName == null) { throw new Error('ArgumentNullException:procedureSetName'); } var procSets = this.items.getValue(this.dictionaryProperties.procset); if (procSets == null) { procSets = new pdf_array_1.PdfArray(); this.items.setValue(this.dictionaryProperties.procset, procSets); } var name = new pdf_name_1.PdfName(procedureSetName); if (!procSets.contains(name)) { procSets.add(name); } }; PdfResources.prototype.removeFont = function (name) { var key = null; var keys = this.pdfNames.keys(); for (var index = 0; index < this.pdfNames.size(); index++) { if (this.pdfNames.getValue(keys[index]) === new pdf_name_1.PdfName(name)) { key = keys[index]; break; } } if (key != null) { this.pdfNames.remove(key); } }; PdfResources.prototype.generateName = function () { var name = Guid.getNewGuidString(); return name; }; PdfResources.prototype.add = function (arg1, arg2) { if (arg1 instanceof pdf_font_1.PdfFont) { var dictionary = null; var fonts = this.items.getValue(this.dictionaryProperties.font); Iif (fonts != null) { var reference = fonts; dictionary = fonts; dictionary = fonts; } else { dictionary = new pdf_dictionary_1.PdfDictionary(); this.items.setValue(this.dictionaryProperties.font, dictionary); } dictionary.items.setValue(arg2.value, new pdf_reference_1.PdfReferenceHolder(arg1.element)); } else if (arg1 instanceof pdf_template_1.PdfTemplate) { var xobjects = void 0; xobjects = this.items.getValue(this.dictionaryProperties.xObject); Eif (xobjects == null) { xobjects = new pdf_dictionary_1.PdfDictionary(); this.items.setValue(this.dictionaryProperties.xObject, xobjects); } xobjects.items.setValue(arg2.value, new pdf_reference_1.PdfReferenceHolder(arg1.element)); } else Eif (arg1 instanceof pdf_brush_1.PdfBrush) { Eif (arg1 instanceof pdf_gradient_brush_1.PdfGradientBrush || arg1 instanceof pdf_tiling_brush_1.PdfTilingBrush) { var savable = arg1.element; Eif (savable != null) { var pattern = this.items.getValue(this.dictionaryProperties.pattern); Eif (pattern == null) { pattern = new pdf_dictionary_1.PdfDictionary(); this.items.setValue(this.dictionaryProperties.pattern, pattern); } pattern.items.setValue(arg2.value, new pdf_reference_1.PdfReferenceHolder(savable)); } } } else if (arg1 instanceof pdf_transparency_1.PdfTransparency) { var savable = arg1.element; var transDic = null; transDic = this.items.getValue(this.dictionaryProperties.extGState); if (transDic == null) { transDic = new pdf_dictionary_1.PdfDictionary(); this.items.setValue(this.dictionaryProperties.extGState, transDic); } transDic.items.setValue(arg2.value, new pdf_reference_1.PdfReferenceHolder(savable)); } else { var xobjects = this.Dictionary.items.getValue(this.dictionaryProperties.xObject); var parentXObjects = void 0; if (typeof this.pdfDocument !== 'undefined') { parentXObjects = this.pdfDocument.sections.element.items.getValue(this.dictionaryProperties.resources).items.getValue(this.dictionaryProperties.xObject); } var values = this.Dictionary.items.values(); var hasSameImageStream = false; var oldReference = void 0; if (typeof this.pdfDocument !== 'undefined' && (typeof parentXObjects === undefined || parentXObjects == null)) { parentXObjects = new pdf_dictionary_1.PdfDictionary(); this.pdfDocument.sections.element.items.getValue(this.dictionaryProperties.resources).items.setValue(this.dictionaryProperties.xObject, parentXObjects); } else if (typeof this.pdfDocument !== 'undefined') { var values_1 = parentXObjects.items.values(); for (var i = 0; i < values_1.length; i++) { if (typeof values_1[i] !== 'undefined' && typeof values_1[i].element !== 'undefined') { if (values_1[i].element.data[0] === arg1.element.data[0]) { oldReference = values_1[i]; hasSameImageStream = true; } } } } if (xobjects == null) { xobjects = new pdf_dictionary_1.PdfDictionary(); this.Dictionary.items.setValue(this.dictionaryProperties.xObject, xobjects); } if (hasSameImageStream && typeof oldReference !== 'undefined') { xobjects.items.setValue(arg2.value, oldReference); } else { var reference = new pdf_reference_1.PdfReferenceHolder(arg1.element); xobjects.items.setValue(arg2.value, reference); if (typeof this.pdfDocument !== 'undefined') { parentXObjects.items.setValue(arg2.value, reference); } } } }; return PdfResources; }(pdf_dictionary_1.PdfDictionary)); exports.PdfResources = PdfResources; var Guid = (function () { function Guid() { } Guid.getNewGuidString = function () { return 'aaaaaaaa-aaaa-4aaa-baaa-aaaaaaaaaaaa'.replace(/[ab]/g, function (c) { var random = Math.random() * 16 | 0; var result = c === 'a' ? random : (random & 0x3 | 0x8); return result.toString(16); }); }; return Guid; }()); exports.Guid = Guid; }); |