7 Module implementing a dialog to enter the data for printing a web page to PDF. |
7 Module implementing a dialog to enter the data for printing a web page to PDF. |
8 """ |
8 """ |
9 |
9 |
10 from __future__ import unicode_literals |
10 from __future__ import unicode_literals |
11 |
11 |
12 from PyQt5.QtCore import pyqtSlot, QMarginsF |
12 import os |
|
13 |
|
14 from PyQt5.QtCore import pyqtSlot, QMarginsF, QStandardPaths |
13 from PyQt5.QtGui import QPageLayout, QPageSize |
15 from PyQt5.QtGui import QPageLayout, QPageSize |
14 from PyQt5.QtPrintSupport import QPrinter, QPageSetupDialog |
16 from PyQt5.QtPrintSupport import QPrinter, QPageSetupDialog |
15 from PyQt5.QtWidgets import QDialog |
17 from PyQt5.QtWidgets import QDialog |
16 |
18 |
17 from E5Gui.E5PathPicker import E5PathPickerModes |
19 from E5Gui.E5PathPicker import E5PathPickerModes |
38 |
40 |
39 self.pdfFilePicker.setMode(E5PathPickerModes.SaveFileOverwriteMode) |
41 self.pdfFilePicker.setMode(E5PathPickerModes.SaveFileOverwriteMode) |
40 self.pdfFilePicker.setFilters(self.tr( |
42 self.pdfFilePicker.setFilters(self.tr( |
41 "PDF Files (*.pdf);;" |
43 "PDF Files (*.pdf);;" |
42 "All Files (*)")) |
44 "All Files (*)")) |
|
45 if not os.path.isabs(filePath): |
|
46 documentsPath = QStandardPaths.writableLocation( |
|
47 QStandardPaths.DocumentsLocation) |
|
48 if documentsPath: |
|
49 filePath = os.path.join(documentsPath, filePath) |
|
50 else: |
|
51 filePath = os.path.abspath(filePath) |
43 self.pdfFilePicker.setText(filePath, toNative=True) |
52 self.pdfFilePicker.setText(filePath, toNative=True) |
44 |
53 |
45 self.__currentPageLayout = QPageLayout( |
54 self.__currentPageLayout = QPageLayout( |
46 QPageSize(QPageSize.A4), QPageLayout.Portrait, |
55 QPageSize(QPageSize.A4), QPageLayout.Portrait, |
47 QMarginsF(0.0, 0.0, 0.0, 0.0)) |
56 QMarginsF(0.0, 0.0, 0.0, 0.0)) |