Re: Qt issue with printing landscape-oriented images
Zdenek Dohnal <[email protected]> Wed, 26 Feb 2025 10:25:16 +0100
| Newsgroups | dev.linux.lists.printing-architecture |
|---|---|
| Message-ID | <[email protected]> |
Hi Alex,
thank you for heads-up!
To be honest I have never seen IPP attribute landscape :D - I know
there is IPP attribute 'orientation-requested' which is used for setting
whether you want portrait, landscape, etc.
Based on the code for image it looks like landscape is really a thing,
and if okular wants to do landscape this way, it should pass
landscape=true instead of false.
The older cups-filters ignores anything besides landscape=true, but the
current libcupsfilters sets "auto-rotate" if landscape=false is passed,
which looks correct to me.
Zdenek
On 2/18/25 15:18, Alexander Pevzner wrote:
> 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.
>
--
Zdenek Dohnal
Senior Software Engineer
Red Hat, BRQ-TPBC