I have been trying to extract the QR Code from PDF using python. When first need to see weather QR Code available in the PDF or not.
Below the Code been attached on it:
import PyPDF2
from pyzbar import pyzbar
from PIL import Image
def has_qr_code(pdf_path):
pdf_file = open(pdf_path, 'rb')
pdf_reader = PyPDF2.PdfReader(pdf_file)
for page in pdf_reader.pages:
images = page.Extract_Image()
for image in images:
img = Image.fromarray(image)
decoded = pyzbar.decode(img)
if decoded:
return True
return False
# Example usage
pdf_path = r"C:\Users\TestData.PDF"
if has_qr_code(pdf_path):
print("QR code found in the PDF.")
else:
print("No QR code found in the PDF.")
On page.Extract Image getting Error : "AttributeError: 'PageObject' object has no attribute 'Extract_Image'"
Suggest !!