By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,719 Members | 1,875 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,719 IT Pros & Developers. It's quick & easy.

Need Help Printing within Web Browser using a Windows Forms Control

P: n/a
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
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
ev.Graphics.DrawString(TextBox1.Text, New Font("Arial", 11,
FontStyle.Regular), Brushes.Black, 120, 120)
ev.HasMorePages = False
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button2.Click
Dim PrintDoc As New PrintDocument()
AddHandler PrintDoc.PrintPage, AddressOf Me.PrintText
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 PrintPageEventArgs, which provides you with the
dimensions and characters of the current printer page. Another mechanism is
the Graphics.MeasureString 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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.