Page 1 of 1

Even more webgadget printing!

Posted: Wed Jan 05, 2005 5:30 pm
by Karbon
This code works exceptionally well with single prints, but when called multiple times the document run off the printer in a different order than the function was called.

I've tried a WindowEvent() after the ExecWB call at the bottom but haven't had any luck getting any kind of sensible order out of it. Can anyone think of any reason that might be happening?

Code: Select all

  Procedure print_webgadget(webgadget.l,type.l)

  WebObject.IWebBrowser2 = GetWindowLong_(GadgetID(webgadget), #GWL_USERDATA)
   
  Repeat
    WebObject\get_Busy(@IsBusy.l)
    Delay(1)
    While WindowEvent(): Wend
  Until IsBusy = 0
  
  ; Type is the operation to perform.
  
  Select type
    
    Case 0
      WebObject\ExecWB(#OLECMDID_PRINT, #OLECMDEXECOPT_PROMPTUSER, 0, 0)
    Case 1
      WebObject\ExecWB(#OLECMDID_PRINT, #OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)
    Case 2 
      WebObject\ExecWB(#OLECMDID_PRINTPREVIEW, #OLECMDEXECOPT_DONTPROMPTUSER, 0, 0)
      
  EndSelect

EndProcedure

Posted: Thu Jan 06, 2005 2:30 pm
by Karbon
C'mon, you guys have bailed me out in the past! I can't think of anything else here!

:twisted: :twisted:

Posted: Thu Jan 06, 2005 4:14 pm
by dracflamloc
I've never printed with PureBasic, but make sure those printer calls go into the printer spool/queue and not directly to the printer.

Posted: Thu Jan 06, 2005 4:25 pm
by Karbon
It's really just asking IE to print, so I'm not sure there is any control over it.

Posted: Fri Jan 07, 2005 2:58 pm
by Karbon
Something else I noticed today is that this :

Code: Select all

WebObject\ExecWB(#OLECMDID_PRINT, #OLECMDEXECOPT_PROMPTUSER, 0, 0)
Does prompt the user with the standard print dialog but doesn't pay any attention to the number of copies parameter. Any idea(s) on that one?

Posted: Tue Jan 11, 2005 3:53 pm
by Karbon
Foo. Ok. Would anyone have any other ideas as to how to print an HTML document without using the iWebBrowser2 interface to ask IE to do it? Using the "print" verb just prints out the text of the page.

Posted: Wed Jan 12, 2005 7:24 pm
by freak
No simple subject it seems...

I had a biiig look into this yesterday and didn't come up with much, since
you need some kind of rendering engine to do the printing, and they seem to
be quite rare.

What i've found is this:
http://terrainformatica.com/htmlayout/main.whtm

It is a small rendering engine in a dll. Unfortunately, the demo doesn't include
any of the printing functionality, so there is no way of testing it.
But it seems like you'd have much more power over the printing process than
with IWebBrowser2 at the cost of probably not the best rendering of complex
pages. (Since it is only a small dll, and IE is a huge thing)
Some of the pages i tested with it were rendered a little strange.

If you want to use this, i'd suggest you download the demo and check
the type of html pages you wish to print and see if it renderes them correctly,
then maybe ask the developper for a demo with the printing stuff in it.

Another solution would be to use the ActiveX wrapper for Mozilla. But i don't
know if that even supports printing.
http://www.iol.ie/~locka/mozilla/control.htm
Implementing this isn't that easy, but possible using the atl.dll

Well, that's about all i could come up with.. good luck.

Posted: Wed Jan 12, 2005 7:31 pm
by Karbon
Freak, thank you very much! I owe you about 20 favors, feel free to collect any time!

Posted: Mon Jan 24, 2005 10:51 pm
by freak
I'm curious.. did you make any progress on this?

Posted: Tue Jan 25, 2005 1:42 am
by Karbon
No, I haven't. I've given up on the HTML printing for right now. Luckily there are alternate formats - I just don't support the HTML templates when batch printing.

I'm going to pick this back up for the next version but I'm re-writing everything, so that will be a while!

Thanks very much for your help Timo!