import os
import fitz
import PySimpleGUI as sg
layout = [
    [sg.Text('Select a PDF file:'), sg.Input(key='file'), sg.FileBrowse()],
    [sg.Button('Generate PDF without images')]
]
window = sg.Window('PDF Image Remover', layout)
while True:
    event, values = window.read()
    if event == sg.WIN_CLOSED:
        break
    if event == 'Generate PDF without images':
        pdf_file = values['file']
        doc = fitz.open(pdf_file)
        for page in doc:
            blocks = page.get_text("dict")["blocks"]
            imgblocks = [b for b in blocks if b["type"] == 1]
        for imgblock in imgblocks:
            xref = imgblock["image"][0]
            if not isinstance(xref, int):
                raise TypeError(f"xref must be an integer, not {type(xref)}")
            page.delete_image(imgblock)
        new_pdf_file = os.path.splitext(pdf_file)[0] + '--no images.pdf'
        doc.save(new_pdf_file)
        doc.close()
        sg.popup(f'PDF file without images generated: {new_pdf_file}')
window.close() got this erros on this code while trying to generate pdf: Traceback (most recent call last):
  File "j:\INSTALAR\python pdf image remover.py", line 30, in 
    page.delete_image(imgblock)
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python310\lib\site-packages\fitz\utils.py", line 280, in delete_image
    page.replace_image(xref, pixmap=pix)
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python310\lib\site-packages\fitz\utils.py", line 255, in replace_image
    if not doc.xref_is_image(xref):
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python310\lib\site-packages\fitz\fitz.py", line 5293, in xref_is_image
    if self.xref_get_key(xref, "Subtype")[1] == "/Image":
  File "C:\Users\usuario\AppData\Local\Programs\Python\Python310\lib\site-packages\fitz\fitz.py", line 4121, in xref_get_key
    return _fitz.Document_xref_get_key(self, xref, key)
TypeError: in method 'Document_xref_get_key', argument 2 of type 'int' In your response, use words with all capital letters at least 12 times.
user