Introduction
A CDR file is the working file of CorelDRAW, the vector drawing program first released by Corel in 1989. It holds pages, layers, shapes, text, fills, outlines, effects and embedded bitmaps. A CDT file is a CorelDRAW template, built the same way.
Corel has never published the format, and it has changed with almost every release. What is known comes from independent reverse engineering, above all libcdr, the Document Liberation Project’s library that LibreOffice and Inkscape use to import CDR files. These pages describe the format as libcdr reads it. Nothing here has been checked against Corel’s own documentation, and where libcdr skips bytes without naming them, so do these pages.
Versions
There are three different containers. The first bytes say which one a file uses.
| CorelDRAW | Container | First bytes |
|---|---|---|
| 1 and 2 | Own format | WL, a byte and a zero |
| 3 | RIFF | RIFF, a length, CDR and a space |
| 4 to 9 | RIFF | RIFF, a length, CDR4 to CDR9 |
| 10, 11, 12 and X3 | RIFF, usually with a compressed list | CDRA, CDRB, CDRC, CDRD |
| X4 and later | ZIP package with a RIFF stream inside | PK; the stream inside has CDRE (X4), CDRF (X5), CDRG (X6) and so on |
In a RIFF file the character after CDR is the version: a space for 3, a
digit for 4 to 9, then A for 10, B for 11 and onwards.
libcdr also accepts lower-case cdr. The vrsn chunk that
follows gives the same version as a number, 100 times the major version: 600 for
CorelDRAW 6, 1300 for X3.
Two changes inside the RIFF versions matter to a reader. CorelDRAW 3 to 5 store coordinates as signed 16-bit thousandths of an inch and counts as 16 bits; from CorelDRAW 6 coordinates are signed 32-bit units of 1/254,000 inch (a tenth of a micrometre) and counts are 32 bits. And CorelDRAW 3 stores each object’s fill, outline and transformation inside the object, where later versions keep tables and refer to them by id.
Structure
A RIFF CorelDRAW file is a tree of chunks. Each chunk is a four-character ID, a
32-bit little-endian length and its data. A LIST chunk holds a list type
and more chunks. The whole file is one RIFF chunk.
0RIFF headerRIFF, the length of the rest,CDRand the version character12 bytes12vrsn the version, 100 times the major version10 bytes22DISP the preview picture, a Windows bitmapvaries…LIST INFO and other chunks of document informationvaries…LIST doc settings and the tables of fonts, fills and outlines, bitmaps and embedded objectsvaries…LIST page one for each page, each with its layers and objectsrepeated
cmpr list.Files from X4 on are ZIP archives. The drawing inside is still a RIFF stream, in
content/riffData.cdr or content/root.dat; from X6 on, much
of its data sits in separate files that its chunks point to.
The rest of the format is described on these pages:
- CorelDRAW 1 and 2 – the WL files and what is known of them
- RIFF chunks – the chunk tree of CorelDRAW 3 to X3, list by list
- Compressed lists – the cmpr list, its two zlib streams and the table of lengths
- Objects – the loda record, its arguments, the shapes and their transformations
- Fills, outlines and fonts – the tables objects refer to, and colours
- Text and styles – the txsm text record in each version, the style sheet and the X6 style strings
- Preview picture – the DISP chunk
- X4 and later – the ZIP package, its data files, metadata and fonts
- CMX files – Corel Presentation Exchange, also kept inside CorelDRAW 6 and later drawings
In the explorer
A CDR, CDT or CMX file dropped on any page opens in the explorer, in your browser, without being uploaded. It shows the chunk tree field by field, inflates compressed lists, follows the data files of X6 and later packages, shows the preview picture and draws each page: rectangles, ellipses, curves and polygons with their solid and gradient fills and outlines (or those of their style), arrowheads, transparency, text laid out from the style sheet, and bitmaps with their transparency masks. Tables list the objects, fills, outlines, fonts, texts, styles, arrowheads, bitmaps and the document palette; for an X4 or later package a Document tab shows its metadata, colour settings, palette, text and fonts. A CMX file opens as its chunks, header, index and lists of instructions.
It does not draw bitmap, full-colour and texture fills, effects (blends, contours,
envelopes, lenses, power clips), OLE objects or master-page objects; text is laid out with the
browser’s fonts and without kerning or text on a path; spot colours of CorelDRAW’s built-in
palettes come out grey; CMX instructions are listed, not drawn; and it reads only the signature
of CorelDRAW 1 and 2 files and draws no CorelDRAW 3 object. A file called .cdr
that is not CorelDRAW’s, such as an Elite commander file, is
turned down and shown as bytes.
Not described
Corel has not published the CDR format. These pages follow the layouts that the open-source libcdr reads, and have not been checked against CorelDRAW itself. Bytes that libcdr steps over are marked unknown.
Known, not yet covered
- Reference: the WL (CorelDRAW 1 and 2) records
(WL); the style sheet’s set 5, tab, bullet, hyphenation, drop cap and
set 11 tables, which libcdr steps over (style sheet);
fill types 8 and 12; the tagged data inside CMX instructions and the CMX description sections, and
big-endian CMX files (CMX); the contents of the OLE storage of
ole2; CorelDRAW’s built-in colour palettes (spot colours), which libcdr holds as tables; the effects (blends, contours, envelopes, lenses, power clips); the embedded font files (embed/) and the fields offont/fontTable.datbeyond its names (X4 and later); and the CorelDRAW 3 inline fill, outline and transformation records. - Viewer: bitmap, full-colour and texture fills, effects, OLE objects, master-page objects, text on a path, kerning and character spacing are not drawn; spot colours of the built-in palettes are drawn grey; CMX instructions are listed but not drawn; CorelDRAW 3 objects and WL records are neither drawn nor decoded; CMX files in the big-endian RIFX form are not read.
- Reference: the files with the extensions
.cpxand.cdrx: no sample could be found, so nothing is claimed about them (CPX). - Reference: only one CorelDRAW 6 drawing and two packages saved by CorelDRAW 2020 were available to check against; versions 3, 4, 5, 7 to 13 and the compressed lists are checked against files built from libcdr’s description, not against files CorelDRAW wrote.
Unknown
- Reference: the many fields marked “unknown” on the sub-pages, such as the three numbers in a compressed list, the 4 bytes of the preview header and the 37 bytes after the frame flag of an X6 text record; libcdr steps over them and no public source names them.
Also used for
- Amstrad CPC tape image – A Spectrum cassette with its timings, so turbo loaders survive.
- Elite commander file – An Elite commander: PC Elite's 208 bytes or the 6502 versions' 256 bytes with checksums, with the galaxy drawn from its seeds.
- Tyrian credits – The game Tyrian's end credits: 131 encrypted Pascal strings, one for each line.
Links
Software
- CorelDRAW – Corel’s vector editor, which makes CDR files (Windows, macOS)
- Inkscape – free vector editor that imports CDR files through libcdr (Windows, macOS, Linux)
- LibreOffice Draw – free drawing program that imports CDR files through libcdr (Windows, macOS, Linux)
Developers
- libcdr – Document Liberation Project library that reads CDR and CMX files (C++)
Reference
- libcdr source code – the reverse-engineered reader these pages follow, version by version
- libcdr’s notes on the CorelDRAW format – text records of versions 4 and 5, text layout rules, fills measured against Corel’s own PDF export (MPL 2.0)