ExAnydoc can infer a format from document bytes, an extension, or a path. An explicit format always removes ambiguity when converting bytes.
Supported formats
| Documents | Extensions | Format |
|---|---|---|
| Word binary | .doc | :doc |
| Word OOXML | .docx, .docm | :docx |
| PowerPoint binary | .ppt, .pps, .pot | :ppt |
| PowerPoint OOXML | .pptx, .pptm, .ppsx, .ppsm | :pptx |
| Excel | .xls, .xlsx, .xlsm, .xlsb | :excel |
| OpenDocument | .odt, .ods, .odp | :odt, :ods, :odp |
| Other | .rtf, .epub, .csv, .pdf | :rtf, :epub, :csv, :pdf |
Legacy and OOXML variants use different format atoms for Word and PowerPoint.
All supported Excel extensions use :excel.
Detection
Use the detection helpers without performing a conversion:
:docx = ExAnydoc.format_from_bytes(File.read!("report.docx"))
:docx = ExAnydoc.format_from_extension(".DOCM")
:pptx = ExAnydoc.format_from_path("presentation.PPSX")
nil = ExAnydoc.format_from_path("archive.bin")Extension matching is case-insensitive and accepts a leading dot. Content
detection returns nil for unknown data and for signature-less CSV data.
PDF limitation
Text-based PDFs can be converted to Markdown. Scanned or image-only PDFs need
OCR, which ExAnydoc does not provide. PDF is also unavailable through
ExAnydoc.to_document/2; use one of the Markdown conversion functions instead.
File paths versus binaries
Use a path when the document is already on disk. Use bytes for uploads, blobs, or data fetched from another source. Both variants run native parsing work on a dirty CPU scheduler, so they do not occupy a regular BEAM scheduler while the conversion runs.