Das Objekt "Nichtetypen" hat kein Attribut "Saveas" docx2pdf unter WindowsPython

Python-Programme
Anonymous
 Das Objekt "Nichtetypen" hat kein Attribut "Saveas" docx2pdf unter Windows

Post by Anonymous »

Code: Select all

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 )
< /code>
Ich verwende docx2pdf, um die docx -Datei in Python in PDF zu [url=viewtopic.php?t=12659]konvertieren.[/url] Mein Skript muss ausgeführt werden, wenn Windows startet (ohne Anmeldung bei Windows). In diesem Modus erhöht das Skript den Fehler beim Konvertieren in PDF 'Nonetype' Objekt hat kein Attribut 'Saveas' 
. Ich weiß nicht, wo sich das Problem befindet, aber ich denke, es ist passiert, weil einige Dienste vor dem Anmelden bei Windows nicht funktionieren. Wenn ich das Skript nach der Anmeldung bei Windows ausführe, funktioniert es richtig. Wie kann ich das Skript vorstellen, bevor ich mich bei Windows anmelde?

Code: Select all

'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'

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post