pyinstaller exe working when its –console but not when its –windowed/hidden console?

I have a function that converts my docx file to pdf file then start it. I tried using (subprocess.popen), (webbrowser.open), (subprocess.call), currently (os.startfile) none worked. It do works fine when i set my exe to –console(console based) via auto-py-to-exe, but i dont want the user to see the shell when starting the app. App just crashes

   def generate_pdf(employee_data, currentid):
   # Prepare the employee rows for the report
   employeerows = []
   for row in employee_data:
    employeerows.append({
        "name": row[0],       # Concatenated lastname and firstname
        "address": row[1],    # Address
        "mobileno": row[2]    # Mobile number
    })

# Load the DocxTemplate
doc = DocxTemplate("employeelist.docx")

conn = sqlite3.connect("brgydb.db")
cur = conn.cursor()

cur.execute("SELECT brgylogo, regionlogo, companyname, address, mobileno FROM globalsetup WHERE idno=?",(currentid,))

row = cur.fetchone()
conn.commit()

# Write binary data to a file-like object
image_stream = BytesIO(row[0])

# Open the image using PIL
image = Image.open(image_stream)

# Save the image to a file
image.save('retrieved_image.png')

# Write binary data to a file-like object
image_stream1 = BytesIO(row[1])

# Open the image using PIL
image1 = Image.open(image_stream1)

# Save the image to a file
image1.save('retrievedimage1.png')

# Open the image and resize it to the desired dimensions
image_path = "retrieved_image.png"
original_image = Image.open(image_path)
desired_width_cm, desired_height_cm = 2.21, 2.21  # Set the desired dimensions in cm

# Convert cm to inches
desired_width = Cm(desired_width_cm).inches
desired_height = Cm(desired_height_cm).inches

original_image.thumbnail((desired_width * 100, desired_height * 100))

# Create an InlineImage object with the resized image
resized_image = InlineImage(doc, image_path, width=Cm(desired_width_cm))



# Open the image and resize it to the desired dimensions
image_path1 = "retrievedimage1.png"
original_image1 = Image.open(image_path1)
  

# Convert cm to inches
desired_width = Cm(desired_width_cm).inches
desired_height = Cm(desired_height_cm).inches

original_image1.thumbnail((desired_width * 100, desired_height * 100)) 

# Create an InlineImage object with the resized image
resized_image1 = InlineImage(doc, image_path1, width=Cm(desired_width_cm))
# Define context for rendering the document
context = {
    "reportDtStr": "03-May-2024",
    "employee_data": employeerows,
    "CompanyName":row[2],
    "Address": row[3],
    "Whateveritisidontknow":row[4],
    "image1": resized_image,
    "image2": resized_image1

}

# Render the document with the provided context
doc.render(context)

# Save the rendered document
doc.save("report1.docx")

convert("report1.docx", "employeelist.pdf")

os.startfile("employeelist.pdf")

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật