RenderPageToMetafileStream
Rendering and printing
Description
This function is only available in the Delphi edition. It renders a page from the selected document into a TStream as a Windows metafile (vector output), preserving the page's text and vector content rather than rasterizing it to pixels.
The chosen Format controls the metafile variant: mfEMF uses the classic GDI enhanced-metafile path (broad consumer compatibility), mfEMFPlus and mfEMFDual use the GDI+ recording path (better fidelity for transparency and anti-aliasing), and mfWMF produces the legacy 16-bit format.
mfEMFDual records both GDI and GDI+ commands in the same file so that older GDI-only consumers can still read it at the cost of a larger file size. Prefer mfEMFPlus when you know the consumer is GDI+ capable (Office, Illustrator, modern viewers).
Internally this is a convenience wrapper over RenderPageToStream that maps the Format to an integer Options value, so DPI is still multiplied by the per-instance RenderScale set via SetRenderScale.
Syntax
Delphi
Function TPDFlib.RenderPageToMetafileStream(DPI: Double; Page: Integer; Format: TPDFlibMetafileFormat; Target: TStream): Integer;
Parameters
| DPI | The DPI to use when rendering the page. Controls the metafile frame dimensions; vector content itself is DPI-independent |
|---|---|
| Page | The page number to render |
| Format | mfEMF = classic GDI EMF; mfEMFPlus = GDI+ EMF+ Only; mfEMFDual = GDI+ EMF+ Dual (GDI + GDI+ records, larger but broadly compatible); mfWMF = legacy 16-bit WMF |
| Target | The stream to place the rendered metafile bytes into |
Return values
| 0 | The page could not be rendered |
|---|---|
| 1 | The page was rendered correctly and the metafile bytes were written to the stream |