I saw a lot of messages about setting up the printer tray in C # for a text document. I need a solution for Excel.
The best solution, if possible, for any document. Some method I can pass the file path and tray.
EDIT So far I have tried the following, but there have been no changes to the printer settings.
PrinterSettings ps = new PrinterSettings(); ps.PrinterName = @"\\localhost\HP-4515n"; var dps = ps.DefaultPageSettings; dps.PaperSource.RawKind = 260;
OR
PrinterSettings ps = new PrinterSettings(); ps.PrinterName = @"\\localhost\HP-4515n"; PaperSource psrc = new PaperSource(); psrc.RawKind = 260; psrc.SourceName = "unknown"; dps.PaperSource = psrc;
EDIT 2
I am hardcoding RawKind, since the tray is somehow not showing up in the documents.
And now, when I type, for example. In an Excel document, I show PrinterDialog, get the name of the selected printer and pass it on to interact with the active property of the Excel printer. But now I need to print a ton of documents, and I need to install the selected printer and its property specifically in the tray programmatically.
c # printing interop
sysboard
source share