Solved

printDocument in vb.net

Posted on 2013-01-22
9
1,546 Views
Last Modified: 2013-01-29
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
Comment
Question by:Nettodotnet
  • 5
  • 3
9 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38806218
What are you trying to print?
0
 
LVL 19

Expert Comment

by:Amandeep Singh Bhullar
ID: 38806248
Have you checked the contents of file at 'c:\TEMP\TestT.rtf'
0
 

Author Comment

by:Nettodotnet
ID: 38806256
kaufmed : Iam trying to print a rtf file.
 AmanBhullar: yes it has 2 pages content.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38806317
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
 

Author Comment

by:Nettodotnet
ID: 38806510
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 38806673
Are you running the application as a user who has access to that path?
0
 

Author Comment

by:Nettodotnet
ID: 38806842
Iam creating a TEMP file under each user:
C:\\TEMP\TestT.rtf"
0
 

Accepted Solution

by:
Nettodotnet earned 0 total points
ID: 38815454
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
 

Author Closing Comment

by:Nettodotnet
ID: 38830325
i reasearched my self
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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

816 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now