Discussion Locked

Print using VB component and Internet

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I have a web page that calls a vb component. When the user clicks on a link I want to automatically print certain information from the database to the USER's default printer.

Currently I am using the printer.print method in vb to write out all of the data. The data is printing fine, but my problem is that it is being sent to the default printer of the computer on which the vb program resides.
I need to know how to change the printer to be the USER's default printer instead of the default printer of the computer running the component. Please help.

5 replies

by steved

Is this a client-side or a server-side component? If client-side, it should be installed on the user's computer and use the right printer (but it probably has a heck of a time reading data from the database). If server-side, it will never be able touse the client's printer (but it sees the database just fine). Your best solution might be to use a server-side component to provide printer-friendly output directly to the web page. Then let the user use their browser's Print function.

I hope this helps.

Steve Diamond

by aking-robertson

It is a server side component. Letting the user use the browser's print function is not really an option. It needs to print automatically. That's the problem. I know there must be a way to get the default printer settings off the user's pc using oneof the win api functions or something, I'm just not sure how. Thanks for your help though.

by steved

Sorry to have to repeat myself, but you're not really seeing the situation clearly. A server-side component is executing only on the web server. It cannot, under any circumstances, interact with the client computer except through the browser or someother client-side component (like a plug-in). It cannot execute any Win API calls on the client computer because it's not running there. It cannot access the client's printer because it's not running there.

What you are looking to do can only be done by a client-side component. That's why I suggested formatting the report so that the client's browser could print it. The only alternative is to create a new client-side component that would communicate directly with your server-side component. Every client would have to download this component, which would easily be able to print to the client's default printer. You would have to make your server-side component push the data for the report over to the client-side component, and make your client-side component do the printing.

I hope this makes it a bit more clear.

Steve Diamond

by aking-robertson

I agree with you that just writing a printer friendly version of the report and asking the user to click the 'Print' button the browser would be a good solution. However, my boss does not agree. I have found a way to worm around this though, in thatsince we only have a few users, I will add a field in my database that specifies the printer connection. I'll get that value when they login and when they're ready to print, I can tell it to print there from vb. For my current situation, this will probably be a viable solution. But, I really appreciate your help. Thanks.

This discussion is closed to new replies.