|
@@ -2,8 +2,7 @@ from PySide6.QtWidgets import QDialog
|
|
|
from PySide6.QtPrintSupport import QPrintDialog, QPrinter
|
|
|
from PySide6.QtGui import QPainter, QPixmap, QPageSize
|
|
|
from PySide6.QtCore import Qt
|
|
|
-import pdfkit
|
|
|
-from module import create_filename
|
|
|
+from module.wkhtmltopdf import create_pdf
|
|
|
from pdf2image import convert_from_path
|
|
|
|
|
|
|
|
@@ -14,10 +13,9 @@ class Print:
|
|
|
self.printer.setFullPage(True)
|
|
|
self.printer.setPageSize(QPageSize.A4)
|
|
|
|
|
|
- pdf = CreatorPDF(text)
|
|
|
+ pdf = create_pdf(text)
|
|
|
image = convert_from_path(pdf.get_path_to_pdf())[0].toqimage()
|
|
|
image = QPixmap.fromImage(image)
|
|
|
- # print(self.printer.pageRect())
|
|
|
image = image.scaledToWidth(self.printer.width(), Qt.SmoothTransformation)
|
|
|
|
|
|
dialog = QPrintDialog(self.printer)
|
|
@@ -30,19 +28,4 @@ class Print:
|
|
|
|
|
|
painter.drawPixmap(0, 0, im)
|
|
|
painter.end()
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-class CreatorPDF():
|
|
|
- def __init__(self, text_html):
|
|
|
- self.__file_name = create_filename('pdf')
|
|
|
- # self.__file_name = 'pdf.pdf'
|
|
|
- configuration = pdfkit.configuration(
|
|
|
- wkhtmltopdf="/usr/bin/wkhtmltopdf")
|
|
|
- pdfkit.from_string(text_html, self.__file_name, configuration=configuration, css=None, options={
|
|
|
- "enable-local-file-access": ""
|
|
|
- })
|
|
|
-
|
|
|
- def get_path_to_pdf(self) -> str:
|
|
|
- return self.__file_name
|
|
|
-
|
|
|
+
|