CompressPageAsMRC
Rendering and printing, Image handling, Optimisation
Description
Rebuilds a scanned page as a Mixed Raster Content pair: a downsampled JPEG background under a full-resolution CCITT stencil mask
Syntax
Delphi
Function CompressPageAsMRC(Page: Integer; DPI: Double; BGScale, JPEGQuality, Threshold, Options: Integer): Integer;ActiveX
Function PDFlib::CompressPageAsMRC(Page As Long, DPI As Double, BGScale As Long, JPEGQuality As Long, Threshold As Long, Options As Long) As LongDLL
int DLCompressPageAsMRC(int InstanceID, int Page, double DPI, int BGScale, int JPEGQuality, int Threshold, int Options);Parameters
| Page | 1-based page to rebuild |
|---|---|
| DPI | Render resolution of the source raster, 50 to 1200 |
| BGScale | Background downsample factor, 1 to 8; 4 turns a 200 DPI background into a 50 DPI JPEG |
| JPEGQuality | Background JPEG quality, 1 to 100 |
| Threshold | Rec. 601 luminance threshold separating foreground from background, 1 to 255; pixels at or above stay in the mask |
| Options | Reserved for future use, pass 0 |
Return values
| Bytes | The replaced content size in bytes, or 0 when an argument is out of range, rendering fails or a layer cannot be embedded |
|---|
Remarks
The page content is replaced: the original operators are removed and the page becomes a /DCTDecode background image drawn at the page box with a /CCITTFaxDecode /ImageMask stencil over it painted in the current fill colour. Run SetFillColor before the call to choose the foreground colour, typically black
Text stays crisp because the mask keeps full source resolution whilst the JPEG background carries the halftones at a fraction of the size; typical scanned-text pages shrink well below a flat single-image JPEG of the same page
The call does not flatten annotations or form fields — they stay as objects above the rebuilt content
See also
RenderPageToMonochromeFileEx, SetImageAsMask, AddImageCCITTFromStream, SetPageContentFromString