Send string directly to a printer with interop

BeliasBelias Member Posts: 2,998
Hi guys,
I need to directly send a string to a printer (a zebra, but it's not that important) through .net interoperability. I dug internet but what i found is this c# that i am not able to translate into nav, because there's the PrintPage event that i don't know how translate in nav. Any clue?

public void Print(string PrinterName)
{
PrintDocument doc = new PrintDocument();
doc.PrinterSettings.PrinterName = PrinterName;
doc.PrintPage += new PrintPageEventHandler(PrintHandler);
doc.Print();
}

private void PrintHandler(object sender, PrintPageEventArgs ppeArgs)
{
Font FontNormal = new Font("Verdana", 12);
Graphics g = ppeArgs.Graphics;
g.DrawString("Your string to print", FontNormal, Brushes.Black, xpos, ypos, new StringFormat());
}

Just for the record (techy stuff): why doing this stuff instead of printing a report with a single textbox to the desired zebra printer?
because i need to get this work on a webclient. Althought i worked around the fact that "webclient only prints to pdf if there's no request page" through a STARTSESSION command, i found out that doing a "REPORT.PRINT(.....)" in a start session prints a pdf and then sends the pdf to the desired printer. This screws up the text in my textbox and my zebra prints zpl code instead of the correct label.
-Mirko-
"Never memorize what you can easily find in a book".....Or Mibuso
My Blog

Best Answer

Answers

Sign In or Register to comment.