IppPrinter: Add check for poorly advertised PDF support

This commit is contained in:
Anton Thomasson 2020-06-01 20:47:27 +02:00
parent cd852a6e9f
commit 8e4d31be73
2 changed files with 23 additions and 1 deletions

View file

@ -228,6 +228,22 @@ void IppPrinter::convertFailed(QString message)
emit jobFinished(false); emit jobFinished(false);
} }
bool IppPrinter::hasPrinterDeviceIdCmd(QString cmd)
{
QStringList printerDeviceId = _attrs["printer-device-id"].toObject()["value"].toString().split(";");
for (QStringList::iterator it = printerDeviceId.begin(); it != printerDeviceId.end(); it++)
{
QStringList kv = it->split(":");
if(kv.length()==2 && kv[0]=="CMD")
{
return kv[1].split(",").contains("PDF");
}
}
return false;
}
void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){
qDebug() << "printing" << filename << attrs; qDebug() << "printing" << filename << attrs;
@ -283,7 +299,11 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){
qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType); qDebug() << supportedMimeTypes << supportedMimeTypes.contains(mimeType);
if(alwaysConvert || from == Image || (from == Pdf && !supportedMimeTypes.contains("application/pdf"))) bool supportsPdf = supportedMimeTypes.contains("application/pdf") || hasPrinterDeviceIdCmd("PDF");
qDebug() << "supportsPdf" << supportsPdf;
if(alwaysConvert || from == Image || (from == Pdf && !supportsPdf))
{ {
if(supportedMimeTypes.contains("image/pwg-raster")) if(supportedMimeTypes.contains("image/pwg-raster"))
{ {

View file

@ -29,6 +29,8 @@ public:
Q_INVOKABLE bool getJobs(); Q_INVOKABLE bool getJobs();
Q_INVOKABLE bool cancelJob(qint32 jobId); Q_INVOKABLE bool cancelJob(qint32 jobId);
bool hasPrinterDeviceIdCmd(QString cmd);
enum ConvertTarget enum ConvertTarget
{ {
NoConvert, NoConvert,