FlattenTransparency

Document manipulation, Rendering, PDF compatibility

Description

Replaces every selected page with one opaque raster image that preserves the rendered appearance while removing transparency from reachable page content

Syntax

Delphi

Function TPDFlib.FlattenTransparency(Const PageRange: WideString; DPI: Double; BackgroundColor: Cardinal; Options: Integer): Integer;

Parameters

PageRangePage range expression, or an empty string for every page
DPIRaster resolution from 36 through 1200 dots per inch
BackgroundColorOpaque raster background as a COLORREF value
OptionsBitwise combination of PDF_FLATTEN_TRANSPARENCY_KEEP_ANNOTATIONS and PDF_FLATTEN_TRANSPARENCY_GARBAGE_COLLECT, or PDF_FLATTEN_TRANSPARENCY_DEFAULT

Return values

Returns the number of pages replaced, or 0 when validation or rendering fails before any page is replaced

Remarks

The default option renders annotations and form fields into the replacement image, removes their interactive objects, and collects unreachable objects so a compatible older PDF version can be selected afterward

PDF_FLATTEN_TRANSPARENCY_KEEP_ANNOTATIONS preserves annotation and form objects and excludes them from the raster pass so they are not drawn twice

Soft masks, blend modes and isolated or knockout transparency groups are composited exactly as in bitmap rendering, so the replacement image looks like the page did in a viewer

By default, rotated pages are written with their visual dimensions and a zero rotation, UserUnit is folded into the media-box dimensions, and auxiliary page boxes are removed

When annotations are kept, the original page boxes, rotation and UserUnit stay in place and the replacement raster is mapped back into that coordinate system, so links, widgets and appearance streams remain aligned

Processing is page-streamed to bound peak raster memory, supports progress and cancellation, and may return a partial page count after a later-page failure or cancellation

Garbage collection invalidates IDs for unreachable images, captures, graphics states, and other removed resources, so acquire new IDs after this call when the garbage-collection option is used

See also

RenderPageTileToStream, SetInformation, FlattenAnnotsOnPageRange