Skip to content
Snippets Groups Projects
pdf_format.py 307 B
Newer Older
  • Learn to ignore specific revisions
  • Jesper Zedlitz's avatar
    Jesper Zedlitz committed
    from pypdf import PdfReader
    from pypdf.errors import PyPdfError
    
    
    def is_valid(resource, file):
        """Check if the content is a readable PDF document."""
    
        with open(file.name, "rb") as f:
            try:
                PdfReader(f)
                return True
            except PyPdfError:
                return False