import qrcode # Function to generate QR code for a file def generate_qr_code(file_path, output_path): qr = qrcode.QRCode( version=1, error_correction=qrcode.constants.ERROR_CORRECT_L, box_size=10, border=4, ) # Add data (in this case, a file path or URL) qr.add_data(file_path) qr.make(fit=True) # Create an image from the QR Code instance img = qr.make_image(fill_color="black", back_color="white") # Save the image # Example usage file_path = "file:///D:/Downloads/Orange%20und%20Gr%C3%BCn%20Pizza%20Speisekarte.pdf" output_path = "qrcode.png" generate_qr_code(file_path, output_path)