WMF — Windows Metafile: The 16-bit Clipboard Standard, Still Alive

2026-06-169 min read
WMFWindowsvectorclipboardGDIlegacy

WMF (Windows Metafile) is a binary vector format developed by Microsoft for Windows 3.0 in 1990. Conceptually it is a recorded sequence of GDI (Graphics Device Interface) calls: "draw a rectangle", "set pen width 2 pixels", "select Arial 10 pt font". When you copy an image from Word or Excel and paste into another program, Windows under the hood often uses WMF to transfer vector data via the clipboard. Thirty-five years later the format continues to live in all Office versions, is supported by LibreOffice, opens in Inkscape and Visio, and remains one of the intermediate exchange standards for vector graphics in the Windows ecosystem.

Map generation of Kazan city center
Kazan Kremlin, 200×200 m fragment. WMF is convenient for inserting a map into a Word document on a Windows machine without dependency on external fonts or raster resources.

History: Windows 3.0, GDI, OLE

In May 1990 Microsoft released Windows 3.0 — the first commercially successful version of the graphical shell. In parallel GDI (Graphics Device Interface) appeared — an API layer for drawing graphics shared by all Windows applications. WMF was conceived as a way to save a sequence of GDI calls into a file or transfer them via the clipboard. The core idea: "save not the picture, save the recipe for drawing it." This allowed scaling vector graphics across different DPIs and reusing illustrations in multiple documents.

Structurally WMF is a sequence of 16-bit records, each representing one GDI call. A record begins with length (in words) and function code. The function type is the low byte of the code. For example 0x0214 is MoveTo, 0x0213 is LineTo, 0x041B is Rectangle. Every 1990s Windows programmer knew these codes by heart, because debugging WMF required reading hex dumps.

In 1992 Windows 3.1 introduced the Placeable Metafile format — WMF with an additional 22-byte header describing size and aspect ratio. Without this header any program opening WMF had to guess scale from context. Placeable Metafile became the standard for embedding into Word documents and distribution on clipart disks. If the magic number 0x9AC6CDD7 is present in the first four bytes — it is a Placeable Metafile.

In parallel OLE (Object Linking and Embedding) technology developed — embedding objects from one application into another's document. WMF was the primary exchange format for OLE: an Excel chart pasted into Word was transferred as WMF. This tradition lives in modern Office versions, although since Windows NT (1993) the extended EMF alternative has been available.

What's inside a WMF file

WMF is a binary format with a very compact structure. The Placeable Metafile header (if present) is 22 bytes:

4 bytes: magic 0x9AC6CDD7
2 bytes: handle (reserved, =0)
8 bytes: bbox (left, top, right, bottom in TWIPS)
2 bytes: inch (logical units per inch)
4 bytes: reserved
2 bytes: checksum

Then the standard WMF header (18 bytes): file type (1 — memory metafile, 2 — disk metafile), version (0x0300 for Windows 3.0+), size in words, number of objects, max record size. After the header follows a sequence of variable-length records. The file ends with a record code 0x0000 (EOF).

WMF coordinates are 16-bit signed integers, range ±32767. The unit is TWIPS (1/1440 inch) or logical units, depending on the current mapping mode. This limitation becomes critical for large maps: a real-world kilometer square shown at source scale doesn't fit into a 16-bit field. The solution is to scale everything into the file's coordinate space, losing absolute size precision.

Objects in WMF are pens (CreatePen), brushes (CreateBrush), fonts (CreateFont), regions (CreateRegion). They are created by indices in the object table and switched via SelectObject. For a Nevsky Avenue map this means: create a pen for roads, a brush for buildings, a font for labels, and switch between them as you render layers.

WMF clipboard pipeline: GDI to Word/Excel

Who needs WMF: four scenarios

Office worker on Microsoft Word 2003 or Visio 2007. In corporate environments where software updates are frozen for 5-10 years, Office 2003 or 2007 still appear (industry, government, some banking systems with regulatory restrictions). Word 2003 recognizes both WMF and EMF, but in certain situations (insertion into text with wrapping, conversion to RTF) WMF works better — because it is the format Word 2003 was originally designed for.

Designer with legacy CAD pipeline. AutoCAD up to version 2009 could import WMF via File → Insert → Image → WMF; after 2010 this capability was removed in favor of DXF and DWG. But in template and block collections for architects, files from 1990–2005 in WMF still circulate. If such a template is used in work — a district map in WMF will sit next to architectural plans without conversion gymnastics.

LibreOffice user on Linux. LibreOffice Draw, Impress, Writer open WMF natively and use it for copying vector graphics between documents. In a Linux environment, where running Word via Wine is a last resort, LibreOffice + WMF is the working exchange path with Windows users.

Archivist of documents. WMF is a format with a long history and stable specification. Microsoft published the [MS-WMF] document under the Open Specifications Initiative in 2007, the format is guaranteed to open in 30+ years. If a district map is part of an archival document that must outlive editor and OS changes, WMF is one of the acceptable variants alongside PDF/A and SVG.

Software for WMF: seven programs

LibreOffice (Draw / Writer). Free, LGPL. Windows/macOS/Linux. Imports WMF without issues, supports the Placeable variant. Convenient WMF → SVG/PDF conversion path: open → File → Export → SVG. libreoffice.org

Inkscape. Free, GPL. Imports WMF via UniConvertor or built-in handler. Exports back to WMF via File → Save As. Sometimes loses gradients and transparency — a format limitation, not an Inkscape one. inkscape.org

Microsoft Word, Excel, PowerPoint. Paid, included in Microsoft 365. All three applications can insert WMF via Insert → Picture or paste from clipboard. When saving to .docx, Word packs the WMF inside the document's ZIP archive. microsoft.com/office

IrfanView. Free for personal use, Windows. A lightweight viewer for raster and vector formats. WMF opens and converts to PNG/JPEG in one click. irfanview.com

Microsoft Visio. Paid, ~$5/month as part of Microsoft 365 or ~$300 one-time. WMF is one of the primary import formats in Visio. For district maps this means: paste WMF from osm2cdr → add a process diagram → export the page as PDF. microsoft.com/visio

CorelDRAW. Paid, ~$650. Opens WMF correctly, saves as native CDR. If the main format in the workflow is CDR, WMF works as an intermediate path between Office and CorelDRAW. coreldraw.com

ImageMagick (CLI). Free. Converts WMF to PNG/PDF/SVG from the command line: magick input.wmf output.png. Useful in documentation build scripts. imagemagick.org

Map generation of Dubai city center
Dubai near Burj Khalifa, 200×200 m. A WMF map is easy to insert into a Word excursion report.

WMF vs EMF — which to choose

Parameter WMF EMF
Released 1990, Windows 3.0 1993, Windows NT
Coordinate width 16-bit, ±32767 32-bit, ±2.1B
Bezier curves No Yes
Transparency No Yes (via EMF+)
Size for typical map 100–500 KB 200–800 KB
Word support All versions Word 2000+
Linux support LibreOffice, Inkscape LibreOffice, Inkscape (worse)

WMF is the default choice if: the document opens in Word before 2007, maximum compatibility is required, the file will traverse multiple Office versions. EMF is the choice if: Bezier curves, transparency, smooth gradients, large coordinates without precision loss are needed.

Pitfalls and tips

16-bit coordinates. The most serious WMF limitation. If a Moscow map at real scale tried to fit into WMF — individual points would exceed ±32767. Solution: scale the map into [0, 30000] coordinate space before export. osm2cdr.ru does this automatically.

Fonts. WMF records the font name (e.g. "Arial") but not the font itself. When opening the file on a machine without that font, Windows substitutes a fallback (usually Microsoft Sans Serif), and map labels look different. Solution: use only Arial, Times New Roman, Courier New — guaranteed installed on any Windows; or convert text to <path> at the preparation stage.

No clipping path. WMF doesn't support arbitrary clip masks. If the district map should be visible only within a circular frame — this must be implemented before export, not at the document insertion stage.

Transparency. WMF knows only binary transparency (either the pixel exists or it doesn't). Semi-transparent building layers or shadow gradients are lost in WMF. For modern graphics use EMF.

Security. Between 2003 and 2010 several vulnerabilities were discovered in the Windows WMF parser (CVE-2005-2124, CVE-2010-1885 and others) allowing code execution via specially crafted files. Modern Windows versions have closed these holes, but as a principle: don't open WMF from untrusted sources in old Office versions (pre-2010).

How to get a map as WMF via osm2cdr.ru

Direct WMF export is not currently in the standard osm2cdr.ru list — the path goes through SVG or EPS with subsequent conversion. Step 1: on osm2cdr.ru choose SVG format and draw the area. Step 2: download the SVG. Step 3: open in Inkscape. Step 4: File → Save As → choose "Windows Metafile (.wmf)". Step 5: insert the resulting file into Word via Insert → Picture → From File. Alternative path: open SVG in LibreOffice Draw, File → Export → choose WMF.

For scripted document builds the ImageMagick + librsvg combo works: rsvg-convert input.svg | magick - input.wmf. Convenient for batch processing of multiple districts at once.

Sources

← All articles