Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Easy printing of files in VB .net

Posted on 2004-09-22
9
270 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
ID: 12130621
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
ID: 12131024
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
ID: 12132148
DESP
Will this handle a multipage document?
How would I set margins, select printer etc?
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 27

Expert Comment

by:planocz
ID: 12132270
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
 
LVL 19

Expert Comment

by:Desp
ID: 12132401
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
ID: 12132564
see me post above for using the print dialog
0
 

Author Comment

by:pharries
ID: 12332905
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
ID: 12536833
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

861 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