I am successfully using this (fantastic) module - - but would like to have the following functionality:

BTW - - I am using only html print

when a user selects "print", a new page is not displayed (that is there is no "preview" page of the printer-formatted output) but instead simply the browser print dialog.

At the moment, I am successfully creating an output in the desired format but it is a requirement that that the user does not re-direct off-page and we do not want a new window.

I am sure this can be done but I am not sure how.

Thanks to all

n

Comments

jcnventura’s picture

Status: Active » Postponed (maintainer needs more info)

Hi,

There's no way to create the version in an hidden window with the module at the moment.

However, it should be a simple matter of adding the window.close() javascript after the window.print() call in print.pages.inc:

--- print.pages.inc     20 Aug 2009 02:19:19 -0000      1.1.2.54
+++ print.pages.inc     4 Sep 2009 08:22:33 -0000
@@ -220,7 +220,7 @@
     }
   }

-  $print['sendtoprinter'] = $print_html_sendtoprinter ? ' onload="window.print();"' : '';
+  $print['sendtoprinter'] = $print_html_sendtoprinter ? ' onload="window.print();window.close();"' : '';

   switch ($print_logo_options) {
     case 0: // none

Can you test it and see if it does what you want?

João

newtonpage’s picture

Thanks do much for the reply

Yes - - this does work but I surely hate to hack your excellent module.

Here is the behavior with your suggested code:

- - window opens
- - waits for user confirm of print
- - window closes

This works for now but here is what I have done in the node tpl where this link is placed:

<a
	href = "/devel/foogli_test_01/print/node/<?php print $nodeId;?>"
	class = "<?php print $node->links['print_html']['attributes']['class']; ?> "
	title = "print a copy of <?php print $node->title;?>"
	rel =  "/devel/foogli_test_01/print/node/<?php print $nodeId;?>"
	onclick = "<?php print $node->links['print_html']['attributes']['onclick']; ?>"

>

This is a little unusual but I need to style the link like so:

[image] [grey text] "print" [orange text] "activity"

This has css rollover and the image is supplied by sprite.

Since the html is stripped (rightly) from the title field, I decided to do this like this - - although I could have wrapped that div and replaced it with jQuery.

In any case, to try to avoid hacking the module, I tried without success to intervene in the onclick but I could not get it to work.

I tried putting in:

onclick = "window.open(this.href); window.print(this.href); window.close(this.href); return false;"

but I still this did not work and since it required that I comment out 'send_to_printer' - - well, this is not OK.

The ideal thing, of course, would be to do this in the popups api but this does not work since the popup hates this - - I suspect that it has to do with the way the I have structured the print_html.node-activity.tpl.php - -

I am at looking an ajax call and using a modal to display the page - - not sure if the print command will work here, though, since it may print the whole page plus the modal.

Are you aware of anyone who has successfully used a modal or the popups api here?

In any case, this works for now and I truly appreciate your response.

I have subscribed and I will try to answer questions where I am able.

n

jcnventura’s picture

Status: Postponed (maintainer needs more info) » Active

I am thinking about putting an option to NOT close the window automatically when the setting is to open in a new window and print automatically (I can't see any reason why anyone would want a new window + auto print without wanting to close it after).

jcnventura’s picture

Status: Active » Fixed

I've just committed some code that adds a new setting to close the window when both the new window and send to printer are enabled.

Joao

Status: Fixed » Closed (fixed)

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