简体   繁体   中英

Python pdf2image: hide consoles

I'm using pdf2image which uses poppler to convert PDF to images. However, when you use it in Python it opens a new console every time to convert a PDF. Is there a way to hide this console?

for file_name in os.listdir(path):
  if file_name.endswith('.pdf'):
    pages = convert_from_path(path + file_name, thread_count=4)
    idx = 1
    for page in pages:
      page.save(file_name + '-page-' + str(idx) + '.jpg', 'JPEG')
      idx += 1

I'm using pdf2image which uses poppler to convert PDF to images. However, when you use it in Python it opens a new console every time to convert a PDF. Is there a way to hide this console?

for file_name in os.listdir(path):
  if file_name.endswith('.pdf'):
    pages = convert_from_path(path + file_name, thread_count=4)
    idx = 1
    for page in pages:
      page.save(file_name + '-page-' + str(idx) + '.jpg', 'JPEG')
      idx += 1

I'm using pdf2image which uses poppler to convert PDF to images. However, when you use it in Python it opens a new console every time to convert a PDF. Is there a way to hide this console?

for file_name in os.listdir(path):
  if file_name.endswith('.pdf'):
    pages = convert_from_path(path + file_name, thread_count=4)
    idx = 1
    for page in pages:
      page.save(file_name + '-page-' + str(idx) + '.jpg', 'JPEG')
      idx += 1

currently the code comes by default:

# Spawn the process and save its uuid
    startupinfo=None
    if platform.system() == 'Windows':
        # this startupinfo structure prevents a console window from popping up on Windows
        startupinfo = subprocess.STARTUPINFO()
        startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW
    processes.append(
        (thread_output_file, Popen(args, env=env, stdout=PIPE, stderr=PIPE, startupinfo=startupinfo))
    )

I've tried many things and the console keeps popping up

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM