How does one delete an indirect object (or mark it for removal)?
Thanking you in advance,
Joe
How does one delete an indirect object (or mark it for removal)?
Thanking you in advance,
Joe
All indirect (shared) SDF/Cos objects that are not referenced anywhere
in the document will be automatically removed when calling doc.Save()
with SDFDoc.SaveOptions.e_linearized or
SDFDoc.SaveOptions.e_remove_unused option. PDFNet may also
periodically 'garbage collect' unused indirect objects.
If you are not sure whether a given object (e.g. an image) is
referenced from a document, you could replace it with another object
(such as Null). This way any outstanding references will point to this
Null object. For example:
Obj image_dict = image.GetSDFObj();
Obj null_obj = doc.CreateIndirectNull();
doc.GetSDFDoc().Swap(image_dict.GetObjNum(), null_obj.GetObjNum());
...
doc.Save(..., SDFDoc.SaveOptions.e_linearized);