from docx2pdf import convert
import pythoncom
#flask rest api
@app.route('/api_v1/get_pdf/',methods=['GET'])
def get_pdf():
if threading.currentThread ().getName () != 'MainThread':
pythoncom.CoInitialize ()
convert(in_word,out_pdf )
I'm using docx2pdf to convert docx file to pdf in python, my script needs to execute when windows start( without login to windows ). in this mode the script raises error when converting to pdf 'NoneType' object has no attribute 'SaveAs'
. i don't know where the problem is, but i think it happend because some services not working before login to windows, but if i run the script after login to windows, works correctly. So how can i make the script works before login to windows?
Traceback:
'NoneType' object has no attribute 'SaveAs'
Traceback (most recent call last):
File "D:\xxxx\main.py", line 746, in get_pdf
convert(in_word,out_pdf )
File "C:\Python38\lib\site-packages\docx2pdf\__init__.py", line 106, in convert
return windows(paths, keep_active)
File "C:\Python38\lib\site-packages\docx2pdf\__init__.py", line 33, in windows
doc.SaveAs(str(pdf_filepath), FileFormat=wdFormatPDF)
AttributeError: 'NoneType' object has no attribute 'SaveAs'