IppPrinter: Add check for poorly advertised PDF support
This commit is contained in:
parent
cd852a6e9f
commit
8e4d31be73
2 changed files with 23 additions and 1 deletions
|
@ -228,6 +228,22 @@ void IppPrinter::convertFailed(QString message)
|
|||
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){
|
||||
qDebug() << "printing" << filename << attrs;
|
||||
|
||||
|
@ -283,7 +299,11 @@ void IppPrinter::print(QJsonObject attrs, QString filename, bool alwaysConvert){
|
|||
|
||||
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"))
|
||||
{
|
||||
|
|
|
@ -29,6 +29,8 @@ public:
|
|||
Q_INVOKABLE bool getJobs();
|
||||
Q_INVOKABLE bool cancelJob(qint32 jobId);
|
||||
|
||||
bool hasPrinterDeviceIdCmd(QString cmd);
|
||||
|
||||
enum ConvertTarget
|
||||
{
|
||||
NoConvert,
|
||||
|
|
Loading…
Reference in a new issue