Set Document Metadata on Save
Leave feedback
On this page
The comparison result document can carry metadata (author, organization, creation date, etc.). Use SaveOptions.clone_metadata_type to choose where it comes from:
MetadataType.SOURCE— clone metadata from the source document.MetadataType.TARGET— clone metadata from the target document.MetadataType.FILE_AUTHOR— set user-defined metadata viaSaveOptions.file_author_metadata.
from groupdocs.comparison import Comparer
from groupdocs.comparison.options import SaveOptions, MetadataType
def set_metadata_from_source():
with Comparer("./source.docx") as comparer:
comparer.add("./target.docx")
save_options = SaveOptions()
save_options.clone_metadata_type = MetadataType.SOURCE
comparer.compare("./result.docx", save_options)
if __name__ == "__main__":
set_metadata_from_source()
source.docx is the source file used in this example. Click here to download it.
target.docx is the target file used in this example. Click here to download it.
Binary file (DOCX, 25 KB)
from groupdocs.comparison import Comparer
from groupdocs.comparison.options import SaveOptions, MetadataType
def set_metadata_from_target():
with Comparer("./source.docx") as comparer:
comparer.add("./target.docx")
save_options = SaveOptions()
save_options.clone_metadata_type = MetadataType.TARGET
comparer.compare("./result.docx", save_options)
if __name__ == "__main__":
set_metadata_from_target()
source.docx is the source file used in this example. Click here to download it.
Binary file (DOCX, 25 KB)
from groupdocs.comparison import Comparer
from groupdocs.comparison.options import SaveOptions, MetadataType, FileAuthorMetadata
def set_user_defined_metadata():
with Comparer("./source.docx") as comparer:
comparer.add("./target.docx")
author_metadata = FileAuthorMetadata()
author_metadata.author = "Tom"
author_metadata.company = "GroupDocs"
author_metadata.last_save_by = "Jack"
save_options = SaveOptions()
save_options.clone_metadata_type = MetadataType.FILE_AUTHOR
save_options.file_author_metadata = author_metadata
comparer.compare("./result.docx", save_options)
if __name__ == "__main__":
set_user_defined_metadata()
source.docx is the source file used in this example. Click here to download it.
Binary file (DOCX, 25 KB)
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.