Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.net Printing with staple

In my project i have to print a liste of images files (.png) with differents settings, and i ca do it without problem using the native .Net System.Drawing.Printing.PrintDocument classe :

  • PrintDocument.DefaultPageSettings.Landscape allow me to change the orientation
  • PrintDocument.DefaultPageSettings.PaperSize allow me to change the papersize to use
  • PrintDocument.DefaultPageSettings.Duplex allow me to change the duplexing mode

The only thing i am not able to do is to define the Stapling property ?? After spending a lot of time of searching, i am very dissapointed on how to do this :

  • Is it possible to do it using the PrintDocument classe and its sub-classes ??
  • Do i have to use a PrintTicket as described in MSDN article ?

But if the solution is to use the print ticket class, i 've two others questions :

  1. How do i attach the printing of an existing image file (using a printjob, a PrintDocument ???)
  2. Are thoses classes only available for using XPS document ?

Important constraint : there is no GUI (because the program prints a lot of files in batch mode), so the user cannot change interactivly the staple option.

like image 599
sstassin Avatar asked Nov 27 '25 04:11

sstassin


1 Answers

Finally, after spending few more hours of search, i've found the right answer to get and set specific printer settings.

Thanks to this Good Article, i did understand that in order to get/set all the settings of a printer, i have to deal with the DevMode structure of the printer.

Drawbacks :

  • the DevMode structure is specific to a driver, and also to an operating system
  • you have to maintain a list of DevMode address for each parameters you want to change

Benefits :

  • you can access all the functions offered by a printer (even printing on tee-shirt, or saving mode....)
  • the project in the link show a small interface to get/set/examine what parameter have been changed using the Pinter Dialog Settings window. So you yan easily by code change on the fly
like image 82
sstassin Avatar answered Nov 28 '25 18:11

sstassin