473,416 Members | 1,498 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,416 software developers and data experts.

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
PrintPageEventArgs)
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
Try
Dim PrintDoc As New PrintDocument()
AddHandler PrintDoc.PrintPage, 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 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
0 1805

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

Similar topics

9
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...
0
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...
2
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...
3
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:...
2
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...
0
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...
0
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...
8
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...
8
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.