2018-06-23 00:04:28 +03:00
|
|
|
#include "lrpdfexporter.h"
|
2024-09-04 17:31:16 +03:00
|
|
|
|
2018-06-23 00:04:28 +03:00
|
|
|
#include "lrexportersfactory.h"
|
|
|
|
#include "lrreportengine_p.h"
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
#include <QPrinter>
|
|
|
|
|
|
|
|
namespace {
|
2018-06-23 00:04:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
LimeReport::ReportExporterInterface* createPDFExporter(LimeReport::ReportEnginePrivate* parent)
|
|
|
|
{
|
2018-06-23 00:04:28 +03:00
|
|
|
return new LimeReport::PDFExporter(parent);
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
bool VARIABLE_IS_NOT_USED registred = LimeReport::ExportersFactory::instance().registerCreator(
|
|
|
|
"PDF", LimeReport::ExporterAttribs(QObject::tr("Export to PDF"), "PDFExporter"),
|
|
|
|
createPDFExporter);
|
2018-06-23 00:04:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
} // namespace
|
2018-06-23 00:04:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
namespace LimeReport {
|
2018-06-23 00:04:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
PDFExporter::PDFExporter(ReportEnginePrivate* parent): QObject(parent), m_reportEngine(parent) { }
|
2018-06-23 00:04:28 +03:00
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
bool PDFExporter::exportPages(ReportPages pages, const QString& fileName,
|
|
|
|
const QMap<QString, QVariant>& params)
|
2018-06-23 00:04:28 +03:00
|
|
|
{
|
|
|
|
Q_UNUSED(params);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!fileName.isEmpty()) {
|
2018-06-23 00:04:28 +03:00
|
|
|
QPrinter printer;
|
|
|
|
printer.setOutputFileName(fileName);
|
|
|
|
printer.setOutputFormat(QPrinter::PdfFormat);
|
2024-09-04 17:31:16 +03:00
|
|
|
if (!pages.isEmpty()) {
|
2019-10-12 22:31:35 +03:00
|
|
|
m_reportEngine->printPages(pages, &printer);
|
2018-06-23 00:04:28 +03:00
|
|
|
}
|
|
|
|
m_reportEngine->emitPrintedToPDF(fileName);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2024-09-04 17:31:16 +03:00
|
|
|
} // namespace LimeReport
|