Solved

Easy printing of files in VB .net

Posted on 2004-09-22
9
269 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

808 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