Solved

Easy printing of files in VB .net

Posted on 2004-09-22
9
271 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

685 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