Reading drawing information
Use Dwg::version($source) to identify the format a DWG file was saved in. For drawing details such as insertion units, title, author, or last save time, use Dwg::info($source)->read().
See Choose a DWG source for supported inputs.
Identify the stored format
use Mattmy\DwgConverter\Facades\Dwg;
$version = Dwg::version($source);
$code = $version->code; // e.g. 'AC1032'
$format = $version->format; // e.g. 'R2018', or null for an unrecognized AC10xx codeversion() reads the first six bytes without running an external tool. Several software versions can share the same format. A file with a recognized header can still fail to decode.
Read drawing metadata
Requires LibreDWG
dwgreadwith JSON output support. See External tools.
$info = Dwg::info($source)->read();
$title = $info->summary?->title;
$lastSavedAt = $info->timestamps?->lastSavedAt;versioncontains the stored DWG format.drawingUnitsexposes the insertion unit code (INSUNITS) and itsstatus. Recognized units areSPECIFIED, zero isUNSPECIFIED, and missing or unrecognized units areUNKNOWN.summarycontains the title, subject, author, keywords, comments, hyperlink base, last saved by, revision number, and custom properties. An unavailable summary or empty text field isnull. Non-empty text is preserved as supplied.summary->customPropertieslists thenameandvaluepairs returned by LibreDWG in order, including repeated names. Missing or empty property text isnull. An explicit empty list is[], while an absent or unreadable list isnull.timestampsexposescreatedAtandlastSavedAtas RFC 3339 UTC strings ending inZ, with milliseconds when nonzero. An unavailable time isnull. If neither is available,timestampsisnull.
Each read() runs a new query and returns reusable data. Even when you only need one field, it generates and decodes the full JSON and applies the same byte limits and timeout as toJson().
Some LibreDWG builds emit invalid UTF-8 for characters such as certain emoji. In that case read() fails with info_invalid. See troubleshooting.