Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Controls
  New Posts New Posts RSS Feed - webbrowser control / printing
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

webbrowser control / printing

 Post Reply Post Reply
Author
Message
fuxi View Drop Down
Groupie
Groupie


Joined: 15 December 2008
Location: Germany
Status: Offline
Points: 21
Post Options Post Options   Thanks (0) Thanks(0)   Quote fuxi Quote  Post ReplyReply Direct Link To This Post Topic: webbrowser control / printing
    Posted: 12 June 2009 at 10:24am
hi all,

i managed to display + print data but here's my problem:

i'd like to do somekind of serial printing - the problem: printing gives me missing + blank pages.
i'm doing it like this:

for page=1 to 20
   with mybrowserWrapper
      .generate_page page ' i'm generating html data out of a database
      .show                          ' i'm now saving the html data to a tmpfile, loading it to the control using .navigate tmpfile
                                         ' the html appears, and i'm using Do While htm.Busy: DoEvents: Loop to determine when it has finished loading
      .printIt                        ' i'm printing like this: htm.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER
   end with
next

the code seems ok, but there's something with printing, either the printing routine starts before it gets data (blank pages) or it's skipping pages (the loop continues before printing has finished).

i'm not sure where to find the problem :/ but i guess i need to wait until print has finished before i generate the next page.

anyone knows how to do it?
thanks,
fuxi
Back to Top
Krog View Drop Down
Groupie
Groupie


Joined: 06 February 2008
Status: Offline
Points: 100
Post Options Post Options   Thanks (0) Thanks(0)   Quote Krog Quote  Post ReplyReply Direct Link To This Post Posted: 27 June 2009 at 4:58am
Hi!

This is the way the WebBrowser control handles printing:

By default, the ExecWB() method passes a copy of the document to a separate thread, which then performs the actual printing. In this way the ExecWB() method returns immediately, without waiting for the thread to finish, and if the browser is destroyed while printing is still in progress, only part of the contents will be printed.

You can use the following constants:


Const PRINT_DONTBOTHERUSER = 1
Const PRINT_WAITFORCOMPLETION = 2


These can be used to enhance the print function. For example: PRINT_WAITFORCOMPLETION can be used to wait until the pages have been sent to the printer before continuing (especially useful if you want to restore the original header/footer) and PRINT_DONTBOTHERUSER can be used to hide all print dialogs.

So the code may look like this:


' start printing, and wait until output has been spooled to printer...
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_DONTPROMPTUSER, PRINT_WAITFORCOMPLETION Or PRINT_DONTBOTHERUSER, 0


There is more info in the MSDN link bellow:

http://msdn.microsoft.com/en-us/library/aa769937(VS.85).aspx
Product: Xtreme SuitePro (ActiveX) version 15.2.1
Platform: Windows XP SP2
Language: Visual Basic 6 SP6
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.234 seconds.