* Qt issue with printing landscape-oriented images
@ 2025-02-18 14:18 Alexander Pevzner
2025-02-26 9:25 ` Zdenek Dohnal
0 siblings, 1 reply; 4+ messages in thread
From: Alexander Pevzner @ 2025-02-18 14:18 UTC (permalink / raw)
To: Open Printing
[-- Attachment #1: Type: text/plain, Size: 2637 bytes --]
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 (pzz@apevzner.com)
[-- Attachment #2: test.png --]
[-- Type: image/png, Size: 144186 bytes --]
[-- Attachment #3: 00000020-data.pdf --]
[-- Type: application/pdf, Size: 31915 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Qt issue with printing landscape-oriented images
2025-02-18 14:18 Qt issue with printing landscape-oriented images Alexander Pevzner
@ 2025-02-26 9:25 ` Zdenek Dohnal
2025-02-26 12:24 ` Johannes Meixner
2025-02-28 21:40 ` Alexander Pevzner
0 siblings, 2 replies; 4+ messages in thread
From: Zdenek Dohnal @ 2025-02-26 9:25 UTC (permalink / raw)
To: Alexander Pevzner, Open Printing
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
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Qt issue with printing landscape-oriented images
2025-02-26 9:25 ` Zdenek Dohnal
@ 2025-02-26 12:24 ` Johannes Meixner
2025-02-28 21:40 ` Alexander Pevzner
1 sibling, 0 replies; 4+ messages in thread
From: Johannes Meixner @ 2025-02-26 12:24 UTC (permalink / raw)
To: Open Printing
Hello,
I didn't check any details here
so only a side note for the fun of it:
There is no such thing as "landscape printing".
Cf.
https://en.opensuse.org/SDB:Landscape_Printing
On 2025-02-26 10:25, Zdenek Dohnal wrote:
> 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.
>>
Kind Regards
Johannes Meixner
--
SUSE Software Solutions Germany GmbH
Frankenstr. 146 - 90461 Nuernberg - Germany
(HRB 36809, AG Nuernberg) GF: Ivo Totev
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Qt issue with printing landscape-oriented images
2025-02-26 9:25 ` Zdenek Dohnal
2025-02-26 12:24 ` Johannes Meixner
@ 2025-02-28 21:40 ` Alexander Pevzner
1 sibling, 0 replies; 4+ messages in thread
From: Alexander Pevzner @ 2025-02-28 21:40 UTC (permalink / raw)
To: Zdenek Dohnal, Open Printing
Hi Zdenek,
On 2/26/25 12:25 PM, Zdenek Dohnal wrote:
> 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.
Honestly, me too.
I has discussed this issue with Till in the OpenPrinting Telegram group.
He told that best of all for Qt is to use the IPP-standard
orientation-requested attribute instead of the CUPS-specific landscape
attribute, but as Qt moves to CPDB, it is good enough just to use the
landscape attribute correctly, as a temporary solution.
Seems tha Qt people have accepted out simple patch into master and plan
to backport to older releases.
> 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.
Yes, exactly. Actually, all current Qt programs are affected, not only
okular.
--
Wishes, Alexander Pevzner (pzz@apevzner.com)
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-02-28 22:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18 14:18 Qt issue with printing landscape-oriented images Alexander Pevzner
2025-02-26 9:25 ` Zdenek Dohnal
2025-02-26 12:24 ` Johannes Meixner
2025-02-28 21:40 ` Alexander Pevzner
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.