On clicking the "Print" button with the "Open in new window" and "Close window after sending to printer" options set, using Chrome, the new window opens and immediately closes without printing. On trying again the new window opens but no print dialog opens.

See http://stackoverflow.com/questions/7652981/chrome-window-print-window-cl... for a discussion of this problem outside Drupal.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hughworm’s picture

I have successfully patched print.pages.inc based on solution from darven in http://stackoverflow.com/questions/7652981/chrome-window-print-window-cl... : I replaced window.close() with setTimeout(function(){window.close();}, 1).

Line 180 then becomes:

    $window_close = (variable_get('print_html_new_window', PRINT_HTML_NEW_WINDOW_DEFAULT) && variable_get('print_html_windowclose', PRINT_HTML_WINDOWCLOSE_DEFAULT)) ? 'setTimeout(function(){window.close();}, 1);' : '';

The original forms the following script:

function ($) {
	Drupal.behaviors.print = {
		attach: function(context) {
			$(window).load(function() {
				window.print();
				window.close();
			})
		}
	}
}(jQuery);

The patched version forms this script:

function ($) {
	Drupal.behaviors.print = {
		attach: function(context) {
			$(window).load(function() {
				window.print();
				setTimeout(function(){window.close();}, 1); /* In fact timeout doesn't start until print dialog closes */
			})
		}
	}
}(jQuery);

I successfully tested this in Chrome, FFX and IE11.

azovsky’s picture

Priority: Normal » Critical
Status: Active » Needs review
FileSize
1012 bytes

Thanks @hughworm!

Yours solution is working for me.

I wrapped it in a patch file.

calebtr’s picture

Status: Needs review » Reviewed & tested by the community

This patch applies and works as described.

Since no one else seems to be testing this in about 9 months, I'm setting RTBC in hopes of moving it along.

evgeny.chernyavskiy’s picture

I can confirm this patch fixes the issue.

BrightBold’s picture

This fixed the problem for me as well.

sdowney2002’s picture

This patch works for me, as well.

mradcliffe’s picture

Here's a backport of the patch in #2 for 7.x-1.x.

sureshcj’s picture

Thanks @hughworm!

The #2 patch work for me...

jcnventura’s picture

Status: Reviewed & tested by the community » Fixed

Thanks everyone!

  • mradcliffe authored efe2bdf on 7.x-1.x
    Issue #2324829 by mradcliffe, azovsky, hughworm: "Close window after...

  • jcnventura committed 669afdb on 7.x-2.x authored by azovsky
    Issue #2324829 by azovsky, hughworm, evgeny.chernyavskiy, calebtr,...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

buckydawg’s picture

good day how do i run this patch