Solved

Easy printing of files in VB .net

Posted on 2004-09-22
9
266 Views
Last Modified: 2008-03-06
I am a beginner at VB .net
I am overwhelmed by the complexity of printing a multiline rtf file using .net. I have searched the forums and feel nauseated at this huge task!
Are there any inexpensive (preferably free) easy to use components that a beginner can use?
As I do this for fun I can not shell out hundreds of dollars!
I would like the flexibility of being able to print the contents of an RTF box or a multi font RTF file from the hard disk.
Thanks.
0
Comment
Question by:pharries
  • 2
  • 2
  • 2
  • +1
9 Comments
 
LVL 19

Expert Comment

by:Desp
Comment Utility
imports System.Diagnostics

Dim pi As ProcessStartInfo = New ProcessStartInfo("C:\doc.rtf")
pi.Verb = "print"
pi.WindowStyle = ProcessWindowStyle.Hidden
Dim p As Process = New Process()
p.StartInfo = pi
p.Start()
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
This link may help if the document is open in a richtextbox
http://216.26.160.137/Forums/AspNetForums20/ShowPost.aspx?PostID=6908
0
 

Author Comment

by:pharries
Comment Utility
DESP
Will this handle a multipage document?
How would I set margins, select printer etc?
0
 
LVL 27

Expert Comment

by:planocz
Comment Utility
Check here for some micro$oft ideas of printing

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnwinforms/html/printwinforms.asp

there is also a report generator that is loaded into the SQL server from Micro$oft that is still free to down load.
I am guessing that this could replace CR reports in the future.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 19

Expert Comment

by:Desp
Comment Utility
This is the simplest way to print MULTIPAGE docs to the DEFAULT printer
for setting the margins and other things you have to use the printdialog and other controls/classes
0
 
LVL 18

Expert Comment

by:armoghan
Comment Utility
see me post above for using the print dialog
0
 

Author Comment

by:pharries
Comment Utility
Is there anyway of being able to do this simply and preset margins etc and the chosen printer from within the code so that when print is hit no print dialog appears.
I really do need to prevent the users from being to selecvct their own printer
Thanks
0
 
LVL 27

Accepted Solution

by:
planocz earned 400 total points
Comment Utility
code  to set printer to print so user does not set it...

   'Example:  InitializePrinterToUSE("Brother HL-1650/1670N Duplex 1")

    Public Function InitializePrinterToUSE(ByVal sPrinterName As String)
        ' Set the specified printer to the default printer for this program. Return
        ' true if the printer was found.
        Dim i As Integer
        Dim printer As New Printing.PrinterSettings

        For i = 0 To printer.InstalledPrinters.Count - 1
            If InStr(printer.InstalledPrinters.Item(i), sPrinterName) > 0 Then
                printer.PrinterName = printer.InstalledPrinters.Item(i)
                Return printer.PrinterName
                Exit Function
            End If
        Next i
        MsgBox("The '" & sPrinterName & "' printer could not be found.", vbExclamation)
    End Function
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

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 …
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now