Printing a simple pdf
-
@LT-K101 Take a look at https://doc.qt.io/qt-5/qtprintsupport-index.html
To write to PDF see: https://wiki.qt.io/Exporting_a_document_to_PDF -
@LT-K101 said in Printing a simple pdf:
@jsulm Implementing it in python is my headache.
Many, many examples of Qt code are in C++, not Python. You are going to struggle if you are not prepared to look at C++ and translate for yourself into Python. It really is not too hard, most Qt calls are pretty similar, some common sense/guesswork should allow you to translate C++ to Python from simple example code without knowing all the ins & outs of C++.
-
@jsulm This is the C++ code
QString fileName = QFileDialog::getSaveFileName((QWidget* )0, "Export PDF", QString(), "*.pdf"); if (QFileInfo(fileName).suffix().isEmpty()) { fileName.append(".pdf"); } QPrinter printer(QPrinter::PrinterResolution); printer.setOutputFormat(QPrinter::PdfFormat); printer.setPaperSize(QPrinter::A4); printer.setOutputFileName(fileName);
-
@LT-K101 said in Printing a simple pdf:
QString fileName = QFileDialog::getSaveFileName((QWidget* )0, "Export PDF", QString(), "*.pdf");
if (QFileInfo(fileName).suffix().isEmpty()) { fileName.append(".pdf"); }QPrinter printer(QPrinter::PrinterResolution);
printer.setOutputFormat(QPrinter::PdfFormat);
printer.setPaperSize(QPrinter::A4);
printer.setOutputFileName(fileName);without testing, it's not too different:
fileName = QFileDialog.getSaveFileName(0, "Export PDF", "", "*.pdf") if (QFileInfo(fileName).suffix().isEmpty()): fileName.append(".pdf") printer = QPrinter(QPrinter.PrinterResolution) printer.setOutputFormat(QPrinter.PdfFormat) printer.setPaperSize(QPrinter.A4) printer.setOutputFileName(fileName)
Better will be if you share your translation, or the part that doesn't work, otherwise we can just guess.
-
@CristianMaureira said in Printing a simple pdf:
fileName = QFileDialog.getSaveFileName(0, "Export PDF", "", "*.pdf")
The OP may need to use
None
in place of the0
here.