michaelrsweet / pappl

PAPPL - Printer Application Framework
https://www.msweet.org/pappl
Apache License 2.0
309 stars 49 forks source link

Web interface: Changes of settings under Media only apply for printing if Save Changes is clicked under Printing Defaults #164

Closed tillkamppeter closed 3 years ago

tillkamppeter commented 3 years ago

In the PostScript Printer Application I set up a printer, it gets assigned a make/model and then I can click "Media", tell which paper is in which tray, click "Save changes" at the bottom, and then click "Printing Defaults" where I can set the default for the other options (and also select the tray from which I want to print). If I do nothing here because the paper I want to print on is in the first tray and the other settings are also what I need, I do not click anything, click on the printer name to get back to the printer's page and click "Test Page". The test page prints, but in Letter size whereas I have told under "Media" that my tray contains A4 paper. But when I click "Save Changes" under "Printing Defaults", even without changing anything and then print the test page again, it comes out in A4 size.

In the PostScript Printer Application the data about trays, paper sizes, and other options comes from PPD files and they usually have Letter as default paper size. So on the "Media" screen all trays are shown with the default paper size, Letter. I switch that to A4 as I am in Europe where one uses A4 paper and click "Save Changes". With this I assume that the page size is A4 now, especially that the "Printing Defaults" page shows in the tray selection drop-down that tray 1 loaded with A4 paper is selected, but in reality an invisible default choice iwth the original default paper size of Letter is active.

The click on "Save changes" under "Media" should not only update the media_ready[] array in the pappl_pr_driver_data_t data structure of the print queue but also set the media_default to the entry of the selected tray (or of the first tray if none is selected).

tillkamppeter commented 3 years ago

This patch fixes this issue: refresh-media-default-when-changing-media-ready.patch.txt

It simply lets the papplPrinterSetReadyMedia() function refresh the media_default record in the printer data right after having updated the array of ready media, so changes in the tray selected by default are immediately reflected.

tillkamppeter commented 3 years ago

Some important notice about the patch:

The

  if (i >= printer->driver_data.num_source)
    printer->driver_data.media_default = printer->driver_data.media_ready[0];

after the loop is needed as a paper source can also disappear, especially if in the PostScript Printer Application under "Device Settings" the seetings under "Installable printer accessories" get changed.

tillkamppeter commented 3 years ago

I have applied this patch to the Snap of the PostScript Printer Application now, meaning that it gets tested this way, but for reproducing this bug the unsnapped PostScript Printer Application or any other Printer Application should be used.

tillkamppeter commented 3 years ago

I can reproduce this bug also with testpappl of the PAPPL package and my HP OfficeJet Pro 8730. The problem occurs when I do not apply the patch and goes away with the patch applied.

michaelrsweet commented 3 years ago

@tillkamppeter This isn't the right place to "fix" this - the default media shouldn't be changed when setting the ready media, particularly if the source in the default media isn't set. The web interface is the only place that we limit media-default to the list of ready media, so that should be where this change should be made (with a preference of preserving the media size first...)

tillkamppeter commented 3 years ago

Most important is that the user does not get something completely unexpected when he sets the "Media" settings to what he has actually loaded into the trays (for example that if he sets the media size in all trays to A4 that the job comes out in Letter).

Also if the default media setting in the driver data does not correspond with any of the tray's media, the physical printer cannot print with these settings (as it seems that the print job is sent with exactly the settings in media_default). Therefore media_default must be set to the media of one of the trays. I had selected the tray which is set by media_default.source as this is also the media displayed under the "Printing defaults".

so what you would think to set as media_default after having changed the ready media settings is at first checking whether the current tray has loaded the size which is set in media_default.size_name and only if it matches stay with the selected tray and otherwise find the first tray with the matching size, and if none matches in size, use the currently selected tray again?

I am also OK to do the setting of media_default for the updated ready media in the web interface instead of in the driver data code.

tillkamppeter commented 3 years ago

The default media is completely invisible in the web interface. one sees only the ready media on the "Media" page and on the "Printing Defaults" page one sees the ready media for the source set in the default media. So what has to be changed would be to add a "Default Media" entry to the "Media" page, like

Default Media

                A4        [ ] Borderless  Plain Paper

Ready Media

Tray 1 Media:   A4        [X] Borderless  Plain Paper
Tray 2 Media:   A3        [ ] Borderless  Plain Paper
Envelope Media: Env 10    [ ] Borderless  Plain Paper

The user can now configure the ready media for all his trays and also default paper size, borderless, and paper type on the Media page. On the "Printing Defaults" page the drop down will get one extra item (the first item) saying "Default Media: A4, Plain Paper" for the user being able to select the default media instead of an entry of the ready media. But the media selected on "Printing Defaults" always should be used, as otherwise the Printer Application is not intuitive. The user expects the settings in the web interface to be used.

tillkamppeter commented 3 years ago

To make the Printer Application behave as the web interface suggests, without modifying the web interface, jobs have to be printed with the ready media in the tray selected by the default media (the one which appears in the "Media" drop-down of the "Printing Defaults" page). This is what the user tells that he has in his printer, and if he does not configure the ready media on the "Media" page it is the default media anyway (at least in my PostScript Printer Application as there I initialize the ready media with the default media).

A patch which would do this is here: job-create-print-options-use-media-ready.patch.txt

michaelrsweet commented 3 years ago

@tillkamppeter The default media should be one of the ready media, so PAPPL's web interface enforces that. I am not going to make this complicated or infinitely configurable.

tillkamppeter commented 3 years ago

How does PAPPL's web interface enforce that the default media is one of the ready media? How can the user see which of the ready media is the default media? How can the user configure the default media via the web interface?

michaelrsweet commented 3 years ago

@tillkamppeter You can only pick one of the ready media from the printing defaults page.

tillkamppeter commented 3 years ago

@michaelrsweet that I can pick only one ready media from the Printing Defaults page is clear to me, it is the ready media I select to print on.

My problem is the following:

I create a new printer, has Tray 1 and Tray 2, so the driver gives me two ready media and one default media in the driver_data structure. The driver sets the default media to Tray 1, Letter, not borderless, plain paper and the ready media get initially filled with the paper size, type and, margins of the default media: Letter, not borderless, plain paper. The Media page shows the two appropriate entries and on the Printing Defaults page Tray 1, the source defined in the default media is selected.

If a user prints immediately, paper is taken from Tray 1 and it is assumed that it is Letter-sized plain paper and the printing is not done borderless.

Now many users set the ready media on the Media page to what they have in their printer. For example I set A4 borderless plain paper for Tray 1 and A3 borderless plain paper for Tray 2. I save the changes on the Media page and switch to Printing Defaults. Tray 1, the source of the default media is still selected, and the drop-down shows what paper I have in Tray 1: A4 borderless plain paper. Now I print a job, but the pages do not get scaled into the borderless A4 size but into Letter size with margins, as the job processing function of PAPPL uses the default media. What I expect is what I have told to be in Tray 1 on the Media page and displayed in the Media drop-down on the Printing Defaults page: My job being scaled onto borderless A4 paper (I have set "print-scaling" to "fill"). Especially as paper size, margins, and type of the default media are nowhere visible in the web interface.

With the little patch which I attached two comments earlier it works this way. It sould work at least this way if the user does not specify a page size with the job, nor the file having a specified page size (being an image file for example, or PDF/PostScript when print-scaling is set to fill or fit). If a page size is given with the job, the ready media should get searched for this size and only if it is not available one could fall back to the ready media of the default tray )or the manual tray if the printer has one?).

michaelrsweet commented 3 years ago

Try this:

[master 52b7492] Update the default media when the ready media for the corresponding source is changed (Issue #164)

tillkamppeter commented 3 years ago

It is working as expected now. Thank you very much.