We have an application that basically archives files and we give the user the possibility to print these files. They can be .txt, .doc, .pdf, .jpg nothing fancy. Is there a
It's actually very, very easy.
Use System.Drawing.Printing.PrintDocument.
Follow the example in that link, or just use the code here (which I excerpted from something doing print automation I'm using every day).
for example, to print off a .jpg (BTW, this won't open any editing application; it spools to the printer in the background)
public void SetupPrintHandler()
{
PrintDocument printDoc = new PrintDocument();
printDoc.PrintPage += new PrintPageEventHandler(OnPrintPage);
printDoc.Print();
}
private void OnPrintPage(object sender, PrintPageEventArgs args)
{
using (Image image = Image.FromFile(@"C:\file.jpg"))
{
Graphics g = args.Graphics;
g.DrawImage(image, 0, 0);
}
}