Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Print web page in VB.NET Console Application

Posted on 2010-11-17
7
Medium Priority
?
850 Views
Last Modified: 2012-05-10
Hello, I am struggling to print a web page from a VB.NET terminal application. Basically, when our system sees a command in the database, it prints off a web page based on the value of that command. The problem I am having, is calling a web browser control gives me an ActiveX error about the application not having multiple threads.

Any code snippets for this would be really appreciated.
0
Comment
Question by:Benji_
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 7

Expert Comment

by:rogerard
ID: 34157944
I just did a test in my vb.net 2005.  I added a WebBrowser control to the form, set it the url to both a url and to a html file, then executed
Me.WebBrowser1.Print()
for both types of pages and it printed find.  Are you trying to print it from a background worker?
0
 
LVL 7

Expert Comment

by:rogerard
ID: 34157982
If trying to print from a thread, implement something similar to this:
 
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Me.WebBrowser1.Print()
    If Me.WebBrowser1.InvokeRequired Then
      Me.WebBrowser1.Invoke(New MethodInvoker(AddressOf printbrowser))
    Else
      WebBrowser1.Print()
    End If
  End Sub

  Private Sub printbrowser()
    Me.WebBrowser1.Print()
  End Sub

Open in new window

0
 
LVL 7

Expert Comment

by:rogerard
ID: 34157990
delete the first me.webbrowser1.print from the code above at line 2.  I forgot to remove it.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 2

Author Comment

by:Benji_
ID: 34162714
Sorry, both of you seem to have missed (though this is my fault) that this application is a Terminal application, or a Console application in VB.NET terms. Sorry, but thank you for trying.
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 34162777
Does it have to be console app?

One option is to develop another winforms based app which you can launch from your console app. That app can use the webbrowser and print the web page.
0
 
LVL 2

Author Comment

by:Benji_
ID: 34164357
I am thinking of just moving from a console app to a winforms app. As nice as it is having a nice simple system, I think it is time to move to winforms as the solution.

Thanks for all your help.
0
 
LVL 2

Author Closing Comment

by:Benji_
ID: 34164372
Shame there was never a full solution, but still made me see what had to be done.
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question