Search Text in DWG Java

DWG files are CAD drawings containing vector image data and metadata written with binary coding. In some use cases, you may want to search text in a DWG file. Following such requirements, this article covers how to search a text string in a DWG file programmatically using Java.

Find Text in DWG File – Java API Installation

You need to configure Aspose.CAD for Java API in your project to work with different CAD files like DWG, DXF, etc. You can quickly configure it by downloading the JAR files from the New Releases section or access it from the Aspose Repository with the following settings in the pom.xml file of your project:

Repository:

 <repositories>
    <repository>
        <id>AsposeJavaAPI</id>
        <name>Aspose Java API</name>
        <url>http://repository.aspose.com/repo/</url>
    </repository>
</repositories>

Dependency:

 <dependencies>
    <dependency>
        <groupId>com.aspose</groupId>
        <artifactId>aspose-cad</artifactId>
        <version>22.7</version>
    </dependency>
</dependencies>

How to Search Text String in DWG Drawing in Java

You can find and text string in a DWG file with the following steps:

  1. Load the input DWG file.
  2. Search for the text string in the source file.
  3. Iterate through CadText entities and find text.

Search Text in DWG Drawing Programmatically in Java

The following steps elaborate on how to search text in a DWG drawing file:

  1. Load the input DWG file with CadImage class.
  2. Search for the text string in the source file.
  3. Iterate through CadText entities and find text.

The following code sample elaborates on how to search text in DWG drawing programmatically in Java:

Get a Free API License

You may try the API to its full capacity by getting a free temporary license. It enables all the features without any watermarks or limitations.

Conclusion

In this article, you have learned how to search text in DWG drawing programmatically in Java. Furthermore, you can take a look at various other features included in the API by visiting the documentation section. If you have any concerns, please feel free to reach out to us at forum.

See Also