<!-- https://mvnrepository.com/artifact/aspose-cad/aspose-cad -->
<dependency>
<groupId>aspose-cad</groupId>
<artifactId>aspose-cad</artifactId>
<version>23.1</version>
<scope>system</scope>
<systemPath>${basedir}/src/main/resources/lib/aspose-cad-23.1.jar</systemPath>
</dependency>
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
import com.aspose.cad.Image;
import com.aspose.cad.fileformats.cad.CadImage;
import com.aspose.cad.fileformats.cad.cadobjects.CadBaseEntity;
public class DwgReader {
public static void main(String[] args) {
// 使用 CadImage 类加载输入 DWG 文件
CadImage dgnImage = (CadImage) Image.load("D:\\a.dwg");
// 在文件中搜索文本
for (CadBaseEntity entity : dgnImage.getEntities())
{
// 我们在这里遍历 CadText 实体,但其他一些实体
// 也可能包含文本,例如 CadMText 和其他
if (entity.getClass() == com.aspose.cad.fileformats.cad.cadobjects.CadText.class)
{
com.aspose.cad.fileformats.cad.cadobjects.CadText text =
(com.aspose.cad.fileformats.cad.cadobjects.CadText)entity;
System.out.println(text.getDefaultValue());
}
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.