Sunday, January 14, 2018

Print the document to a specific printer


In one of my previous posts, I have discussed how to download and print a remote file. Here is the blog link

The solution in the above post will print the file to the default printer and recently I was working on a modification where I have to print the file to a specific printer instead of the default printer and couple of readers of my blog post also asked how to do this, so I would like to share today the solution for it.

I was checking online to modify my old solution to print to a specific printer and few suggested to me to use the arguments property of the ProcessStartInfo and also the below MSDN example suggests the same, but unfortunately, I was not successful using that property.


To solve this issue I have found another solution which is to use the Print Document and in fact, I think this is an easy solution when compared to the other solution in my previous post.

Below is the function for it.

PROCEDURE PrintFile@1000000018(FilePath@1000000002 : Text[250]);


PrinterName@1240060002 : Text;

PrintDocument@1240060003 : DotNet "'System.Drawing, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Printing.PrintDocument";

PrinterSettings@1240060004 : DotNet "'System.Drawing, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Printing.PrinterSettings";


PrinterName := 'MF8200C Series';

PrintDocument := PrintDocument.PrintDocument;

PrintDocument.DocumentName := FilePath;

PrinterSettings := PrinterSettings.PrinterSettings;

PrinterSettings.PrinterName := PrinterName;

PrintDocument.PrinterSettings := PrinterSettings;




If you have any other tips or suggestions, please do share them in the comments below.


Arndt Loermann said...

Hey Suresh Kulla, thank you for your post. we try it out with txt files and pdf file, but the output is only a white paper with some black points in the header and footer area of the output.

any idea for solution or what we can check to print the files correctly ?

thank you in advance
Arndt Loermann

Suresh Kulla said...


I ran into same issue for some printers, I will review and let you know if i find a solution.


Anthony Paul said...

amazing !!! good work. keep it up.
find Best printer from here.

Tizer said...

Hi mate,
Your code for this help me a lot.

Can you tell me why I can't access my printer? Says "A call to System.Drawing.Printing.PrintDocument.Print failed with this message: Settings to access printer 'xxxxx' are not valid.

There is anything that you can tell me in order to fix it?

Rishi said...

Hi Suresh,

Thanks a lot for sharing this great Blog.
Could you please share the solution of White Paper Issue which is shared by @Arndt Loermann.
It would be very useful for all of us.

Unknown said...

Contact HP Support Assistant Number helps keep your computer updated and secure in Windows 10, 8, and 7.
Is your hp printer not printing the black electronic data stream? Then you must ask our technical team why is my printer not printing.

Printer Offline Fix said...

Thanks for sharing the blog with us. Learn how to get your printer online with For the more details you have to do just one click How Do I Get My Printer Online

FEBTOP said...

Good to know about the printers. If you are looking for the cnc 3d printer for sale then, is deals in the quality products.

Backup said...

Thanks for the feature description.

Anonymous said...

I think I have never seen such blogs ever before that has complete things with all details which I want. Buy the best quality Hybrid 3D Printer on Visit here 3 in 1 3D Printer

tamil selvan said...

This is an awesome post. Really very informative and creative
printer service center in omr

Terri Meeks said...

New web site is looking good. Thanks for the great effort. wholesale label printing said...

Thanks for nice and informative post. This article is really contains lots of valuable information. For the Hybrid 3D Printer CNC you have to visit on

13IT Australia said...

Thanks for sharing information. Choosing computer accessories from leading IT store offer great discount and value for your money Computer Store Australia | Buy Printers Online

Maverick 3D Printing said...

I really want to thank the author for such a nice blog that helped me to understand why it is important. If you are looking for 3d printer in USA then is a good choice.

magictradingco said...

A very delightful article that you have shared here. Your blog is a valuable and engaging article for us, and also I will share it with my companions who need this info. Thankful to you for sharing an article like this.6 Heads American Screen Printing Machine

Adam parker said...

Nice Information , Thanks For The Great Content

Get started to Install, Setup, Connect, Print from your 123 hp setup printers. Easy to Download driver & Printer software from HP Envy,HP Officejet,HP Officejet Pro,HP Deskjet Printer Setup Driver Installation

For More Support|123hp com/oj8049|| | ojpro|ojpro6968|

The Ink Supplies said...

Nice article, which you have shared here. Your article is very informative and I liked your way to express your views in this post. The article you have shared here is very informative and the points you have mentioned are very helpful. Thanks for sharing this article here. Ink Supplies

Smart austo said...

Nice Information , Thanks For The Great Content
Get started Hp printer software install and setup .you can install 123 HP OJ4650 Setup from|ojpro6968
|| || ojpro

aaronssd said...

This is a smart blog. I would not joke about this. You have fantastic information about this theme. A debt of gratitude is in order for sharing a particularly extraordinary online journal to us. 3d printing service

Mary James said...

You've supplied us with an interesting article about Epson Sublimation Printer Ink Online India. This is a fantastic resource for expanding your understanding of the subject. Thank you very much.