Adding metadata properties is one of the most powerful features of the GroupDocs.Metadata search engine. When you call the add_properties method, it examines all available metadata packages and tries to pick up a known property that satisfies the specified predicate. Note that a property is added only to packages that fit the following criteria:
Only existing metadata packages are affected. No new packages are created during this operation.
There must be a known metadata property that fits the search condition but is actually missing from the package. The properties supported by a package are usually defined in the specification of the corresponding metadata standard.
fromdatetimeimportdatetimefromgroupdocs.metadataimportMetadatafromgroupdocs.metadata.commonimportPropertyValuefromgroupdocs.metadata.taggingimportTagsdefadding_metadata():withMetadata("input.docx")asmetadata:# Add the "last printed" date wherever it is a known but missing propertyproperty_value=PropertyValue(datetime.now())affected=metadata.add_properties(lambdap:Tags.time.printedinlist(p.tags),property_value)print(f"Affected properties: {affected}")metadata.save("output.docx")if__name__=="__main__":adding_metadata()
input.docx is the sample file used in this example. Click here to download it.