diff --git a/src/app/share/resources/icon.qrc b/src/app/share/resources/icon.qrc index 329cd555f..439657321 100644 --- a/src/app/share/resources/icon.qrc +++ b/src/app/share/resources/icon.qrc @@ -55,5 +55,6 @@ icon/16x16/landscape.png icon/16x16/portrait.png icon/16x16/template.png + icon/32x32/pdf.png diff --git a/src/app/share/resources/icon/32x32/pdf.png b/src/app/share/resources/icon/32x32/pdf.png new file mode 100644 index 000000000..0c65ce2ff Binary files /dev/null and b/src/app/share/resources/icon/32x32/pdf.png differ diff --git a/src/app/tablewindow.cpp b/src/app/tablewindow.cpp index f6471f3a6..091397397 100644 --- a/src/app/tablewindow.cpp +++ b/src/app/tablewindow.cpp @@ -83,6 +83,7 @@ TableWindow::TableWindow(QWidget *parent) connect(ui->listWidget, &QListWidget::currentRowChanged, this, &TableWindow::ShowPaper); connect(ui->actionPrint_pre_view, &QAction::triggered, this, &TableWindow::PrintPreview); connect(ui->action_Print, &QAction::triggered, this, &TableWindow::LayoutPrint); + connect(ui->actionSave_to_p_df, &QAction::triggered, this, &TableWindow::PrintToPdf); } //--------------------------------------------------------------------------------------------------------------------- @@ -341,6 +342,26 @@ void TableWindow::LayoutPrint() } } +//--------------------------------------------------------------------------------------------------------------------- +void TableWindow::PrintToPdf() +{ + // display print dialog and if accepted print + QPrinter printer; + printer.setCreator(qApp->applicationDisplayName()+" "+qApp->applicationVersion()); + printer.setDocName(fileName); + printer.setOutputFormat(QPrinter::PdfFormat); + + const QString fileName = QFileDialog::getSaveFileName(this, tr("Print to pdf"), + QDir::homePath()+"/"+this->fileName+".pdf", + tr("PDF file (*.pdf)")); + if (fileName.isEmpty()) + { + printer.setOutputFileName(fileName); + printer.setResolution(static_cast(VApplication::PrintDPI)); + Print( &printer ); + } +} + //--------------------------------------------------------------------------------------------------------------------- void TableWindow::Layout() { diff --git a/src/app/tablewindow.h b/src/app/tablewindow.h index f7221a94f..c988a6f77 100644 --- a/src/app/tablewindow.h +++ b/src/app/tablewindow.h @@ -63,6 +63,7 @@ public slots: void PrintPreview(); void Print (QPrinter *printer); void LayoutPrint(); + void PrintToPdf(); signals: /** @brief closed emit if window is closing. */ diff --git a/src/app/tablewindow.ui b/src/app/tablewindow.ui index d34e4f652..c3c213e30 100644 --- a/src/app/tablewindow.ui +++ b/src/app/tablewindow.ui @@ -279,6 +279,10 @@ false + + + :/icon/32x32/pdf.png:/icon/32x32/pdf.png + Print to p&df