0

I'm having a hard time finding information about this, all of the documentation I find on MSDN/etc is about creating an XPS document and sending it to the printer.

I have a network service that receives files, and all I want to do is send them to the printer. The files are not a specific type - sometimes they will be Word docs, sometimes PDF, sometimes photos. Is there not any way to just send an arbitrary file to the printer?

This is a WPF library, btw.

EDIT:

To further clarify, I do not know what type of file it is - it is just a binary stream keyed to a token. The problem with the shell solution is that it relies on the file extension to determine how to print the file, if you try to pass an extensionless file it will give an error.

amnesia
  • 1,956
  • 2
  • 18
  • 36

1 Answers1

0

Chuck Savage has written a nifty extension method for this:

/// <summary>
/// Print the file
/// </summary>
/// <param name="value"></param>
public static void Print(this FileInfo value)
{
    if (!value.Exists)
        throw new FileNotFoundException("File doesn't exist");
    Process p = new Process();
    p.StartInfo.FileName = value.FullName;
    p.StartInfo.Verb = "Print";
    p.Start();
}
Community
  • 1
  • 1
Nathan Cooper
  • 6,262
  • 4
  • 36
  • 75