ONLYOFFICE / DesktopEditors

An office suite that combines text, spreadsheet and presentation editors allowing to create, view and edit local documents
https://www.onlyoffice.com
Other
2.78k stars 321 forks source link

Printer options Duplex Two-sided settings configuration #602

Closed paucoma closed 3 years ago

paucoma commented 3 years ago

Do you want to request a feature or report a bug? Bug What is the current behavior? Whenever a Print Dialog appears Clicking on " Options >>" --> " Options " Tab --> Duplex Printing always defaults to None: image

Although the default for the printer is : Duplex : Long Side

:~/.cups$ lpoptions -p HPCLJ_M281 -l
PageSize/Media Size: 100x150mm 184x260mm 195x270mm 4x6 5x8 *A4 A5 A6 B5 B6 DoublePostcardRotated Env10 EnvC5 EnvDL EnvMonarch Executive FanFoldGermanLegal ISOB5 Legal Letter Oficio Postcard roc16k Custom.WIDTHxHEIGHT
InputSlot/Media Source: *Auto Manual Tray1 Tray2
ColorModel/Print Color Mode: Gray AdobeRGB DeviceRGB DeviceGray *RGB
Duplex/2-Sided Printing: None *DuplexNoTumble DuplexTumble
cupsPrintQuality/Print Quality: *Draft Normal
print-content-optimize/Print Optimization: *auto photo graphics text text-and-graphics
print-scaling/Print Scaling: *auto auto-fit fill fit none

image

I manually change it to "Long side" within the print dialog, but every time I print again it defaults back to "None"

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

  1. Start Only Office
  2. Open blank Document or Spreadsheet
  3. Print -> Options -> Options Tab -> Duplex Printing Options --> Set to Long-side
  4. Print
  5. Close Only Office
  6. Start OnlyOffice Again, try again. no persistance

What is the expected behavior?

Ideally, this setting should get the default settings from the CUPS server. If there is system changes then these should also be there. If it is not possible, at a minimum, there should be persistance or option to save new default, across application restarts.

Did this work in previous versions of DocumentServer? Don't know, Guess Not

DocumentServer version: ONLYOFFICE Desktop Editors version 6.2.0.148

Operating System: Linux 5.8.0-48-generic ONLYOFFICE/DocumentServer#54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux

Browser version: Firefox 87.0 (64-bit) Google Chrome Version 89.0.4389.114 (Official Build) (64-bit)

LuckySpecialist commented 3 years ago

Hi @paucoma! According to the description, I understood that it is about Desktop Editors, although the problem is located in the Document Server section.

The window you have shown is the system window (we call it after you click print). The settings should be taken by the system directly from the printserver or the user settings of the printer. The fact that the settings are not saved after restarting the application is normal, since this change is valid only for one printing session. When you print again, the default settings are loaded again (from the system or the print server).

So there are a few questions:

  1. When printing in onlyoffice, after changing the option of double-sided printing, the file is printed as expected?
  2. How do other applications behave when printing, is the desired option saved and is it printed correctly?
  3. Have you tried installing the HPLIP driver package and printing with it?
ShockwaveNN commented 3 years ago

Moved this issue to DesktopEditors since seems this is a problem in DesktopEditosr

paucoma commented 3 years ago

Hi LuckySpecialist, thanks for your reply. Sorry for opening this in the wrong spot.

  1. After selecting Duplex Longside it prints as expected, yes
  2. a. Gedit (Gnome Desktop "notepad") it is by default Duplex Long Edge as system defaults (and changes when I change cups server setting) image b. Libre Office Calc, writer, etc.. as well as system defaults (and changes, after application restart, when I change it in the cups server) image c. Google Chrome as well as system defaults (and changes when I change it in the cups server) image d. Firefox apparently does not use system defaults, by default it was off. I go to about:config config page and change the setting and it changes firefox settings. print.printer_HPCLJ_M281.print_duplex
    0 - Off 1 - Flip on long edge 2 - Flip on short edge Any changes to Firefox settings do not influence other programs nor onlyoffice settings either.

  3. I do not believe that this is a driver package issue but as to where and what settings get requested and set when onlyoffice makes the call to the "system print" . Since the value 0 is Duplex: off I am suspecting that this setting is just not being set within the call the the "system print" and therefore always defaults to off.

Of course this bug is low priority as you can manually change it each time and it works as expected. Just a bother that you need to do these extra steps every time you want to print something double-sided. At first glance looks like "low hanging fruit" bug which would not be too difficult to solve.

If you require any more tests/research let me know.

paucoma commented 3 years ago

I did a little bit of browsing and found that the PrinterDialog gets created here, the printer object passed onto this dialog is defined here derived from a wrapper class? QAscPrinterContext defined here, the Qprinter being declared in the header file

I did the following small test Code to see what it would return.

#include <QApplication>
#include <QPrinter>
#include <QPrintDialog>

int main( int argc, char **argv )
{
    QApplication a( argc, argv );

    QPrinter myPrinter;

    QPrintDialog printDialog(&myPrinter,0);
    if (printDialog.exec() == QDialog::Accepted)
      printDialog.show();

    return 0;
}

Compiled it with QT5 v5.12.8

$ make
g++ -c -pipe -O2 -Wall -W -D_REENTRANT -fPIC -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_PRINTSUPPORT_LIB -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /usr/include/x86_64-linux-gnu/qt5 -isystem /usr/include/x86_64-linux-gnu/qt5/QtPrintSupport -isystem /usr/include/x86_64-linux-gnu/qt5/QtWidgets -isystem /usr/include/x86_64-linux-gnu/qt5/QtGui -isystem /usr/include/x86_64-linux-gnu/qt5/QtCore -I. -I/usr/lib/x86_64-linux-gnu/qt5/mkspecs/linux-g++ -o main.o main.cpp
g++ -Wl,-O1 -o test main.o   /usr/lib/x86_64-linux-gnu/libQt5PrintSupport.so /usr/lib/x86_64-linux-gnu/libQt5Widgets.so /usr/lib/x86_64-linux-gnu/libQt5Gui.so /usr/lib/x86_64-linux-gnu/libQt5Core.so /usr/lib/x86_64-linux-gnu/libGL.so -lpthread

This small test code works fine. Meaning that it uses the system defined defaults, and changes when I change the system defaults via CUPS image

I did not go more into details but perhaps within the QAscPrinterContext something is removing the printer defined duplexMode ?

paucoma commented 3 years ago

So I did some more tests and search and I noticed that in cef_types.h the internal enum gets defined for duplex modes

///
// Print job duplex mode values.
///
typedef enum {
  DUPLEX_MODE_UNKNOWN = -1,
  DUPLEX_MODE_SIMPLEX,
  DUPLEX_MODE_LONG_EDGE,
  DUPLEX_MODE_SHORT_EDGE,
} cef_duplex_mode_t;

This does not coincide with Qts' enum: enum QPrinter::DuplexMode

Constant    Value   
QPrinter::DuplexNone    0
QPrinter::DuplexAuto    1
QPrinter::DuplexLongSide    2
QPrinter::DuplexShortSide   3

But I think I may have found a source of the problem.

with my mini test code I added the following:

    QPrinter myPrinter;  
    std::cout << myPrinter.duplex() <<std::endl;
    QPrinterInfo myPrinterInfo(myPrinter);
    std::cout << myPrinterInfo.defaultDuplexMode() <<std::endl;

QPrinter::duplex() always returns 0, no matter what my default setting is. QPrinterInfo::defaultDuplexMode() returns the correct system setting following the enum QPrinter::DuplexMode.

Duplex set to None in System Settings

:~$ ./test 
0
0

Duplex set to LongEdge in System Settings

:~$ ./test 
0
2

Duplex set to ShortEdge in System Settings

:~$ ./test 
0
3

So to properly get the system settings QPrinterInfo object must be used. I see that in the code a QPrinterInfo object does get created but a search for defaultDuplexMode does not turn up anything, hinting towards that this function is not accessed.

ShockwaveNN commented 3 years ago

I'll leave this issue opened until we release DesktopEditors v6.3.1

ShockwaveNN commented 3 years ago

DocumentServer and DesktopEditors v6.3.1 is released. This issue should be fixed