extract_cdxml_from_office
Extract embedded ChemDraw objects from Office files (PPTX, DOCX, XLS, XLSX) and convert them to CDXML files.
Instructions
Extract embedded ChemDraw objects from a PPTX, DOCX, XLS, or XLSX file.
Office files (PPTX/DOCX/XLSX) are ZIP archives that may contain ChemDraw OLE objects as binary blobs. XLS files are OLE2 compound documents with embedded ChemDraw objects stored in MBD* sub-storages. This tool extracts every ChemDraw object, converts it to CDXML, and writes the files to output_dir.
Requires: olefile. CDX→CDXML conversion uses available backends.
Args: file_path: Path to a .pptx, .docx, .xlsx, or .xls file. output_dir: Directory for extracted CDXML files. Default: a folder named "_chemdraw/" next to the input file.
Returns: Dict with keys: ok, input, output_dir, objects (list of: source_path, cdxml_output, cdx_output, error for each extracted object). Returns {ok: False, error: "..."} if extraction fails entirely.
Safety override: Extract every object transactionally; publish nothing on partial failure.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| file_path | Yes | ||
| output_dir | No |