Skip to content

API reference

This page lists application-facing APIs. Follow the linked guides for operation details and setup.

Facade operations

php
Dwg::thumbnail(UploadedFile|string|DwgBinary $source): ThumbnailExtraction
Dwg::toDxf(UploadedFile|string|DwgBinary $source): DxfConversion
Dwg::toJson(UploadedFile|string|DwgBinary $source): JsonConversion
Dwg::toImage(UploadedFile|string|DwgBinary $source): ImageConversion

Each method binds a source without I/O and returns a new operation. See Inputs and outputs.

ThumbnailExtraction

php
extract(): DwgOutput

Extracts an embedded BMP, PNG, or WMF preview. See Extracting thumbnails.

DxfConversion

php
toVersion(DxfVersion $version): self
convert(): DwgOutput

toVersion() returns a new operation with the selected target. convert() creates ASCII DXF. See Converting to DXF.

DxfVersion cases: R12, R14, R2000, R2004, R2007, R2010, R2013, R2018.

JsonConversion

php
convert(): DwgOutput

Creates LibreDWG structural JSON. It has no target-version or format option. See Exporting structural JSON.

ImageConversion

php
format(ImageFormat $format): self
usingDxfVersion(DxfVersion $version): self
atResolution(ImageResolution $resolution): self
convert(): DwgOutput

Every option returns a new operation and preserves the other selections. See Creating image previews.

  • ImageFormat: PNG, JPEG, WEBP.
  • ImageResolution: HIGH, MEDIUM, LOW.

DwgBinary

php
DwgBinary::from(string $contents): DwgBinary
$binary->contents(): string

Wraps raw bytes so a string is not mistaken for a local path.

DwgOutput

php
extension(): string
mimeType(): string
output(): string
storeAs(string $path, string $name, ?string $disk = null): string

extension() and mimeType() do not consume the result. Call exactly one of output() or storeAs().

Exceptions

LibreDwgUnavailable, InvalidDwg, and DwgOperationFailed all provide:

php
reason(): string
context(): array

See Errors and troubleshooting.

Last updated:

Released under the MIT License.