Break out ConvertWorker::pdfToRaster
This commit is contained in:
parent
07a1e35f58
commit
8c18418f26
2 changed files with 99 additions and 79 deletions
|
@ -603,10 +603,38 @@ try {
|
|||
else
|
||||
{
|
||||
|
||||
pdfToRaster(targetFormat, Colors, Quality, PaperSize,
|
||||
HwResX, HwResY, TwoSided, Tumble,
|
||||
PageRangeLow, PageRangeHigh, pages,
|
||||
tmpPdfFile, tempfile);
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Finished";
|
||||
|
||||
emit done(request, tempfile);
|
||||
qDebug() << "posted";
|
||||
|
||||
}
|
||||
catch(const ConvertFailedException& e)
|
||||
{
|
||||
tempfile->deleteLater();
|
||||
emit failed(e.what() == QString("") ? tr("Conversion error") : e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ConvertWorker::pdfToRaster(QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
quint32 PageRangeLow, quint32 PageRangeHigh, quint32 pages,
|
||||
QTemporaryFile& tmpPdfFile, QTemporaryFile* tempfile)
|
||||
{
|
||||
QProcess* pdftoppm = new QProcess(this);
|
||||
pdftoppm->setProgram("pdftoppm");
|
||||
QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)};
|
||||
if (PageRangeLow != 0 && PageRangeHigh !=0)
|
||||
{
|
||||
Pdf2PpmArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)};
|
||||
}
|
||||
|
||||
if(Colors == 1)
|
||||
{
|
||||
|
@ -683,17 +711,3 @@ try {
|
|||
throw ConvertFailedException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
qDebug() << "Finished";
|
||||
|
||||
emit done(request, tempfile);
|
||||
qDebug() << "posted";
|
||||
|
||||
}
|
||||
catch(const ConvertFailedException& e)
|
||||
{
|
||||
tempfile->deleteLater();
|
||||
emit failed(e.what() == QString("") ? tr("Conversion error") : e.what());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,6 +40,12 @@ signals:
|
|||
void done(QNetworkRequest request, QTemporaryFile* data);
|
||||
void progress(qint64 done, qint64 pages);
|
||||
void failed(QString message);
|
||||
|
||||
private:
|
||||
void pdfToRaster(QString targetFormat, quint32 Colors, quint32 Quality, QString PaperSize,
|
||||
quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble,
|
||||
quint32 PageRangeLow, quint32 PageRangeHigh, quint32 pages,
|
||||
QTemporaryFile& tmpPdfFile, QTemporaryFile* tempfile);
|
||||
};
|
||||
|
||||
#endif // CONVERTWORKER_H
|
||||
|
|
Loading…
Reference in a new issue