TrimPageContentToCropBox
Content stream editing
Description
Rewrites every content layer on the requested page and removes complete top-level text runs, painted paths, image placements, and Form XObject invocations whose conservative transformed bounds lie fully outside the effective CropBox. If the page has no explicit CropBox, its inherited MediaBox is used
Objects that intersect the retained box, have unresolved bounds, participate in a clipping path, or use a text clipping rendering mode are preserved. Text bytes are replaced with an equivalent numeric advance so later relative text keeps its position. Intersecting Form XObjects are retained without modifying their shared internal streams
Syntax
Delphi
Function TPDFlib.TrimPageContentToCropBox(Page: Integer; Margin: Double= 0): Integer;
ActiveX
Function PDFlib::TrimPageContentToCropBox(Page As Long, Margin As Double) As Long
DLL
int DLTrimPageContentToCropBox(int InstanceID, int Page, double Margin);
Parameters
| Page | One-based page number to rewrite |
|---|---|
| Margin | Margin in the current measurement units. Positive values inset the retained box and negative values expand it |
Return values
| 0 or greater | Number of complete paint objects removed. Zero also means that no eligible object was found or the page or margin was invalid |
|---|
Example
Removed := PDF.TrimPageContentToCropBox(1, 0);
PDF.SaveToFile('trimmed.pdf');