Printing & PowerShell; Thoughts?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
zmilbourn
Posts: 8
Last visit: Tue Dec 14, 2021 10:48 am

Printing & PowerShell; Thoughts?

Post by zmilbourn »

Hello all,

I am coming to PS Studio with experience from another development studio (of which I shall omit the name so there's no conflict of interest). In the aforementioned programming suite, I could create a printer canvas object, write text and graphical elements to the object, and then simply send it to the printer on the end user's machine (the user running the application). I have found printing more difficult in PowerShell - and by extension, in PowerShell Studio.

So far, I have tried to print by passing to the MS Word executable, the Wordpad executable, and even the Internet Explorer executable. Although I can get usable printouts using these methods, I find these solutions very "dirty." I am curious if there's any really slick printing solutions that you all are aware of that could be utilized to print "rich text" from an end user's machine, using only PowerShell.

I am not versed in C# or .NET, but I imagine folks would be utilizing System.Drawing.Printing in some way to achieve this. As a self-admitted novice to .NET framework, I am unsure how to work up something from scratch to achieve the aforementioned results ("rich text" printing) via PowerShell

I would love to hear your thoughts on this! Thank you.
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: Printing & PowerShell; Thoughts?

Post by jvierra »

Yes. We use the Net Printing classes to create a graphical context and use standard System.Drawing methods to write into the graphical context (Canvas).

Attached is a simple example.
Attachments
Demo-PrintDocument3.psf
(15.65 KiB) Downloaded 157 times
User avatar
zmilbourn
Posts: 8
Last visit: Tue Dec 14, 2021 10:48 am

Re: Printing & PowerShell; Thoughts?

Post by zmilbourn »

Thanks very much!
This topic is 5 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked