The following code is in C#.
// Print TIF file
PrintDocument printDocument = new PrintDocument();
printDocument.PrinterSettings.PrinterName = printerIdentifier;
printDocument.PrintPage += new PrintPageEventHandler(printDocument_PrintPage);
printDocument.Print();
/// <summary>
/// This event occurs when the output to print for the current page is needed
/// </summary>
/// <param name="sender">sender</param>
/// <param name="e">an argument of type PrintPageEventArgs containing data related to this event</param>
private static void printDocument_PrintPage(object sender, PrintPageEventArgs e)
{
try
{
Graphics g = e.Graphics;
Stream fs = File.OpenRead(_fileName);
Image image = Image.FromStream( fs, true ) ;
g.DrawImage(image,0,0);
fs.Close();
}
catch(Exception ex)
{
...
}
}
No comments:
Post a Comment