FileType.get_supported_file_types() returns every file type that the installed version can open. To check a single file, pass its extension to FileType.from_extension, which returns FileType.UNKNOWN for an extension the library does not support:
importosfromgroupdocs.signature.domainimportFileType# Every file type the installed version can openforfile_typeinFileType.get_supported_file_types():print(f"{file_type.extension}: {file_type.file_format}")# Check whether one file is supportedextension=os.path.splitext("contract.pdf")[1]ifFileType.from_extension(extension)==FileType.UNKNOWN:print(f"{extension} files are not supported")else:print(f"{extension} files are supported")
Example: Working with Different File Formats
The same code signs every supported format; the library detects the format from the file:
importosfromgroupdocs.signatureimportSignaturefromgroupdocs.signature.optionsimportTextSignOptions# The same code signs every supported formatforsourcein("sample.pdf","sample.docx","sample.xlsx"):name,extension=os.path.splitext(source)withSignature(source)assignature:options=TextSignOptions("John Smith")options.left=100options.top=100result=signature.sign(f"{name}_signed{extension}",options)print(f"{source}: {len(result.succeeded)} signature(s) added")
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.
On this page
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.