{"id":23790067,"url":"https://github.com/kaitai-io/coreldraw_cdr.ksy","last_synced_at":"2025-07-19T04:03:23.441Z","repository":{"id":41532629,"uuid":"249818779","full_name":"kaitai-io/coreldraw_cdr.ksy","owner":"kaitai-io","description":"CDR (CorelDRAW drawing) format specification for Kaitai Struct","archived":false,"fork":false,"pushed_at":"2023-07-23T11:54:42.000Z","size":99,"stargazers_count":4,"open_issues_count":3,"forks_count":2,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-07-07T08:11:54.955Z","etag":null,"topics":["coreldraw","file-format","kaitai-struct","vector-graphics"],"latest_commit_sha":null,"homepage":"","language":"Kaitai Struct","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaitai-io.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-03-24T21:10:57.000Z","updated_at":"2025-07-06T09:28:19.000Z","dependencies_parsed_at":"2025-02-21T12:43:26.627Z","dependency_job_id":"121de009-530d-4f4c-bd06-4ea1baf49e50","html_url":"https://github.com/kaitai-io/coreldraw_cdr.ksy","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/kaitai-io/coreldraw_cdr.ksy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaitai-io%2Fcoreldraw_cdr.ksy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaitai-io%2Fcoreldraw_cdr.ksy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaitai-io%2Fcoreldraw_cdr.ksy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaitai-io%2Fcoreldraw_cdr.ksy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaitai-io","download_url":"https://codeload.github.com/kaitai-io/coreldraw_cdr.ksy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaitai-io%2Fcoreldraw_cdr.ksy/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265887072,"owners_count":23844335,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["coreldraw","file-format","kaitai-struct","vector-graphics"],"created_at":"2025-01-01T17:18:17.274Z","updated_at":"2025-07-19T04:03:23.419Z","avatar_url":"https://github.com/kaitai-io.png","language":"Kaitai Struct","funding_links":[],"categories":[],"sub_categories":[],"readme":"# coreldraw_cdr.ksy\n\nCDR (CorelDRAW drawing) format specification for Kaitai Struct\n\n## What it is\n\nFormal specifications for the CorelDRAW `.cdr` format in [Kaitai Struct](https://kaitai.io/) YAML (`.ksy`), a declarative language for describing binary formats.\n\nIf you are interested in...\n\n* what graphic objects (paths, polygons, rectangles, ellipses, embedded images) the CDR document contains,\n* how do they look like (i.e. the geometry data associated with them: path points, rectangle side lengths and so on),\n* what fill and outline styles the objects use (solid colors, gradients),\n* what transformation matrix is applied on each object,\n\n... and more, [Kaitai Struct](https://kaitai.io/) can make all this data accessible to you given the `.ksy` specifications from this repository.\n\n## How to use\n\n**Use the [`bin/cdr-unpk`](bin/cdr-unpk) Bash script** to preprocess the `.cdr` file so that you can read all CDR versions (especially the new ones) without having to worry about what version of the CDR format the `.cdr` file in front of you is using. The usage is the following:\n\n```\nbin/cdr-unpk example.cdr\n```\n\nIt creates \u003ccode\u003eexample.cdr\u003cstrong\u003e.unpk\u003c/strong\u003e\u003c/code\u003e in the same directory where `example.cdr` is. The `example.cdr.unpk` file needs to be interpreted by [`cdr_unpk.ksy`](cdr_unpk.ksy) (which imports [`coreldraw_cdr.ksy`](coreldraw_cdr.ksy) and [`file_streams.ksy`](file_streams.ksy) under the hood).\n\n---\n\nTo understand why applying the `coreldraw_cdr.ksy` Kaitai Struct specification to real-world `.cdr` files is complicated, you need to have a basic overview of CDR format versions:\n\n* X3 (13.0) and older: directly the RIFF-based chunk structure that `coreldraw_cdr.ksy` understands;\n* X4 (14.0) and X5 (15.0): a ZIP archive, the `coreldraw_cdr.ksy` spec can only recognize the `content/riffData.cdr` file inside it;\n* X6 (16.0) or later: also a ZIP archive, but the entrypoint is `content/root.dat` which needs to read external chunk payloads from `content/data/*.dat` files.\n\nThe need for accessing external streams in CDR X6+ files was a problem, because to be able to use visualizers available for [Kaitai Struct](https://kaitai.io/) (e.g. [ksv](https://github.com/kaitai-io/kaitai_struct_visualizer), [Web IDE](https://ide.kaitai.io/)), the entire parsed byte stream needs to be contained in a single file and the top-level type in the main `.ksy` spec must not have any parameters. That's why the [`bin/cdr-unpk`](bin/cdr-unpk) script was created - it extracts the necessary streams from the given `.cdr` file and dumps them into a `.unpk` file in a custom auxiliary format described in [`cdr_unpk.ksy`](cdr_unpk.ksy).\n\n## Standalone use of `coreldraw_cdr.ksy` from your application\n\nThere is a branch [`unpack-zip-yourself`](https://github.com/kaitai-io/coreldraw_cdr.ksy/tree/unpack-zip-yourself) available when you want to use the Kaitai Struct parser generated from `coreldraw_cdr.ksy` in your application. It makes the integration easier, because it provides you a top-level parameter where you pass a list of `KaitaiStream` objects for each external data stream in X6+ files (in the order specified in `content/dataFileList.dat` file of X6+ `.cdr` ZIP archives):\n\n```ksy\nparams:\n  - id: streams\n    type: io[]\n```\n\nFor pre-X6 `.cdr` files, just pass an empty list.\n\nYou should be able to understand how to find the data streams in the ZIP archive by looking [into `bin/cdr-unpk`](https://github.com/kaitai-io/coreldraw_cdr.ksy/blob/2266d9908f058a27186a7008f263c0ab74e54beb/bin/cdr-unpk#L30), or you can look [into **libcdr**](https://github.com/LibreOffice/libcdr/blob/b14f6a1f17652aa842b23c66236610aea5233aa6/src/lib/CDRDocument.cpp#L154).\n\n## Manual standalone use of `coreldraw_cdr.ksy` (no support for external streams)\n\nBy default, the `coreldraw_cdr.ksy` spec is expected to be imported from [`cdr_unpk.ksy`](cdr_unpk.ksy) and not used by itself. However, if you don't want to preprocess `.cdr` files by [`bin/cdr-unpk`](bin/cdr-unpk), you can manually edit `coreldraw_cdr.ksy` to disable support for external streams (comment out sections `/meta/imports`, `/params` and `/types/chunk_wrapper/instances/body_external`).\n\nSuch a `coreldraw_cdr.ksy` specification can be used directly on the `.cdr` file for pre-X4 files (will work great), or on `content/riffData.cdr` if it's inside the ZIP archive of CDR X4/X5 files. For X6 and later it's technically possible to use it on `content/root.dat` itself too, but you won't get too deep into the file because it uses external streams for most chunks (so it probably won't be very useful).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaitai-io%2Fcoreldraw_cdr.ksy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaitai-io%2Fcoreldraw_cdr.ksy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaitai-io%2Fcoreldraw_cdr.ksy/lists"}