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
|
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);
|
QProcess* pdftoppm = new QProcess(this);
|
||||||
pdftoppm->setProgram("pdftoppm");
|
pdftoppm->setProgram("pdftoppm");
|
||||||
QStringList Pdf2PpmArgs = {"-rx", QString::number(HwResX), "-ry", QString::number(HwResY)};
|
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)};
|
Pdf2PpmArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)};
|
||||||
|
}
|
||||||
|
|
||||||
if(Colors == 1)
|
if(Colors == 1)
|
||||||
{
|
{
|
||||||
|
@ -682,18 +710,4 @@ try {
|
||||||
qDebug() << "ppm2pwg failed";
|
qDebug() << "ppm2pwg failed";
|
||||||
throw ConvertFailedException();
|
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 done(QNetworkRequest request, QTemporaryFile* data);
|
||||||
void progress(qint64 done, qint64 pages);
|
void progress(qint64 done, qint64 pages);
|
||||||
void failed(QString message);
|
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
|
#endif // CONVERTWORKER_H
|
||||||
|
|
Loading…
Reference in a new issue