How to add (.PNG) file in (.docx) file

Wenn du dir nicht sicher bist, in welchem der anderen Foren du die Frage stellen sollst, dann bist du hier im Forum für allgemeine Fragen sicher richtig.
Antworten
mureed.niazie
User
Beiträge: 18
Registriert: Dienstag 22. März 2022, 14:40

from pathlib import Path
from docxtpl import DocxTemplate
import datetime
import PySimpleGUI as sg

document_path = Path(__file__).parent / "Simple_file_path.docx"
doc = DocxTemplate(document_path)
today = datetime.datetime.today()
layout = [[sg.Text("Assembly"), sg.Input(key="ASSEMBLY")],
[sg.Text("ArtikelNr"), sg.Input(key="ARTIKELNR")],
[sg.Text("Customer"), sg.Input(key="CUSTOMER")],
[sg.Text("Reference"), sg.Input(key="REFERENCE")],
[sg.Text("OrderNr"), sg.Input(key="ORDERNR")],
[sg.Text("elspec serial no."), sg.Input(key="ELSPECSERIALNR")],
[sg.Text("umgebungsTemp"), sg.Input(key="UMGEBUNGSTMP")],
[sg.Text("validator name"), sg.Input(key="VALIDATORNAME")],
[sg.Button("Vorlage erstellen"), sg.Exit()], ]

window = sg.Window("Druck Vorlage ", layout, element_justification="right")

while True:
event, values = window.read()
if event == sg.WIN_CLOSED or event == "Exit":
break
if event == "Vorlage erstellen":
values["TODAY"] = today.strftime("%d.%m-%Y")
doc.render(values)
doc.save(Path(__file__).parent / "generated_wordTemp.docx")

window.close()
mureed.niazie
User
Beiträge: 18
Registriert: Dienstag 22. März 2022, 14:40

Hallo everyone. i wanna add a .png file in the created word document, i need your Suggestion please.
Benutzeravatar
Dennis89
User
Beiträge: 1123
Registriert: Freitag 11. Dezember 2020, 15:13

"When I got the music, I got a place to go" [Rancid, 1993]
Antworten