SetGarbageCollect
Document properties, Optimisation
Description
Enables or disables automatic mark-sweep garbage collection of unreferenced indirect objects during a full save operation.
Syntax
Delphi
Function TPDFlib.SetGarbageCollect(Enable: Integer): Integer;ActiveX
Function PDFlib::SetGarbageCollect(Enable As Long) As LongDLL
int DLSetGarbageCollect(int InstanceID, int Enable);Parameters
| Enable | Pass 1 to enable automatic garbage collection, or 0 to disable it (default). |
|---|
Return values
| 0 | Failed to apply setting (no active document). |
|---|---|
| 1 | Setting applied successfully. |
Remarks
Garbage collection identifies and removes unreachable PDF objects, which helps reduce the output file size when pages or annotations have been deleted. Automatic collection is performed when SaveToFile, SaveToStream, or SaveToString is called.
Example
PDF.SetGarbageCollect(1); // Enable GC during save
PDF.SaveToFile('output.pdf');