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;

Parameters

EnablePass 1 to enable automatic garbage collection, or 0 to disable it (default).

Return values

0Failed to apply setting (no active document).
1Setting 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');

See also

GetGarbageCollect, GarbageCollectObjects