Solved

Easy printing of files in VB .net

Posted on 2004-09-22
9
272 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
[X]
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
  • 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
PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

 
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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

752 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