Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Modifying a printers default settings from C#

Here's my situation:

  • I'm developing a C# add-in for a 3rd party program
  • This program (Revit) uses its own printing methods and exposes them through its API
  • I am writing a printing utility that uses these methods to print to various locations, including a PDF printer
  • I'm using PDF995 as a printer and modifying its .ini file to automate it.
  • Basically I'm calling the print method in the API which prints the active drawing to a specified printer.

My problem is that on PDF995, if you go to printing preferences in Windows the orientation is by default set to 'portrait'. I need landscape. These settings seem to override anything I set in the Revit API, so I need a way of changing the windows settings.

I've tried this code:

PrintDocument printDocument = new PrintDocument();
printDocument.PrinterSettings.PrinterName = "PDF995";
printDocument.DefaultPageSettings.Landscape = true;

before calling the print function in the API, but it makes no difference. I can't see a way to edit the pdf995 ini to set these settings either. It's a windows setting that I need to override.

I've seen some C++ code on the net I can call to do things with printers but can't find an example of changing the default settings.

Can anyone point me in the right direction?

like image 934
RodH257 Avatar asked Jul 22 '26 07:07

RodH257


1 Answers

I've had good success using these components:

http://www.merrioncomputing.com/Download/PrintQueueWatch/index.htm http://printqueuewatch.codeplex.com/Wiki/View.aspx?title=Home

This collection makes available all sorts of useful printing options. It's mainly focused on monitoring a print queue, but from memory there are options available to change printer settings and job properties.

like image 178
Michael Baker Avatar answered Jul 23 '26 21:07

Michael Baker



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!