From eb58606250010a11dbbe1c5d55d9ddb551349a16 Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Sat, 1 Aug 2020 17:03:17 +0200 Subject: [PATCH] Update ppm2pwg and enable auto-portrait --- ppm2pwg | 2 +- src/convertworker.cpp | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/ppm2pwg b/ppm2pwg index 3ee6a0f..46acfbf 160000 --- a/ppm2pwg +++ b/ppm2pwg @@ -1 +1 @@ -Subproject commit 3ee6a0fef46cf7a3768b52a77687f69dac965798 +Subproject commit 46acfbf52a2267da8f944f08d70369533d1feba0 diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 0ff34f9..69d8e5e 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -6,7 +6,8 @@ #include void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, - quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble, quint32 pages) + quint32 HwResX, quint32 HwResY, bool TwoSided, bool Tumble, + bool ForcePortrait, quint32 pages) { env.append("HWRES_X="+QString::number(HwResX)); env.append("HWRES_Y="+QString::number(HwResY)); @@ -28,6 +29,12 @@ void ppm2PwgEnv(QStringList& env, bool urf, quint32 Quality, QString PaperSize, env.append("DUPLEX="+QString::number(TwoSided)); env.append("TUMBLE="+QString::number(Tumble)); + + if(ForcePortrait) + { + env.append("FORCE_PORTRAIT=true"); + } + if(pages != 0) { env.append("PAGES="+QString::number(pages)); @@ -181,7 +188,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, pages); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, TwoSided, Tumble, true, pages); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env); @@ -227,7 +234,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo bool ppm2pwgSuccess = false; - for(size_t i = 0; i < (5*pages+10); i++) + for(size_t i = 0; i < (10*pages+10); i++) { if(ppm2pwg->waitForFinished(1000)) { @@ -242,7 +249,7 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo if(it->startsWith("Page")) { QList ppm2pwgTokens = it->split(' '); - emit progress(ppm2pwgTokens.last().toInt(), pages); + emit progress(ppm2pwgTokens.last().toInt()-1, pages); } } } @@ -352,7 +359,7 @@ void ConvertWorker::convertImage(QNetworkRequest request, QString filename, QTem ppm2pwg->setArguments({"ppm2pwg"}); QStringList env; - ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, 0); + ppm2PwgEnv(env, urf, Quality, PaperSize, HwResX, HwResY, false, false, false, 0); qDebug() << "ppm2pwg env is " << env; ppm2pwg->setEnvironment(env);