fralx / LimeReport

Report generator for Qt Framework
http://limereport.ru/
Other
403 stars 154 forks source link

Cloud you change to QPdfWriter class for saving to PDF file #372

Closed liufeijin closed 2 years ago

liufeijin commented 2 years ago

Hi fralx When i use LimeReport get a pdf file with 190 pages , the file size is 9M. it is to big. The PDF default is 1200 dpi. I inserted a code in "lrpdfexporter.cpp" as below bool PDFExporter::exportPages(ReportPages pages, const QString &fileName, const QMap<QString, QVariant> &params) { Q_UNUSED(params); if (!fileName.isEmpty()){ QPrinter printer; printer.setOutputFileName(fileName); printer.setOutputFormat(QPrinter::PdfFormat); printer.setResolution(150); // added row if (!pages.isEmpty()){ m_reportEngine->printPages(pages, &printer); } m_reportEngine->emitPrintedToPDF(fileName); return true; } return false; } } Update 2 printer.setResolution(150); seems it is not at here to change dpi for pdf file.

i use Q_UNUSED(params); if (!fileName.isEmpty()){ QPrinter printer; printer.setOutputFileName(fileName); printer.setOutputFormat(QPrinter::PdfFormat); qDebug()<<printer.resolution()<<"first call before"; printer.setResolution(150); qDebug()<<printer.resolution()<<"first call after"; if (!pages.isEmpty()){ m_reportEngine->printPages(pages, &printer); } m_reportEngine->emitPrintedToPDF(fileName); return true; } return false;

get out 192 first call before (first print pdf size is 8m) 150 first call after

if set to 75 is same also.

don't know where is effect location.

Cloud you have a look? BTW, Cloud you add a parameter for printToPDF like as " Report->printToPDF( QString fileName, int dpi );"?