From e5b105a3c6b58a200d4d5ceacafb33d96e6450cc Mon Sep 17 00:00:00 2001 From: Anton Thomasson Date: Thu, 18 Feb 2021 20:07:40 +0100 Subject: [PATCH] Actually fix total number of pages with ranges --- src/convertworker.cpp | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src/convertworker.cpp b/src/convertworker.cpp index 00cbe49..e135da3 100644 --- a/src/convertworker.cpp +++ b/src/convertworker.cpp @@ -56,13 +56,20 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo emit failed(tr("Failed to get info about PDF file")); } + if(PageRangeLow==0) + { + PageRangeLow=1; + } + if(PageRangeHigh==0) { PageRangeHigh=pages; } // Actual number of pages to print - pages = PageRangeHigh-PageRangeLow; + pages = PageRangeHigh-PageRangeLow+1; + + qDebug() << "PageRangeLow" << PageRangeLow << "PageRangeHigh" << PageRangeHigh << "pages" << pages; bool urf = false; bool ps = false; @@ -132,10 +139,9 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo { PdfToPsArgs.append("-duplex"); } - if(PageRangeLow != 0) - { - PdfToPsArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; - } + + PdfToPsArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; + PdfToPsArgs << QStringList {"-paper", ShortPaperSize, filename, "-"}; qDebug() << "pdftops args is " << PdfToPsArgs; @@ -172,10 +178,9 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo pdftocairo->setProgram("pdftocairo"); QStringList PdfToCairoArgs = {"-pdf"}; - if(PageRangeLow != 0) - { - PdfToCairoArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; - } + + PdfToCairoArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; + PdfToCairoArgs << QStringList {"-paper", ShortPaperSize, filename, "-"}; qDebug() << "pdftocairo args is " << PdfToCairoArgs; @@ -212,10 +217,9 @@ void ConvertWorker::convertPdf(QNetworkRequest request, QString filename, QTempo QProcess* pdftocairo = new QProcess(this); pdftocairo->setProgram("pdftocairo"); QStringList PdfToCairoArgs; - if(PageRangeLow != 0) - { - PdfToCairoArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; - } + + PdfToCairoArgs << QStringList {"-f", QString::number(PageRangeLow), "-l", QString::number(PageRangeHigh)}; + PdfToCairoArgs << QStringList {"-pdf", "-paper", ShortPaperSize, filename, "-"}; pdftocairo->setArguments(PdfToCairoArgs);