Working with CAD metadata
Leave feedback
The GroupDocs Metadata API provides the feature to read basic metadata in CAD files. The supported CAD formats are:
- DWG
- DXF
To access metadata in a CAD drawing, the GroupDocs.Metadata API provides the CadRootPackage.getCadPackage method.
The following code snippet reads metadata associated with a CAD file.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputDxf)) {
CadRootPackage root = metadata.getRootPackageGeneric();
System.out.println(root.getCadPackage().getAcadVersion());
System.out.println(root.getCadPackage().getAuthor());
System.out.println(root.getCadPackage().getComments());
System.out.println(root.getCadPackage().getCreatedDateTime());
System.out.println(root.getCadPackage().getHyperlinkBase());
System.out.println(root.getCadPackage().getKeywords());
System.out.println(root.getCadPackage().getLastSavedBy());
System.out.println(root.getCadPackage().getTitle());
// ...
}
The GroupDocs.Metadata API also allows updating metadata properties in a DXF drawing. Please check the code sample below.
advanced_usage.managing_metadata_for_specific_formats.
try (Metadata metadata = new Metadata(Constants.InputDxf)) {
CadRootPackage root = metadata.getRootPackageGeneric();
root.getCadPackage().setProperties(new WithNameSpecification("Author"), new PropertyValue("GroupDocs"));
root.getCadPackage().setProperties(new WithNameSpecification("Comments"), new PropertyValue("test comment"));
root.getCadPackage().setProperties(new WithNameSpecification("HyperlinkBase"), new PropertyValue("test hyperlink base"));
root.getCadPackage().setProperties(new WithNameSpecification("Keywords"), new PropertyValue("test keywords"));
root.getCadPackage().setProperties(new WithNameSpecification("LastSavedBy"), new PropertyValue("test editor"));
root.getCadPackage().setProperties(new WithNameSpecification("RevisionNumber"), new PropertyValue("test revision number"));
root.getCadPackage().setProperties(new WithNameSpecification("Subject"), new PropertyValue("test subject"));
root.getCadPackage().setProperties(new WithNameSpecification("Title"), new PropertyValue("test title"));
root.getCadPackage().setProperties(new WithNameSpecification("CreatedDateTime"), new PropertyValue(new Date()));
root.getCadPackage().setProperties(new WithNameSpecification("ModifiedDateTime"), new PropertyValue(new Date()));
metadata.save(Constants.OutputDxf);
}
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured Java library we provide simple, but powerful free Apps.
You are welcome to view and edit metadata of PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, emails, images and more with our free online Free Online Document Metadata Viewing and Editing App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.