Bug 266739 - okular ignores the printer settings
Summary: okular ignores the printer settings
Status: RESOLVED WORKSFORME
Alias: None
Product: okular
Classification: Applications
Component: PDF backend (show other bugs)
Version: 0.10.4
Platform: openSUSE Linux
: NOR wishlist
Target Milestone: ---
Assignee: Okular developers
URL:
Keywords: triaged
Depends on:
Blocks:
 
Reported: 2011-02-20 17:23 UTC by Wolfgang Schmidt
Modified: 2018-10-29 02:04 UTC (History)
4 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
patch, removes only one line (790 bytes, patch)
2014-11-28 11:40 UTC, t_d_l_c
Details
patch for okular 0.21.60 (500 bytes, patch)
2014-12-01 16:15 UTC, t_d_l_c
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Wolfgang Schmidt 2011-02-20 17:23:41 UTC
Version:           0.10.4
OS:                Linux

when printing a pdf-document, which is shown on the screen in lanscape format, the information in the printer dialog shows selection of portrait, but the printed page is in landscape.
When i choose landscape in the printer dialog, the printed page is in portrait.


Reproducible: Always




OS: Linux (i686) release 2.6.34.8-13-desktop
Compiler: gcc
Comment 1 t_d_l_c 2014-11-28 11:28:38 UTC
I can confirm this bug for our build of okular (I work for the city of munich). We have Okular 0.18.2 and KDE 4.12.2 on our Ubuntu12LTS - based OS.

I have only one pdf with which I can reproduce the bug. I think the diffence to other pdfs is that in the pdf source code there is a rotation defined - Rotate 90:
4 0 obj
<</Type/Page/MediaBox [0 0 595 842]
/Rotate 90/Parent 3 0 R
/Resources<</ProcSet[/PDF /ImageC /ImageI /Text]
/ColorSpace 25 0 R
/ExtGState 26 0 R
/XObject 27 0 R
/Font 28 0 R
>>
/Contents 5 0 R
>>
endobj

I will add an proposed patch soon.
Comment 2 t_d_l_c 2014-11-28 11:40:43 UTC
Created attachment 89753 [details]
patch, removes only one line
Comment 3 t_d_l_c 2014-11-28 11:47:41 UTC
The problem is in QPrinter::Orientation Document::orientation() const in document.cpp. It swaps width and height when there is a rotation of 90/270 defined, but width and height are already swapped in Okular::Page. 

I've commented out the line which is causing the problem:

QPrinter::Orientation Document::orientation() const
{
    double width, height;
    int landscape, portrait;
    const Okular::Page *currentPage;

    // if some pages are landscape and others are not, the most common wins, as
    // QPrinter does not accept a per-page setting
    landscape = 0;
    portrait = 0;
    for (uint i = 0; i < pages(); i++)
    {
        currentPage = page(i);
        width = currentPage->width();
        height = currentPage->height();
        /* The following line is wrong, because width and height will already be swapped in the Okular::Page.
        *  Rotation is not the rotation defined by the user in the gui for viewing, it's a property within the pdf specification.
        */
        //if (currentPage->orientation() == Okular::Rotation90 || currentPage->orientation() == Okular::Rotation270) qSwap(width, height);
        if (width > height) landscape++;
        else portrait++;
    }
    return (landscape > portrait) ? QPrinter::Landscape : QPrinter::Portrait;
}

This bugfix works for me. But bare with me if this is not the best solution, you can build your own.
Comment 4 Albert Astals Cid 2014-11-30 20:54:57 UTC
an patch against an old okular is not useful, please get at least okular from kde Applications 4.14 or the one from git, see if you can still reproduce the problem and if your patch still fixes it.
Comment 5 t_d_l_c 2014-12-01 16:14:16 UTC
Ok. I have now built okular 0.21.60 from git://anongit.kde.org/okular on my ubuntu12lts-based system/KDE 4.13.2. The problem still occurs and removing the line still helps. 

I have also noticed that when I print something in okular from landscape to portrait using the cups-pdf-printer, the resulting pdf is opened in okular as landscape. Then you would have to turn the document in the gui to have it in landscape. On a real printer this doesn't play a role, because you turn the paper as you like it.
Comment 6 t_d_l_c 2014-12-01 16:15:16 UTC
Created attachment 89792 [details]
patch for okular 0.21.60
Comment 7 Christoph Feck 2014-12-12 21:54:01 UTC
Albert, patch from comment #6 removes one line, would you need it on reviewboard to review it?
Comment 8 Albert Astals Cid 2014-12-12 23:04:16 UTC
A reviewboard would make it easier keeping track that i need to review it.

On the other hand printing bugs are really not on the top of my list, people where assholes on us enough on printing for me to decide all non printing bugs have priority over printing bugs.

Sorry guys, it's not your fault, but it is how it is.
Comment 9 Oliver Sander 2017-04-07 08:14:16 UTC
How would I reproduce this problem nowadays?  My okular version from the git master does not show orientation information in the printer dialog.
Comment 10 Michael Weghorn 2018-01-10 14:46:07 UTC
(In reply to Oliver Sander from comment #9)
> How would I reproduce this problem nowadays?  My okular version from the git
> master does not show orientation information in the printer dialog.

The orientation information can be set in the print dialog under "Properties" -> "Page" (it comes from the Qt 5 print dialog).

I am a colleague of "t_d_l_c" and at least for the document that was used in our case, the problem is no longer reproducible with up-to-date Okular and Poppler versions.
(We just verified that the problem occurs on Kubuntu 12.04, but no longer on an up-to-date system (Ubuntu 18.04 based) with Okular from Applications 17.12).

@Wolfgang Schmidt: Does your problem still occur? Could you add a sample document and a step-by-step guide to reproduce the issue in this case?
Comment 11 Albert Astals Cid 2018-01-10 19:04:56 UTC
Please provide information if possible
Comment 12 Andrew Crouthamel 2018-09-28 03:33:25 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 15 days. Please provide the requested information as soon as possible and set the bug status as REPORTED. Due to regular bug tracker maintenance, if the bug is still in NEEDSINFO status with no change in 30 days, the bug will be closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

If you have already provided the requested information, please set the bug status as REPORTED so that the KDE team knows that the bug is ready to be confirmed.

Thank you for helping us make KDE software even better for everyone!
Comment 13 Andrew Crouthamel 2018-10-29 02:04:07 UTC
Dear Bug Submitter,

This bug has been in NEEDSINFO status with no change for at least 30 days. The bug is now closed as RESOLVED > WORKSFORME due to lack of needed information.

For more information about our bug triaging procedures please read the wiki located here: https://community.kde.org/Guidelines_and_HOWTOs/Bug_triaging

Thank you for helping us make KDE software even better for everyone!