/*
 * SDK Pullenti Unitext, version 4.33, fabruary 2026. Copyright (c) 2013-2026, Pullenti. All rights reserved. 
 * Non-Commercial Freeware and Commercial Software. 
 * This class is generated using the converter UniSharping (www.unisharping.ru) from Pullenti C# project. 
 * The latest version of the code is available on the site www.pullenti.ru
 */

const Utils = require("./../../../unisharp/Utils");
const RefOutArgWrapper = require("./../../../unisharp/RefOutArgWrapper");
const Stream = require("./../../../unisharp/Stream");

const PdfObject = require("./PdfObject");
const PdfReference = require("./PdfReference");
const PdfArray = require("./PdfArray");
const PdfIntValue = require("./PdfIntValue");
const PdfDictionary = require("./PdfDictionary");
const PdfStream = require("./PdfStream");

class PdfFile extends PdfObject {
    
    constructor() {
        super();
        this.rootObject = null;
        this.info = null;
        this.encrypt = null;
        this.pages = new Array();
        this.allResources = new Array();
        this.objs = null;
        this.trailer = null;
        this.m_Stream = null;
        this.m_Head = null;
        this.m_IndirectObjs = new Array();
        this.m_IndirectObjDisp = new Array();
    }
    
    open(fileName, fileContent = null) {
        this.rootObject = null;
        this.info = null;
        if (this.m_Stream !== null) 
            this.m_Stream.close();
        this.m_Stream = new PdfStream(fileName, fileContent);
        this.m_Head = this.m_Stream.readHead();
        let hpos = this.m_Stream.position;
        if (this._readXRefs()) {
        }
        else {
            let i = 0;
            let rootObj = null;
            let infoObj = null;
            this.m_Stream.position = hpos;
            while (true) {
                i = this.m_Stream.peekSolidByte();
                if (i < 0) 
                    break;
                let ch = i;
                let p0 = this.m_Stream.position;
                let _id = 0;
                let v = 0;
                let isObj = false;
                let str = null;
                let obj = null;
                if ((String.fromCharCode(ch)) >= '0' && (String.fromCharCode(ch)) <= '9') {
                    let wrapid178 = new RefOutArgWrapper();
                    let wrapv179 = new RefOutArgWrapper();
                    isObj = this.m_Stream.tryReadIdAndVersion(false, wrapid178, wrapv179);
                    _id = wrapid178.value;
                    v = wrapv179.value;
                }
                if (isObj) {
                    obj = null;
                    try {
                        obj = this.m_Stream.parseObject(this, false);
                    } catch (ex) {
                    }
                    if (obj === null) {
                        this.m_Stream.position = this.m_Stream.position + 1;
                        continue;
                    }
                    obj.id = _id;
                    obj.version = v;
                    obj.sourceFile = this;
                    this._addObj(_id, obj);
                    str = this.m_Stream.readWord(false);
                    continue;
                }
                str = this.m_Stream.readWord(false);
                if (str === "xref") {
                    let i1 = 0;
                    str = this.m_Stream.readWord(false);
                    let wrapi1182 = new RefOutArgWrapper();
                    let inoutres183 = Utils.tryParseInt(str, wrapi1182);
                    i1 = wrapi1182.value;
                    if (inoutres183) {
                        let i2 = 0;
                        str = this.m_Stream.readWord(false);
                        let wrapi2180 = new RefOutArgWrapper();
                        let inoutres181 = Utils.tryParseInt(str, wrapi2180);
                        i2 = wrapi2180.value;
                        if (inoutres181) {
                            if (i2 > i1) 
                                this.m_Stream.position = this.m_Stream.position + (((i2 - i1)) * 20);
                        }
                    }
                    while (true) {
                        str = this.m_Stream.readWord(false);
                        if (Utils.isNullOrEmpty(str) || str === "trailer") 
                            break;
                    }
                }
                if (str === "trailer") {
                    if ((((i = this.m_Stream.peekSolidByte()))) < 0) 
                        break;
                    ch = i;
                    if ((String.fromCharCode(ch)) !== '<') 
                        continue;
                    this.m_Stream.position = this.m_Stream.position + 1;
                    if ((((i = this.m_Stream.readByte()))) < 0) 
                        break;
                    ch = i;
                    if ((String.fromCharCode(ch)) !== '<') 
                        break;
                    this.trailer = new PdfDictionary();
                    this.trailer.sourceFile = this;
                    this.trailer.postParse(this.m_Stream);
                    if (rootObj === null) 
                        rootObj = this.trailer.getObject("Root", true);
                    if (infoObj === null) 
                        infoObj = this.trailer.getObject("Info", true);
                    if (this.trailer.getObject("Encrypt", true) !== null) 
                        this.encrypt = this.trailer.getDictionary("Encrypt", null);
                    continue;
                }
                let pos = this.m_Stream.position;
                obj = this.m_Stream.parseObject(this, false);
                if (pos === (this.m_Stream.position)) 
                    this.m_Stream.position = this.m_Stream.position + 1;
            }
            if (rootObj !== null) 
                this.rootObject = Utils.as(this.getObject(rootObj.id), PdfDictionary);
            if (infoObj !== null) 
                this.info = Utils.as(this.getObject(infoObj.id), PdfDictionary);
        }
        for (let i = 1; i < this.m_IndirectObjs.length; i++) {
            if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                if (this.m_IndirectObjs[i].isTypeItem("ObjStm")) {
                    if (!this._readObjStm(Utils.as(this.m_IndirectObjs[i], PdfDictionary))) {
                        if (this._checkEncrypt()) 
                            return;
                    }
                }
            }
        }
        let isLinearized = false;
        if (this.rootObject === null) {
            for (let i = 1; i < this.m_IndirectObjs.length; i++) {
                if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                    if (this.m_IndirectObjs[i].getObject("Linearized", false) !== null) {
                        isLinearized = true;
                        break;
                    }
                }
            }
        }
        this._readAllResources();
        if (isLinearized) {
            let firstPage = null;
            let pos0 = this.m_Stream.length;
            for (let i = 1; i < this.m_IndirectObjs.length; i++) {
                if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                    let dic = Utils.as(this.m_IndirectObjs[i], PdfDictionary);
                    if (dic.isTypeItem("Page")) {
                        this.pages.push(dic);
                        dic.pageNum = this.pages.length;
                        if (dic.m_FilePos > 0 && (dic.m_FilePos < pos0)) {
                            firstPage = dic;
                            pos0 = dic.m_FilePos;
                        }
                    }
                    else if (dic.isTypeItem("Catalog")) 
                        this.rootObject = dic;
                    else if (dic.isTypeItem("Info")) 
                        this.info = dic;
                }
            }
            if (this.rootObject !== null) {
                this.pages.splice(0, this.pages.length);
                this.rootObject.getAllPages(this.pages);
            }
            else if (firstPage !== null && this.pages[0] !== firstPage) {
                Utils.removeItem(this.pages, firstPage);
                this.pages.splice(0, 0, firstPage);
            }
            return;
        }
        if (this.rootObject === null) {
            for (let i = 1; i < this.m_IndirectObjs.length; i++) {
                if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                    if (this.m_IndirectObjs[i].isTypeItem("Catalog")) {
                        this.rootObject = Utils.as(this.m_IndirectObjs[i], PdfDictionary);
                        break;
                    }
                }
            }
        }
        if (this.info === null) {
            for (let i = 1; i < this.m_IndirectObjs.length; i++) {
                if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                    if (this.m_IndirectObjs[i].isTypeItem("Info")) {
                        this.info = Utils.as(this.m_IndirectObjs[i], PdfDictionary);
                        break;
                    }
                }
            }
        }
        if (this.rootObject === null) {
            for (let i = 1; i < this.m_IndirectObjs.length; i++) {
                if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                    if (this.m_IndirectObjs[i].isTypeItem("XRef")) {
                        this.objs = new Array();
                        for (const v of this.m_IndirectObjs) {
                            if (v !== null) 
                                this.objs.push(v);
                        }
                        break;
                    }
                }
            }
        }
        if (this.rootObject !== null) 
            this.rootObject.getAllPages(this.pages);
        for (let i = 0; i < this.pages.length; i++) {
            this.pages[i].pageNum = i + 1;
        }
    }
    
    writeOnlyOnePage(s, pageNum) {
        let pdic = this.rootObject.getDictionary("Pages", null);
        let count = Utils.as(pdic.getObject("Count", false), PdfIntValue);
        if (count !== null) {
            count.val = 1;
            count.id = 0;
        }
        let kids = Utils.as(pdic.getObject("Kids", false), PdfArray);
        kids.clear();
        let _objs = new Array();
        let _id = 1;
        let curPage = null;
        for (let i = 1; i < this.m_IndirectObjDisp.length; i++) {
            let obj = this.getObject(i);
            if (obj === null) 
                continue;
            obj.deleted = true;
            if (obj === this.pages[pageNum] || obj === this.rootObject || obj === this.info) {
                obj.deleted = false;
                _objs.push(obj);
                obj.writeId = _id++;
                if (obj === this.pages[pageNum]) {
                    curPage = Utils.as(obj, PdfDictionary);
                    kids.add(PdfReference._new184(obj.writeId, obj.id));
                }
            }
        }
        if (kids.id > 0) {
            kids.deleted = false;
            _objs.push(kids);
            kids.writeId = _id++;
        }
        pdic.deleted = false;
        _objs.push(pdic);
        pdic.writeId = _id++;
        curPage.addObject("Parent", PdfReference._new184(pdic.writeId, pdic.id));
        let refs = new Array();
        let tmp = new Array();
        let k = 0;
        let cou0 = 0;
        for (k = 0; ; k++) {
            let cou = _objs.length;
            for (let i = cou0; i < cou; i++) {
                let obj0 = _objs[i];
                if (obj0.id === 378 || obj0.id === 276) {
                }
                let dic = Utils.as(obj0, PdfDictionary);
                if (dic !== null) {
                    for (const key of dic.keys) {
                        if (key === "StructTreeRoot") 
                            continue;
                        let obj = dic.getObject(key, false);
                        if (obj === null) 
                            continue;
                        if (obj.deleted) {
                            if (obj.id === 94) {
                            }
                            if ((obj instanceof PdfDictionary) && obj.isTypeItem("Page")) 
                                continue;
                            obj.deleted = false;
                            _objs.push(obj);
                            obj.writeId = _id++;
                            let re = Utils.as(dic.getObject(key, true), PdfReference);
                            if (re !== null) 
                                re.writeId = obj.writeId;
                        }
                        else if (obj.id === 0 && (((obj instanceof PdfDictionary) || (obj instanceof PdfArray)))) 
                            _objs.push(obj);
                    }
                }
                let arr = Utils.as(obj0, PdfArray);
                if (arr !== null) {
                    for (let j = 0; j < arr.itemsCount; j++) {
                        let obj = arr.getItem(j, false);
                        if (obj === null) 
                            continue;
                        if (obj.deleted) {
                            if (obj.id === 94) {
                            }
                            if ((obj instanceof PdfDictionary) && obj.isTypeItem("Page")) 
                                continue;
                            obj.deleted = false;
                            _objs.push(obj);
                            obj.writeId = _id++;
                            let re = Utils.as(arr.getItem(j, false), PdfReference);
                            if (re !== null) 
                                re.writeId = obj.writeId;
                        }
                        else if (obj.id === 0 && (((obj instanceof PdfDictionary) || (obj instanceof PdfArray)))) 
                            _objs.push(obj);
                    }
                }
            }
            if (_objs.length === cou) 
                break;
            cou0 = cou;
        }
        let buf = [ ];
        let ii = 0;
        for (ii = 0; ii < this.m_Head.length; ii++) {
            if (this.m_Head[ii] === (0xA)) {
                ii++;
                break;
            }
        }
        s.write(this.m_Head, 0, ii);
        let objsCount = 0;
        for (const obj of _objs) {
            if (obj.id === 0) 
                continue;
            obj.writePos = s.position;
            objsCount++;
            buf = Utils.encodeString("ASCII", (String(obj.writeId) + " 0 obj\r\n"));
            s.write(buf, 0, buf.length);
            if (obj.deleted) {
                buf = Utils.encodeString("ASCII", "null");
                s.write(buf, 0, buf.length);
            }
            else 
                obj.write(s);
            buf = Utils.encodeString("ASCII", "\r\nendobj\r\n");
            s.write(buf, 0, buf.length);
        }
        let xrefpos = s.position;
        buf = Utils.encodeString("ASCII", ("xref\r\n0 " + (objsCount + 1) + "\r\n0000000000 65535 f\r\n"));
        s.write(buf, 0, buf.length);
        for (const obj of _objs) {
            if (obj.writeId > 0) {
                buf = Utils.encodeString("ASCII", (Utils.correctToString((obj.writePos).toString(10), 1, true) + " 00000 n\r\n"));
                s.write(buf, 0, buf.length);
            }
        }
        if (this.trailer === null) {
            let _trailer = ("trailer\r\n<</Size " + objsCount);
            if (this.info !== null) 
                _trailer = (_trailer + "/Info " + this.info.writeId + " 0 R");
            if (this.rootObject !== null) 
                _trailer = (_trailer + "/Root " + this.rootObject.writeId + " 0 R");
            _trailer = (_trailer + ">>\r\nstartxref\r\n" + xrefpos + "\r\n%%EOF");
            buf = Utils.encodeString("ASCII", _trailer);
            s.write(buf, 0, buf.length);
        }
        else {
            buf = Utils.encodeString("ASCII", "trailer\r\n");
            s.write(buf, 0, buf.length);
            let iii = Utils.as(this.trailer.getObject("Size", false), PdfIntValue);
            if (iii !== null) 
                iii.val = _objs.length;
            if (this.trailer.getObject("Root", false) === null && this.rootObject !== null) 
                this.trailer.addObject("Root", PdfReference._new186(this.rootObject.writeId));
            if (this.trailer.getObject("Info", false) === null && this.info !== null) 
                this.trailer.addObject("Info", PdfReference._new186(this.info.writeId));
            this.trailer.write(s);
            buf = Utils.encodeString("ASCII", ("\r\nstartxref\r\n" + xrefpos + "\r\n%%EOF"));
            s.write(buf, 0, buf.length);
        }
    }
    
    write(s) {
        let buf = [ ];
        let ii = 0;
        for (ii = 0; ii < this.m_Head.length; ii++) {
            if (this.m_Head[ii] === (0xA)) {
                ii++;
                break;
            }
        }
        s.write(this.m_Head, 0, ii);
        let refs = new Array();
        let _objs = new Array();
        let tmp = new Array();
        for (let i = 1; i < this.m_IndirectObjDisp.length; i++) {
            let obj = this.getObject(i);
            if (obj === null) 
                continue;
            if (obj instanceof PdfDictionary) {
                if (obj.isTypeItem("XRef")) 
                    continue;
            }
            _objs.push(obj);
            obj.writeId = _objs.length;
            tmp.splice(0, tmp.length);
            obj.getAllReferences(refs, tmp);
        }
        for (const r of refs) {
            let obj = this.getObject(r.id);
            if (obj !== null) 
                r.writeId = obj.writeId;
        }
        for (const obj of _objs) {
            obj.writePos = s.position;
            buf = Utils.encodeString("ASCII", (String(obj.writeId) + " 0 obj\r\n"));
            s.write(buf, 0, buf.length);
            if (obj.deleted) {
                buf = Utils.encodeString("ASCII", "null");
                s.write(buf, 0, buf.length);
            }
            else 
                obj.write(s);
            buf = Utils.encodeString("ASCII", "\r\nendobj\r\n");
            s.write(buf, 0, buf.length);
        }
        let xrefpos = s.position;
        buf = Utils.encodeString("ASCII", ("xref\r\n0 " + (_objs.length + 1) + "\r\n0000000000 65535 f\r\n"));
        s.write(buf, 0, buf.length);
        for (const obj of _objs) {
            buf = Utils.encodeString("ASCII", (Utils.correctToString((obj.writePos).toString(10), 1, true) + " 00000 n\r\n"));
            s.write(buf, 0, buf.length);
        }
        if (this.trailer === null) {
            let _trailer = ("trailer\r\n<</Size " + _objs.length);
            if (this.info !== null) 
                _trailer = (_trailer + "/Info " + this.info.writeId + " 0 R");
            if (this.rootObject !== null) 
                _trailer = (_trailer + "/Root " + this.rootObject.writeId + " 0 R");
            _trailer = (_trailer + ">>\r\nstartxref\r\n" + xrefpos + "\r\n%%EOF");
            buf = Utils.encodeString("ASCII", _trailer);
            s.write(buf, 0, buf.length);
        }
        else {
            buf = Utils.encodeString("ASCII", "trailer\r\n");
            s.write(buf, 0, buf.length);
            let iii = Utils.as(this.trailer.getObject("Size", false), PdfIntValue);
            if (iii !== null) 
                iii.val = _objs.length;
            if (this.trailer.getObject("Root", false) === null && this.rootObject !== null) 
                this.trailer.addObject("Root", PdfReference._new186(this.rootObject.writeId));
            if (this.trailer.getObject("Info", false) === null && this.info !== null) 
                this.trailer.addObject("Info", PdfReference._new186(this.info.writeId));
            this.trailer.write(s);
            buf = Utils.encodeString("ASCII", ("\r\nstartxref\r\n" + xrefpos + "\r\n%%EOF"));
            s.write(buf, 0, buf.length);
        }
        refs.splice(0, refs.length);
        _objs.splice(0, _objs.length);
    }
    
    _readAllResources() {
        for (let i = 1; i < this.m_IndirectObjs.length; i++) {
            if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                let dic = Utils.as(this.m_IndirectObjs[i], PdfDictionary);
                let sub = dic.getStringItem("Subtype");
                if (sub === "Image" || sub === "Font") 
                    this.allResources.push(dic);
            }
        }
    }
    
    _checkEncrypt() {
        for (let i = 1; i < this.m_IndirectObjs.length; i++) {
            if (this.m_IndirectObjs[i] instanceof PdfDictionary) {
                let dic = Utils.as(this.m_IndirectObjs[i], PdfDictionary);
                if (dic.isTypeItem("Encrypt")) {
                    this.encrypt = dic;
                    return true;
                }
                this.encrypt = dic.getDictionary("Encrypt", null);
                if (this.encrypt !== null) 
                    return true;
            }
        }
        return false;
    }
    
    close() {
        if (this.m_Stream !== null) 
            this.m_Stream.close();
        this.m_Stream = null;
    }
    
    get maxObjsCount() {
        return this.m_IndirectObjs.length;
    }
    
    getObject(_id) {
        if ((_id < 1) || _id >= this.m_IndirectObjs.length) 
            return null;
        if (this.m_IndirectObjs[_id] !== null) 
            return this.m_IndirectObjs[_id];
        if (this.m_IndirectObjDisp[_id] === 0) 
            return null;
        if (_id === 6) {
        }
        this.m_Stream.position = this.m_IndirectObjDisp[_id];
        let uid = 0;
        let v = 0;
        let wrapuid190 = new RefOutArgWrapper();
        let wrapv191 = new RefOutArgWrapper();
        let inoutres192 = this.m_Stream.tryReadIdAndVersion(false, wrapuid190, wrapv191);
        uid = wrapuid190.value;
        v = wrapv191.value;
        if (!inoutres192) 
            return null;
        if (uid !== _id) 
            return null;
        let obj = null;
        try {
            obj = this.m_Stream.parseObject(this, false);
        } catch (ex) {
        }
        if (obj === null) 
            return null;
        obj.id = _id;
        obj.version = v;
        this.m_IndirectObjs[_id] = obj;
        return obj;
    }
    
    _addObj(_id, obj) {
        while (_id >= this.m_IndirectObjs.length) {
            this.m_IndirectObjs.push(null);
            this.m_IndirectObjDisp.push(0);
        }
        this.m_IndirectObjs[_id] = obj;
    }
    
    _addIndir(_id, disp) {
        while (_id >= this.m_IndirectObjs.length) {
            this.m_IndirectObjs.push(null);
            this.m_IndirectObjDisp.push(0);
        }
        this.m_IndirectObjDisp[_id] = disp;
    }
    
    _readXRefs() {
        if (this.m_Stream.length < 100) 
            return false;
        this.m_Stream.position = this.m_Stream.length - 100;
        let str = null;
        while ((((str = this.m_Stream.readWord(true)))) !== null) {
            if (str === "startxref") 
                break;
        }
        if (str === null) 
            return false;
        str = this.m_Stream.readWord(true);
        let disp = 0;
        let wrapdisp199 = new RefOutArgWrapper();
        let inoutres200 = Utils.tryParseInt(str, wrapdisp199);
        disp = wrapdisp199.value;
        if (!inoutres200) 
            return false;
        let infObj = null;
        while (true) {
            if ((disp < 0) || disp >= this.m_Stream.length) 
                return false;
            this.m_Stream.position = disp;
            str = this.m_Stream.readWord(false);
            if (str !== "xref") 
                return false;
            while (true) {
                let id0 = 0;
                let count = 0;
                let i = 0;
                str = this.m_Stream.readWord(true);
                let wrapid0197 = new RefOutArgWrapper();
                let inoutres198 = Utils.tryParseInt(str, wrapid0197);
                id0 = wrapid0197.value;
                if (!inoutres198) 
                    break;
                let wrapcount195 = new RefOutArgWrapper();
                let inoutres196 = Utils.tryParseInt(this.m_Stream.readWord(true), wrapcount195);
                count = wrapcount195.value;
                if (!inoutres196) 
                    break;
                for (i = 0; i < count; i++,id0++) {
                    let w = this.m_Stream.readWord(true);
                    let wrapdisp193 = new RefOutArgWrapper();
                    let inoutres194 = Utils.tryParseInt(w, wrapdisp193);
                    disp = wrapdisp193.value;
                    if (!inoutres194) 
                        break;
                    this.m_Stream.readWord(true);
                    str = this.m_Stream.readWord(true);
                    if (str === null || str.length !== 1) 
                        break;
                    if (str === "n") 
                        this._addIndir(id0, disp);
                }
                if (i < count) 
                    break;
            }
            if (str !== "trailer") 
                return false;
            if (this.m_Stream.readWord(true) !== "<") 
                return false;
            if (this.m_Stream.readWord(true) !== "<") 
                return false;
            this.trailer = new PdfDictionary();
            this.trailer.sourceFile = this;
            this.trailer.postParse(this.m_Stream);
            if (this.trailer.getObject("Encrypt", false) !== null) 
                this.encrypt = this.trailer.getDictionary("Encrypt", null);
            if (this.rootObject === null) {
                let oo = this.trailer.getObject("Root", false);
                if (oo !== null) 
                    this.rootObject = Utils.as(this.getObject(oo.id), PdfDictionary);
            }
            if (infObj === null) 
                infObj = this.trailer.getObject("Info", true);
            let d = 0;
            let prev = Utils.as(this.trailer.getObject("Prev", false), PdfIntValue);
            if (prev === null) 
                break;
            disp = prev.val;
        }
        if (infObj !== null) 
            this.info = Utils.as(this.getObject(infObj.id), PdfDictionary);
        return this.rootObject !== null;
    }
    
    _readObjStm(dic) {
        let dat = dic.extractData();
        if (dat === null || (dat.length < 1)) 
            return false;
        let count = dic.getIntItem("N");
        if (count < 1) 
            return false;
        let pstr = new PdfStream(null, dat); 
        try {
            let ids = new Int32Array(count);
            let disps = new Int32Array(count);
            for (let i = 0; i < count; i++) {
                let _id = Utils.as(pstr.parseObject(this, false), PdfIntValue);
                if (_id === null) 
                    break;
                let disp = Utils.as(pstr.parseObject(this, false), PdfIntValue);
                if (disp === null) 
                    break;
                ids[i] = _id.val;
                disps[i] = disp.val;
            }
            let n0 = pstr.position;
            for (let i = 0; i < count; i++) {
                pstr.position = n0 + disps[i];
                let obj = pstr.parseObject(this, false);
                if (obj !== null) {
                    obj.id = ids[i];
                    obj.sourceFile = this;
                    this._addObj(obj.id, obj);
                    if (obj instanceof PdfDictionary) {
                        if (obj.isTypeItem("ObjStm")) {
                        }
                    }
                }
            }
        }
        finally {
            pstr.close();
        }
        return true;
    }
    
    getAllWhoRefObject0(objId) {
        let res = new Array();
        let ids = new Array();
        for (let i = 1; i < this.maxObjsCount; i++) {
            let o = this.getObject(i);
            if (o === null || o.id === objId) 
                continue;
            ids.splice(0, ids.length);
            o.getAllWhoRefObject(objId, o, res, ids);
        }
        return res;
    }
}


module.exports = PdfFile