Skip to content

API 參考

本頁只列出 application-facing API。操作細節與安裝方式請閱讀對應指南。

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

每個方法只綁定來源、不執行 I/O,並回傳新操作。請參考輸入與輸出

ThumbnailExtraction

php
extract(): DwgOutput

擷取內嵌 BMP、PNG 或 WMF 預覽。請參考擷取縮圖

DxfConversion

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

toVersion() 回傳具有指定 target 的新操作;convert() 建立 ASCII DXF。請參考 轉換為 DXF

DxfVersion cases:R12R14R2000R2004R2007R2010R2013R2018

JsonConversion

php
convert(): DwgOutput

建立 LibreDWG 結構 JSON,沒有 target-version 或 format 選項。請參考輸出結構 JSON

ImageConversion

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

每個選項都回傳新操作並保留其他選擇。請參考建立圖片預覽

  • ImageFormatPNGJPEGWEBP
  • ImageResolutionHIGHMEDIUMLOW

DwgBinary

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

包裝 raw bytes,避免 string 被誤認為 local path。

DwgOutput

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

extension()mimeType() 不會消費結果。output()storeAs() 只能選擇一個呼叫一次。

Exceptions

LibreDwgUnavailableInvalidDwgDwgOperationFailed 都提供:

php
reason(): string
context(): array

請參考錯誤與疑難排解

Last updated:

使用 MIT License 發布。