0

ASP.NET 4.5, c#, VS2013

I have a windows form application in c#. The application creates a pdf and I wanted to print it to a specific printer. I could do:

axAcroPDF1.printWithDialog()

and user selects a printer from the list.

But my users do not like this at all. The preferred printer in this case is way back in the list and they want this to be the default printer for this program only.

I am not able to see a default printer like property in axAcroPDF and I do not know how to set the default printer for this windows application only.

Please advise an optimum solution. I did not expect this to get so complicated. Thanks,

OlivierH
  • 3,875
  • 1
  • 19
  • 32
  • I put together the following workaround: Use axAcroPDF to show the PDF disabling the toolbar PrintDialog to print the PDF where my desired printer is the 1st in the list of available printer. – user3285061 Jul 03 '14 at 16:09

1 Answers1

0

I don't think you can set the default printer per application, only per user. (I'm all ears if this is not the case!)

You could try programmatically getting the default printer, setting it to what you require, and then setting it back to its original value once you're done with your PDF. You can accomplish this with the Windows API using SetDefaultPrinter and GetDefaultPrinter.

You'll need to know how to make Windows API calls from C#. Have a look at pinvoke if you're not sure where to start.

Gareth
  • 2,746
  • 4
  • 30
  • 44
  • Thanks Gareth, I will check out pinvoke. Just to rephrase my problem: I do not want to change the default printer but to print the PDF to a specific printer. – user3285061 Jul 03 '14 at 14:20
  • I realise that, but if your print function only allows you to print to the default printer (without showing the print dialog) then you may have to resort to temporarily changing the default printer to get what you want ( I seem to recall there was a function that silently prints to the default printer) – Gareth Jul 03 '14 at 14:36