Skip to content

Commit 89fa4ae

Browse files
committed
Integrate code to existin structure
1 parent 9ac1795 commit 89fa4ae

File tree

3 files changed

+24
-20
lines changed

3 files changed

+24
-20
lines changed

src/ReplaceInDocument.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/entities/utils.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import subprocess
2+
13
from aiogram.types import ReplyKeyboardMarkup, Update
24
from aiogram.utils.keyboard import ReplyKeyboardBuilder
35

@@ -54,3 +56,25 @@ async def log_error(message: str):
5456
logger.error(message)
5557
for admin_chat_id in ADMINS:
5658
await bot.send_message(chat_id=admin_chat_id, text=message)
59+
60+
61+
def replaceInDocument(FIO: str, dateTill: str, pdfFileName: str) -> None:
62+
with open("src/static/certificate.svg", "r", encoding="utf-8") as file:
63+
svg_content = file.read()
64+
svg_content = svg_content.replace("fioHandler", FIO)
65+
svg_content = svg_content.replace("dateHandler", dateTill)
66+
67+
temp_svg_path = "temp_certificate.svg"
68+
with open(temp_svg_path, "w", encoding="utf-8") as f:
69+
f.write(svg_content)
70+
subprocess.run(
71+
[
72+
"inkscape",
73+
temp_svg_path,
74+
"--export-type=pdf",
75+
f"--export-filename={pdfFileName}",
76+
],
77+
check=True,
78+
)
79+
80+
logger.info(f"PDF успешно создан: {pdfFileName}")
File renamed without changes.

0 commit comments

Comments
 (0)