Bug 463732

Summary: Print Dialog should remember PDF Options
Product: [Applications] okular Reporter: Gregor Mi <codestruct>
Component: printingAssignee: Okular developers <okular-devel>
Status: RESOLVED FIXED    
Severity: wishlist CC: bk-kde-org, fw.smit01, me, nate
Priority: NOR    
Version: 21.12.3   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In: 23.08
Sentry Crash Report:
Attachments: PDF Options in the Okular Print dialog

Description Gregor Mi 2023-01-02 15:51:49 UTC
Created attachment 154961 [details]
PDF Options in the Okular Print dialog

When printing several documents of the same kind, it would be nice if the PDF Options from the last document printed document would be restored.

In my case, I had to print a bunch of graphics that must be printed with exact measurements. The default "Fit to printable area" would shrink the documents and make the result unusable.

STEPS TO REPRODUCE
1. Open PDF, choose Print, in "PDF Options" tab under Scale Mode switch from "Fit to printable area" to "None; print original size", then click the Print button.
2. Choose Print again, visit "PDF Options" tab and notice that again we have "Fit to printable area" selected.

EXPECTED RESULT
The last used settings would be restored.
Comment 1 Nate Graham 2023-01-09 22:51:56 UTC
The dialog belongs to Qt and unfortunately any changes need to be made there. Feel free to report this at https://bugreports.qt.io.
Comment 2 Martin Schnitkemper 2023-01-11 10:04:31 UTC
I'm not the expert, but the decision is made in core/printoptionswidget.cpp:

| {
|     setWindowTitle(i18n("Print Options"));
|     QFormLayout *layout = new QFormLayout(this);
|     m_ignorePrintMargins = new QComboBox;
|     // value indicates whether full page is enabled (i.e. print margins ignored)
|     m_ignorePrintMargins->insertItem(0, i18n("Fit to printable area"), false);
|     m_ignorePrintMargins->insertItem(1, i18n("Fit to full page"), true);
|     layout->addRow(i18n("Scale mode:"), m_ignorePrintMargins);
| }    

Then it should be possible to store the return value ("true" or "false") as a status in ~/.config/okularrc and when opening the dialog again,
read the value and set it as default.
Comment 3 Martin Schnitkemper 2023-01-11 11:53:02 UTC
Sorry, it seems to be decided in the function "PDFOptionsPage" of "generators/poppler/generator_pdf.cpp":

| m_scaleMode = new QComboBox;
| m_scaleMode->insertItem(FitToPrintableArea, i18n("Fit to printable area"), FitToPrintableArea);
| m_scaleMode->insertItem(FitToPage, i18n("Fit to full page"), FitToPage);
| m_scaleMode->insertItem(None, i18n("None; print original size"), None);
| m_scaleMode->setToolTip(i18n("Scaling mode for the printed pages"));
| printBackendLayout->addRow(i18n("Scale mode:"), m_scaleMode);

So the return value of "m_scaleMode" should be saved and reloaded as default.
Comment 4 Nate Graham 2023-01-11 14:57:28 UTC
This would work for the scaling option, since it's added by Okular. But it would not work for any other options that come from the basic dialog itself. So if we did this, we'd go from "nothing is remembered" to "random options are remembered, but most aren't".

("random" here is from the user's perspective, because most users won't understand which parts of the dialog come from Qt and which parts come from Okular)

This might be more confusing than enlightening. But maybe I'm wrong and the scaling options really are so important to remember.
Comment 5 ratijas 2023-01-11 15:07:36 UTC
I agree that it would make sense to remember options, but I also agree that it's something to be done in upstream. If the framework allows pluggable options like scaling coming from downstream apps, then it's the responsibility of the framework to provide save/restore API for such extensions as well.
Comment 6 Martin Schnitkemper 2023-01-11 15:34:22 UTC
(In reply to Nate Graham from comment #4)
> This would work for the scaling option, since it's added by Okular. But it
> would not work for any other options that come from the basic dialog itself.
> So if we did this, we'd go from "nothing is remembered" to "random options
> are remembered, but most aren't".
You have a point with that.

Perhaps one possibility would be to let the user specify in the application's configuration dialog which option he would like to start the dialog with. Then it is clear that it is not the last selected option that becomes the default, but explicitly the option specified by the user.

For me, the scaling option is not that important, we just had a discussion in a German newsgroup about how to change the behavior, and I didn't see an option there.

For anyone who suffers from the current behavior, I can provide a patch that defaults to the third item in the list instead of the first.
Comment 7 bk-kde-org@kirk.de 2023-01-12 11:32:29 UTC
It is somewhat annoying to step through the menus, tab and buttons every time when printing. Almost every program that creates PDF documents reserves some frame space for the not printable area, and okular does it again by default. So the documents are printed visible smaller, and if an engineering drawing is to be printed (here frequently), it is important to get the correct scale. That means every time go to [Settings], then goto Tab [PDF options], drop down scale list, chose [no scale] and then [print]. It would make it noticable easier, so I would appreciate a change here.
Comment 8 ratijas 2023-01-12 16:54:22 UTC
Well, starting from contributing upstream is also an option, I guess.
Comment 9 fw.smit01 2023-02-27 16:12:54 UTC
Has anyone already tried contributing upstream? Maybe it's better to create a kde-specific print dialog. That's a lot easier to change and can be better integrated with kde apps
Comment 10 Nate Graham 2023-02-27 20:55:09 UTC
I've opened an Issue in Okular where we can discuss which option we think makes sense: https://invent.kde.org/graphics/okular/-/issues/80
Comment 11 Nate Graham 2023-05-31 23:51:46 UTC
Git commit 8afcf256a8efc176cc9d84f4681e64a5144bdf1a by Nate Graham, on behalf of Martin Schnitkemper.
Committed on 31/05/2023 at 23:51.
Pushed by ngraham into branch 'master'.

Make default PDF printing scale mode configurable

Until now, some users have found it annoying when they want to print
multiple documents in their original size and have to manually change
the scaling mode before each print. This commit allows the user to
select the default value so they won't have to change it before every
print.
FIXED-IN: 23.08

M  +6    -0    generators/poppler/conf/pdfsettings.kcfg
M  +44   -1    generators/poppler/conf/pdfsettingswidget.ui
M  +8    -0    generators/poppler/generator_pdf.cpp

https://invent.kde.org/graphics/okular/-/commit/8afcf256a8efc176cc9d84f4681e64a5144bdf1a