I\'m trying to silently print a picture file and i need to print it on special paper type (\"Glossy Photo Paper\"), and on certain size (10cm on 15cm).
On normal windows
I'm not saying that it is impossible, but its not going to be pretty. Theoretically you can get the DEVMODE structure of the device( that structure will have extensions that are specific to the printer driver) set the correct values, and then write it back. There are some helper functions the the PrinterSettings object to do this. There is an example of doing that here
This can actually be done without DEVMODE. Set the paper type via PrintTicket.PageMediaType property. For example:
// ---------------------- GetPrintTicketFromPrinter -----------------------
/// <summary>
/// Returns a PrintTicket based on the current default printer.</summary>
/// <returns>
/// A PrintTicket for the current local default printer.</returns>
public PrintTicket GetPrintTicketFromPrinter()
{
PrintQueue printQueue = null;
var localPrintServer = new LocalPrintServer();
// Retrieving collection of local printer on user machine
PrintQueueCollection localPrinterCollection = localPrintServer.GetPrintQueues();
System.Collections.IEnumerator localPrinterEnumerator =
localPrinterCollection.GetEnumerator();
if (localPrinterEnumerator.MoveNext())
{
// Get PrintQueue from first available printer
printQueue = (PrintQueue)localPrinterEnumerator.Current;
}
else
{
// No printer exist, return null PrintTicket
return null;
}
// Get default PrintTicket from printer
PrintTicket printTicket = printQueue.DefaultPrintTicket;
PrintCapabilities printCapabilites = printQueue.GetPrintCapabilities();
// Modify PrintTicket
if (printCapabilites.PageMediaTypeCapability.Contains(PageMediaType.CardStock))
{
printTicket.PageMediaType = PageMediaType.CardStock;
}
return printTicket;
}