Qt issue with printing landscape-oriented images
Alexander Pevzner <[email protected]> Tue, 18 Feb 2025 17:18:49 +0300
| Newsgroups | dev.linux.lists.printing-architecture |
|---|---|
| Message-ID | <[email protected]> |
Hi!
This information may be interesting for printing stack maintainers of
various Linus distros (Zdenek?).
I've already posted it into the OpenPrinting Telegram group, but as not
everybody subscribed to the group, I repost it here, by Till's advise.
We've recently noticed, that the Okular (Qt-based image viewer)
incorrectly prints images in the landscape orientation.
When printing image (see attached test.png) it sends the following
Create-Job request, followed by the image, converted to PDF (see
attached 00000020-data.pdf:
-----
IPP: request message:
{
VERSION 2.0
OPERATION Create-Job
GROUP operation-attributes-tag
ATTR "attributes-charset" charset: utf-8
ATTR "attributes-natural-language" naturalLanguage: en-us
ATTR "printer-uri" uri: ipp://localhost/printers/Kyocera_ECOSYS_M2040dn
ATTR "requesting-user-name" nameWithoutLanguage: pzz
ATTR "job-name" nameWithoutLanguage: bug.png
GROUP job-attributes-tag
ATTR "media" keyword: A4
ATTR "sides" keyword: one-sided
ATTR "landscape" boolean: false
ATTR "number-up" integer: 1
ATTR "number-up-layout" keyword: lrtb
ATTR "job-billing" nameWithoutLanguage:
ATTR "job-priority" integer: 50
ATTR "job-sheets" nameWithoutLanguage: none none
}
-----
It can be reduced down to the very simple Qt example:
-----
#include <iostream>
#include <QApplication>
#include <QPrinter>
#include <QPrintDialog>
#include <QImage>
#include <QPainter>
int main(int argc, char* argv[])
{
QApplication app(argc, argv);
QPrinter printer;
printer.setPageOrientation(QPageLayout::Landscape);
QImage img("./test.png");
img = img.scaled(printer.width(), printer.height(),
Qt::KeepAspectRatio, Qt:
QPainter painter(&printer);
painter.drawImage(0, 0, img, 0, 0);
painter.end();
return 0;
}
-----
The problem is obviously in the ATTR "landscape" boolean: false
attribute. This is definitely at the Qt side. Seems like all existing
versions of Qt are affected.
We have submitted PR agains qt-base, it is pretty trivial and currently
on review:
https://codereview.qt-project.org/c/qt/qtbase/+/624835
I believe, all more or less modern Linux distros are affected and wonder
why nobody complained before
Note, the problem doesn't exist with old versions of the cups-filters (I
was able to test with very old version1.28)
Looks like the landscape attribute attribute is silently ignoring by
these old versions, and without this explicit orientation setting,
filters set correct orientation automatically.
--
Wishes, Alexander Pevzner ([email protected])
test.png
(image/png, 140.8 KB) - not displayed
00000020-data.pdf
(application/pdf, 31.2 KB) - not displayed