alex_bn_lee

导航

[1039] In python, open a PDF file and maximize it

The implementation is as follows:

import win32gui, win32con, os, time


# Pdf report file path
file_path = os.path.join(pdf_folder, pdf_name) 

# Open and maximize the PDF file
os.startfile(file_path)
# Wait as long as needed for the file to open, this value can be adjusted as needed
time.sleep(2)
# Now maximize the current foreground window (should be the one we care about at this point)
hwnd = win32gui.GetForegroundWindow()
win32gui.ShowWindow(hwnd, win32con.SW_MAXIMIZE)
time.sleep(0.5)

 

posted on 2024-07-22 13:07  McDelfino  阅读(2)  评论(0编辑  收藏  举报