Seite 1 von 1

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

Verfasst: Donnerstag 12. Mai 2022, 14:22
von mureed.niazie
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()

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

Verfasst: Donnerstag 12. Mai 2022, 14:24
von mureed.niazie
Hallo everyone. i wanna add a .png file in the created word document, i need your Suggestion please.

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

Verfasst: Donnerstag 12. Mai 2022, 14:43
von Dennis89