Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Search Text in DWG File using Java
// Load the input DWG file with CadImage class
CadImage dgnImage = (CadImage) Image.load("search.dwg");
// Search for text in the file
for (CadBaseEntity entity : dgnImage.getEntities())
{
// We iterate through CadText entities here, but some other entities
// may contain text also, e.g. CadMText and others
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());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment