In one of my previous posts, I have discussed how to download and print a remote file. Here is the blog link
http://www.navisionworld.com/2017/09/how-to-print-remote-file-from-nav.html
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.
https://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.verbs(v=vs.110).aspx
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]); VAR PrinterName@1240060002 : Text; PrintDocument@1240060003 : DotNet "'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Printing.PrintDocument"; PrinterSettings@1240060004 : DotNet "'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.System.Drawing.Printing.PrinterSettings"; BEGIN PrinterName := 'MF8200C Series'; PrintDocument := PrintDocument.PrintDocument; PrintDocument.DocumentName := FilePath; PrinterSettings := PrinterSettings.PrinterSettings; PrinterSettings.PrinterName := PrinterName; PrintDocument.PrinterSettings := PrinterSettings; PrintDocument.Print; MESSAGE('Complete'); END;
If you have any other tips or suggestions, please do share them in the comments below.
15 comments:
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
Arndt,
I ran into same issue for some printers, I will review and let you know if i find a solution.
Thanks
Suresh
amazing !!! good work. keep it up.
find Best printer from here.
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?
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.
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.
Thanks for sharing the blog with us. Learn how to get your printer online with Printerofflinefix.us. For the more details you have to do just one click How Do I Get My Printer Online
Good to know about the printers. If you are looking for the cnc 3d printer for sale then, febtop.com is deals in the quality products.
Thanks for the feature description.
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 optimus3dp.com. Visit here 3 in 1 3D Printer
This is an awesome post. Really very informative and creative
printer service center in omr
New web site is looking good. Thanks for the great effort. wholesale label printing
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 optimus3dp.com.
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
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 Maverick3dp.com is a good choice.
Post a Comment