Call tabfile() Dim piStart As New ProcessStartInfo With piStart .FileName = System.Windows.Forms.Application.StartupPath & "\tabhamlog.txt" .Verb = "print" .WindowStyle = ProcessWindowStyle.Hidden End With Process.Start(piStart)
You're Browsing As A Guest! Register Now... |
||
|
Become a VB Expert!
Join 416,731 VB Programmers for FREE! Get instant access to thousands
of VB experts, tutorials, code snippets, and more! There are 2,907 people online right now.Registration is fast and FREE... Join Now!
|
||
Page 1 of 1
printing text file in landscape prints in normal not landscape
#1
printing text file in landscape
Posted 05 January 2008 - 05:41 PM
this is going to sound stupid but I am trying to print a text file I am not sure why this works but this code below prints the file but I need to get it printed in landscape and since printing in vb 2005 studio is way different that 6.0 I need all the help I can get
#2
Re: printing text file in landscape
Posted 05 January 2008 - 09:27 PM
You know why this works? Because you are starting a process to open up the text file which launches the program associated with txt files, probably notepad. It then passes a print command to it. So it is opening up notepad and calling print.
However this is not the standard way for printing and .NET does it much better and nicer. To do it you will have to look to your toolbox for the printDialog control and the printdocument control, adding both to your project.
Your printdialog control will be for the dialog screen where you can setup printer settings like landscaping or portrait. Once you got the settings, you would set the printdocument control's printsettings property equal to the printdialog printsettings and handle the printdocument's printpage event for sending data to the printer.
Below is a great site I found which will show you a bit of the code behind this. The example also includes a pagesetup screen and print preview so you can leave those out if you want to keep it simple.
Printing in VB.NET
Enjoy!
"At DIC we be printing code ninjas!"
However this is not the standard way for printing and .NET does it much better and nicer. To do it you will have to look to your toolbox for the printDialog control and the printdocument control, adding both to your project.
Your printdialog control will be for the dialog screen where you can setup printer settings like landscaping or portrait. Once you got the settings, you would set the printdocument control's printsettings property equal to the printdialog printsettings and handle the printdocument's printpage event for sending data to the printer.
Below is a great site I found which will show you a bit of the code behind this. The example also includes a pagesetup screen and print preview so you can leave those out if you want to keep it simple.
Printing in VB.NET
Enjoy!
"At DIC we be printing code ninjas!"
#3
Re: printing text file in landscape
Posted 05 January 2008 - 10:54 PM
Listen to Martyr2, VB.Net added lots for printing. In code you cannot access properties of the printers connected to your pc (or even a Network printer)
Thants why the .Net Framework offered the PrintDialog Class which gives the user the abilit to select what they want. Heres a small example:
Just set the propetties of the PrintDialog Class, one you have the requirements you need call the [url=http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocument.print.aspx]PrintMethod} to print the document.
Hope that helps
Thants why the .Net Framework offered the PrintDialog Class which gives the user the abilit to select what they want. Heres a small example:
Private WithEvents doc As New Printing.PrintDocument ' Set the properties of the PrintDocument 'before showing the dialog Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try ' Setting to tru allows user to select range 'of pager to print 'set to false if you want the user to print whole documdnt only testPrintDialog.AllowSomePages = True ' Show the help button. testPrintDialog.ShowHelp = True ' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set testPrintDialog.Document = doc 'Create property to show the dialog Dim printResults As DialogprintResults = testPrintDialog.ShowDialog() ' If the printResults is OK then print the document. If (printResults = DialogprintResults.OK) Then doc.Print() End If Catch Ex As Exception MessageBox.Show(Ex.Message) End Try End Sub
Just set the propetties of the PrintDialog Class, one you have the requirements you need call the [url=http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocument.print.aspx]PrintMethod} to print the document.
Hope that helps
#4
Re: printing text file in landscape
Posted 06 January 2008 - 07:00 AM
thanks for all the help thus far looks like I got some reading and figguring out to do
been away from vb for a while hard to get back into it when soo many things have changed
thanks a million
been away from vb for a while hard to get back into it when soo many things have changed
thanks a million
PsychoCoder, on 5 Jan, 2008 - 11:54 PM, said:
Listen to Martyr2, VB.Net added lots for printing. In code you cannot access properties of the printers connected to your pc (or even a Network printer)
Thants why the .Net Framework offered the PrintDialog Class which gives the user the abilit to select what they want. Heres a small example:
Just set the propetties of the PrintDialog Class, one you have the requirements you need call the [url=http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocument.print.aspx]PrintMethod} to print the document.
Hope that helps
Thants why the .Net Framework offered the PrintDialog Class which gives the user the abilit to select what they want. Heres a small example:
Private WithEvents doc As New Printing.PrintDocument ' Set the properties of the PrintDocument 'before showing the dialog Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try ' Setting to tru allows user to select range 'of pager to print 'set to false if you want the user to print whole documdnt only testPrintDialog.AllowSomePages = True ' Show the help button. testPrintDialog.ShowHelp = True ' Set the Document property to the PrintDocument for ' which the PrintPage Event has been handled. To display the ' dialog, either this property or the PrinterSettings property ' must be set testPrintDialog.Document = doc 'Create property to show the dialog Dim printResults As DialogprintResults = testPrintDialog.ShowDialog() ' If the printResults is OK then print the document. If (printResults = DialogprintResults.OK) Then doc.Print() End If Catch Ex As Exception MessageBox.Show(Ex.Message) End Try End Sub
Just set the propetties of the PrintDialog Class, one you have the requirements you need call the [url=http://msdn2.microsoft.com/en-us/library/system.drawing.printing.printdocument.print.aspx]PrintMethod} to print the document.
Hope that helps
Page 1 of 1


Ask A New Question
Reply





MultiQuote






|