예제 #1
0
        public HPDF_Xref_Entry HPDF_Xref_GetEntryByObjectId(uint objId)
        {
            LibLogger.Debug(this.GetType(), "HPDF_Xref_GetEntryByObjectId");

            HPDF_Xref tmpXref = this;

            while (tmpXref != null)
            {
                uint i;

                if (tmpXref.Entries.Count + tmpXref.StartOffset > objId)
                {
                    Error = new HPDF_Error("HPDF_Xref_GetEntryByObjectId", HPDF_Error.HPDF_INVALID_OBJ_ID, 0);
                }

                if (tmpXref.StartOffset < objId)
                {
                    for (i = 0; i < tmpXref.Entries.Count; i++)
                    {
                        if (tmpXref.StartOffset + i == objId)
                        {
                            HPDF_Xref_Entry entry = tmpXref.HPDF_Xref_GetEntry((int)i);
                            return(entry);
                        }
                    }
                }

                tmpXref = tmpXref.Prev;
            }

            return(null);
        }
예제 #2
0
        public double HPDF_Xref_Free()
        {
            LibLogger.Debug(this.GetType(), "HPDF_Xref_Free");

            HPDF_Xref lxref = this;

            while (lxref != null)
            {
                /* delete all objects belong to the xref. */

                if (lxref.Entries.Count > 0)
                {
                    for (int i = 0; i < lxref.Entries.Count; i++)
                    {
                        var entry = lxref.HPDF_Xref_GetEntry(i);
                        if (entry.Obj != null)
                        {
                            //HPDF_Obj_ForceFree (xref->mmgr, entry->obj);
                            entry.Obj = null;
                        }
                        // HPDF_FreeMem (xref->mmgr, entry);
                    }
                    ///HPDF_List_Free(xref->entries);
                    lxref.Entries = null;
                }

                if (lxref.Trailer != null)
                {
                    //     HPDF_Dict_Free (xref->trailer);
                    lxref.Trailer = null;
                }

                var tmpXref = lxref.Prev;
                //HPDF_FreeMem (xref->mmgr, xref);
                lxref = null;
                lxref = tmpXref;
            }

            return(HPDF_Consts.HPDF_OK);
        }