Action print to pdf.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2015-04-11 18:33:43 +03:00
parent e97cceb65b
commit 3c96dfddcb
5 changed files with 27 additions and 0 deletions

View File

@ -55,5 +55,6 @@
<file>icon/16x16/landscape.png</file>
<file>icon/16x16/portrait.png</file>
<file>icon/16x16/template.png</file>
<file>icon/32x32/pdf.png</file>
</qresource>
</RCC>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

View File

@ -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<int>(VApplication::PrintDPI));
Print( &printer );
}
}
//---------------------------------------------------------------------------------------------------------------------
void TableWindow::Layout()
{

View File

@ -63,6 +63,7 @@ public slots:
void PrintPreview();
void Print (QPrinter *printer);
void LayoutPrint();
void PrintToPdf();
signals:
/** @brief closed emit if window is closing. */

View File

@ -279,6 +279,10 @@
<property name="enabled">
<bool>false</bool>
</property>
<property name="icon">
<iconset resource="share/resources/icon.qrc">
<normaloff>:/icon/32x32/pdf.png</normaloff>:/icon/32x32/pdf.png</iconset>
</property>
<property name="text">
<string>Print to p&amp;df</string>
</property>