Get dpi for pdf conversion from settings or defaults
This commit is contained in:
parent
4519f0a13e
commit
a586dcca1a
4 changed files with 23 additions and 8 deletions
|
@ -2,27 +2,28 @@
|
|||
#include <sailfishapp.h>
|
||||
|
||||
void ConvertWorker::convertPdf(QNetworkRequest request, QString filename,
|
||||
bool apple, QTemporaryFile* tempfile)
|
||||
bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile)
|
||||
{
|
||||
|
||||
QString HwResX_s = QString::number(HwResX);
|
||||
QString HwResY_s = QString::number(HwResY);
|
||||
|
||||
QProcess* pdftoppm = new QProcess(this);
|
||||
pdftoppm->setProgram("pdftoppm");
|
||||
pdftoppm->setArguments({"-gray", "-rx", "300", "-ry", "300", filename});
|
||||
pdftoppm->setArguments({"-gray", "-rx", HwResX_s, "-ry", HwResY_s, filename});
|
||||
|
||||
|
||||
QProcess* ppm2pwg = new QProcess(this);
|
||||
// Yo dwag, I heard you like programs...
|
||||
ppm2pwg->setProgram("harbour-seaprint");
|
||||
ppm2pwg->setArguments({"ppm2pwg"});
|
||||
QStringList env; // {"PREPEND_FILE="+tempfile->fileName()};
|
||||
QStringList env = {"HWRES_X="+HwResX_s, "HWRES_Y="+HwResY_s};
|
||||
|
||||
if(apple)
|
||||
{
|
||||
env.append("URF=true");
|
||||
}
|
||||
|
||||
qDebug() << "Prepend file env done";
|
||||
|
||||
ppm2pwg->setEnvironment(env);
|
||||
|
||||
pdftoppm->setStandardOutputProcess(ppm2pwg);
|
||||
|
|
|
@ -9,7 +9,7 @@ class ConvertWorker : public QObject
|
|||
|
||||
public slots:
|
||||
void convertPdf(QNetworkRequest request, QString filename,
|
||||
bool apple, QTemporaryFile* tempfile);
|
||||
bool apple, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile);
|
||||
//convertImage();
|
||||
|
||||
signals:
|
||||
|
|
|
@ -291,6 +291,20 @@ void IppPrinter::print(QJsonObject attrs, QString filename){
|
|||
}
|
||||
}
|
||||
|
||||
quint32 HwResX = 300;
|
||||
quint32 HwResY = 300;
|
||||
|
||||
if(attrs.contains("printer-resolution")) {
|
||||
// TODO: check that units == 3, aka dpi
|
||||
HwResX = attrs["printer-resolution"].toObject()["value"].toObject()["x"].toInt();
|
||||
HwResY = attrs["printer-resolution"].toObject()["value"].toObject()["y"].toInt();
|
||||
}
|
||||
else
|
||||
{
|
||||
HwResX = _attrs["printer-resolution-default"].toObject()["value"].toObject()["x"].toInt();
|
||||
HwResY = _attrs["printer-resolution-default"].toObject()["value"].toObject()["y"].toInt();
|
||||
}
|
||||
|
||||
if(from == Pdf && target != NoConvert)
|
||||
{
|
||||
file.close();
|
||||
|
@ -300,7 +314,7 @@ void IppPrinter::print(QJsonObject attrs, QString filename){
|
|||
qDebug() << tempfile->fileName();
|
||||
tempfile->close();
|
||||
|
||||
emit doConvertPdf(request, filename, target==UrfConvert, tempfile);
|
||||
emit doConvertPdf(request, filename, target==UrfConvert, HwResX, HwResY, tempfile);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ signals:
|
|||
void jobFinished(bool status);
|
||||
void cancelStatus(bool status);
|
||||
|
||||
void doConvertPdf(QNetworkRequest request, QString filename, bool urf, QTemporaryFile* tempfile);
|
||||
void doConvertPdf(QNetworkRequest request, QString filename, bool urf, quint32 HwResX, quint32 HwResY, QTemporaryFile* tempfile);
|
||||
|
||||
public slots:
|
||||
void print(QJsonObject attrs, QString file);
|
||||
|
|
Loading…
Reference in a new issue