Even more webgadget printing!

Everything else that doesn't fall into one of the other PB categories.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Even more webgadget printing!

Post 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
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

C'mon, you guys have bailed me out in the past! I can't think of anything else here!

:twisted: :twisted:
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post 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.
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

It's really just asking IE to print, so I'm not sure there is any control over it.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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?
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post 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.
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post by Karbon »

Freak, thank you very much! I owe you about 20 favors, feel free to collect any time!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
freak
PureBasic Team
PureBasic Team
Posts: 5948
Joined: Fri Apr 25, 2003 5:21 pm
Location: Germany

Post by freak »

I'm curious.. did you make any progress on this?
quidquid Latine dictum sit altum videtur
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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!
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
Post Reply