• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1853
  • Last Modified:

printDocument in vb.net

Here is my code:

                            Dim printDocument1 As New PrintDocument()
                            Dim Printd As New PrintDialog()
                            Dim res As DialogResult = Printd.ShowDialog()

                            printDocument1.DocumentName = "c:\TEMP\TestT.rtf"                            Printd.Document = printDocument1
                            Printd.AllowSomePages = True
                            Printd.ShowHelp = True

                            If (res = DialogResult.OK) Then
                                printDocument1.Print()
                            End If


When it print just printing with blank paper.
What iam doing wrong?
0
Nettodotnet
Asked:
Nettodotnet
  • 5
  • 3
1 Solution
 
käµfm³d 👽Commented:
What are you trying to print?
0
 
Amandeep Singh BhullarCommented:
Have you checked the contents of file at 'c:\TEMP\TestT.rtf'
0
 
NettodotnetAuthor Commented:
kaufmed : Iam trying to print a rtf file.
 AmanBhullar: yes it has 2 pages content.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
käµfm³d 👽Commented:
With PrintDocument you have to do all of the drawing to the page yourself. What you are attempting to do now will not work. You can certainly do the work to print the RTF document using PrintDocument if you like, but I think you would find it easier to use the Process class and pass the "Print" verb.

e.g.

Dim printer As New System.Diagnostics.Process()

printer.StartInfo.FileName = "C:\path\to\file.rtf"
printer.StartInfo.Verb = "Print"
printer.Start()

Open in new window

0
 
NettodotnetAuthor Commented:
I try with below code too...
                    Dim p As New Process
                    p.StartInfo.FileName = "C:\\TEMP\TestT.rtf"
                    'p.StartInfo.WindowStyle = Diagnostics.ProcessWindowStyle.Hidden
                    p.StartInfo.Verb = "print"
                    p.Start()

This is working fine on my local box ..But when i deployed into teat server this is not working.
Printing is not working.
0
 
käµfm³d 👽Commented:
Are you running the application as a user who has access to that path?
0
 
NettodotnetAuthor Commented:
Iam creating a TEMP file under each user:
C:\\TEMP\TestT.rtf"
0
 
NettodotnetAuthor Commented:
I figured out it:
here are the steps:

Converting RTF to PDF by using 3rd party DLL's.
Lading pdf into IFRAME
Printing from the IFRAME.
0
 
NettodotnetAuthor Commented:
i reasearched my self
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 5
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now