I am trying to perform a very simple operation:
Get a list of local printers, allow the user to choose (Got it)
Select envelope tray for manual feed
Enter the customer address for the specific envelope size (4 1/8 x 9 1/2/03982) on the printer with manual envelope feed.
I have no experience with the System.Drawing.Printing class, so please forgive my ignorance of the topic.
I am fooling myself with the code that I found below, I was playing with: Rectangle(20, 20, 200, etc.));but could not figure out how to subtract it to the appropriate supply or get an envelope tray.

EDIT - Working Code (Thanks icemanind for pointing me in the right direction.
foreach (String printer in PrinterSettings.InstalledPrinters) {
printersList.Items.Add(printer.ToString());
}
private void btPrint_Click(object sender, EventArgs e)
{
var pd = new PrintDocument();
pd.PrinterSettings.PrinterName = printersList.SelectedItem.ToString();
pd.DefaultPageSettings.Landscape = true;
pd.DefaultPageSettings.PaperSize.RawKind = 6;
pd.PrintPage += pd_PrintPage;
pd.Print();
}
public void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
var vnId = Lnq.Orders.Where(a => a.ID == OrdId).Select(a => a.fk_ClientAttID).FirstOrDefault();
var a = Lnq.Clients.Where(a => a.ID == vnId).Select(a => new {a.Name, a.Addy1, a.City, a.State, a.Zip});
foreach (var v in e)
{
var g = ev.Graphics;
var font = new Font("Arial", 12);
var brush = new SolidBrush(Color.Black);
g.DrawString(a.Name + "\n" + a.Addy1 + "\n" + a.City + ", "
+ a.State + " " + a.Zip, font, brush,
new Rectangle(500, 400, 650, 650));
}
}
source
share