Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Print to File in C#

Posted on 2013-06-27
7
Medium Priority
?
1,366 Views
Last Modified: 2013-07-09
Hi, I'm using C#.NET 2010. I am using the PrintDialog Object and would like to print to a file rather than to the printer. When I select the "Print to File" checkbox, I can't find where it's creating the new file. Where does the Print to File option go?

I have it printing to the printer, but am struggling with "print to file" part.

I only have an option to give the file a name not to select a path. How can I select the path?

An example would be very helpful.

Thank you,
Fulano
0
Comment
Question by:Mr_Fulano
  • 3
  • 2
  • 2
7 Comments
 
LVL 30

Expert Comment

by:anarki_jimbel
ID: 39283282
You need to set thepath:

        printD.PrinterSettings.PrintToFile = true;
        printD.PrinterSettings.PrintFileName = @"c:\temp\test.txt";

See the solution here:

http://stackoverflow.com/questions/9675494/vb-net-printdialog-print-to-file
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39283284
Try setting the PrintFileName property to your file name.

e.g.

printDialog1.PrinterSettings.PrintFileName = @"C:\Users\Kenneth\Desktop\test.ps";

Open in new window

0
 

Author Comment

by:Mr_Fulano
ID: 39287176
I was able to get it to print to a file, but the text comes out garbled. It seems you need to have a printer set up that allows for plain text printing and even that does not produce an exact representation of you original file.

Any thoughts on that?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 39287193
Print to file prints Postscript files. It does not print text files. See: http://windows.microsoft.com/en-us/windows-vista/print-to-file
0
 

Author Comment

by:Mr_Fulano
ID: 39287199
Hi Kaufmed, I understand that now after a lot of struggling with the file. The print to file produces an XPS file format. So, the magic questions become, how do you read that and how you print that?

It does me no good to have a file version of my document that I cannot read or print.

I tried MS Word, MS WordPad, Adobe Reader X, Internet Explorer,  and of course NotePad. but none of those will work. So, what is the magic application that Microsoft uses for this?
0
 
LVL 75

Assisted Solution

by:käµfm³d 👽
käµfm³d   👽 earned 1000 total points
ID: 39287233
Download the XPS viewer.
0
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 1000 total points
ID: 39288694
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

916 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