RenderPageToMetafileFile

Rendering and printing

Description

This function renders a page from the selected document to a Windows metafile (vector output) on disk. It is the file-based counterpart of RenderPageToMetafileStream and writes the same byte stream that the stream variant would produce.

Use the Format parameter to pick the metafile variant: mfEMF for classic GDI enhanced metafiles, mfEMFPlus for GDI+ recorded EMF+ Only (best fidelity), mfEMFDual for EMF+ Dual (GDI + GDI+ records, broadly compatible but larger), and mfWMF for legacy 16-bit metafiles.

The resulting file can be opened directly by vector-capable consumers such as Microsoft Office, Adobe Illustrator, Visio, and modern image viewers, preserving text and vector fidelity rather than rasterizing to pixels.

Syntax

Delphi

Function TPDFlib.RenderPageToMetafileFile(DPI: Double; Page: Integer; Format: TPDFlibMetafileFormat; Const FileName: WideString): Integer;

Parameters

DPIThe DPI to use when rendering the page. Controls the metafile frame dimensions; vector content itself is DPI-independent
PageThe page number to render
FormatmfEMF = classic GDI EMF; mfEMFPlus = GDI+ EMF+ Only; mfEMFDual = GDI+ EMF+ Dual (GDI + GDI+ records, larger but broadly compatible); mfWMF = legacy 16-bit WMF
FileNameThe path and file name of the metafile to create

Return values

0The page could not be rendered or the file could not be written
1The page was rendered correctly and the metafile was saved to disk