473,545 Members | 2,639 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need Help Printing within Web Browser using a Windows Forms Control

I successfully create a .NET Component (Visual Basic .NET) that would
print, unfortunately when used within a web browser it appears that .NET
security doesn't allow you to run code that interacts with the file system
(including printing) from the web browser. How do I disabled this so I can
get my windows form control to work within IE?

Also, do any have any printing code or know how I can implement multipage
printing using the PrintDocument class? The MSDN example only has printing
via StreamReader class see
http://msdn.microsoft.com/library/de...ClassTopic.asp
also I can't find anything on msdn to help me implement multi-page printing
in my program using the PrintDocument class.

The Visual Basic .NET Step by Step book has the following code and text:

Imports System.Drawing. Printing

Private Sub PrintText(ByVal sender As Object, ByVal ev As
PrintPageEventA rgs)
ev.Graphics.Dra wString(TextBox 1.Text, New Font("Arial", 11,
FontStyle.Regul ar), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click
Try
Dim PrintDoc As New PrintDocument()
AddHandler PrintDoc.PrintP age, AddressOf Me.PrintText
PrintDoc.Print( )
Catch ex As Exception
MessageBox.Show ("Sorry--there is a problem printing", ex.ToString())
End Try
End Sub

This code only prints one page. The book states "To handle multipage
printouts, you need to create a virtual page of text called the PrintPage,
and then add text to it until the page is full. When the page is full, it
will be sent to the printer and this process continues until there is no
more text to print. At this point, the print job ends."

"The PrintPage event occurs when a page is printed. PrintPage receives an
argument of the type PrintPageEventA rgs, which provides you with the
dimensions and characters of the current printer page. Another mechanism is
the Graphics.Measur eString method which can be used to determine how many
characteristics & lines can fit in a rectangular area of the page"

I tried looking for information on how to implement this but found now. How
do I implement MultiPage printing?

Not only do I want to know how to multipage print using the PrintDocument
class I also do not want to use Crystal Reports or pdf for report generation
in the web browser in order to print reports from web browser. I saw the
microsoft MCP website used an ActiveX control to print your MCP Transcript.
That's exactly what I want. To pull information from an SQL Server database
and bulid mu own print page/s with the text and graphics I want on it so I
can have my report.
Nov 17 '05 #1
0 1812

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
4091
by: Jody Gelowitz | last post by:
I am trying to find the definition of "Safe Printing" and cannot find out exactly what this entitles. The reason is that I am trying to print contents from a single textbox to no avail using the PrintDialog control under a security setting with only SafePrinting allowed. I have attached a sample project that I am using to try to accomplish...
0
1635
by: DotNetDummy | last post by:
Hi all, I am trying to set the printing setting e.g duplex mode etc. on a default printer when I.E object started printing a particular html doc. Here's the partial code, any help would be appreciated. I have been using system.drawing.printing method but not much help since drawing.printing required printDocument() object which...
2
12459
by: gerb | last post by:
Hello, I realise this is not a pure Javascript question, and that VBscript is probably involved at some point, though not as much as I fear. If you opened this item looking for a pute Javascript question, I'm sorry. For an IE6 intranet application I'm running into some problems regarding printing screens from the browser. The specs...
3
2895
by: Michel H | last post by:
Hello everyone, While it seems simple to me, I just want to have a URL in my windows application that people can click and then launch the URL in the default browser. Same thing with a mailto: link. Here is the code i'm trying to use which comes straight from the microsoft site: string target= "http://www.microsoft.com";
2
5812
by: Benny | last post by:
Hello Experts, Currently I working on a web application using vs.net with C#. I require to create an invoice to a text file and print the file. I have no problem with writing to the text, but how can I print a text file using C# in a web application? Any articles that shows you how can this be done will be great.
0
1975
by: max reason | last post by:
I added the WebBrowser component to my toolbox, then placed one on a form with other .NET components. This much seems to have worked, but I do not understand how to control the sucker from within my application. Specifically, what sort of syntax is involved to get the various interfaces (IHTMLWindow, IHTMLDocument3, etc) in the internal...
0
2456
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls which are not behaving as I would expect. Specifically, if there is a command button external to the usercontrol which is activated by a shortcut...
8
2397
by: Rick Lederman | last post by:
I am using a PrintDocument and PrintDialog to print. The first time that I print it works, but when I try to print a second time without exiting the entire program I get an "InvalidPrinterException was unhandled" error. The error happens in the third line below. The details of the error are below my signature. Help? ...
8
5877
by: Neo Geshel | last post by:
Greetings. BACKGROUND: My sites are pure XHTML 1.1 with CSS 2.1 for markup. My pages are delivered as application/xhtml+xml for all non-MS web clients, and as text/xml for all MS web clients (Internet Explorer). My flash content was originally brought in via the “flash satay” method, but I have since used some server-side magic...
0
7490
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7682
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7449
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7780
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6009
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3465
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1911
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1037
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.