Sprache: C#
Mit diesem Snippet kann man beliebige Dateien drucken.
BSP: PrintFile("D:\Test\Test.pdf");
/// <summary>
/// Prints the file.
/// </summary>
/// <param name="fullPath">The full path.</param>
private static void PrintFile(string fullPath)
{
FileInfo fileInfo = new FileInfo(fullPath);
if(!fileInfo.Exists)
{
throw new FileNotFoundException();
}
var printProcess = new Process();
printProcess.StartInfo.FileName = fullPath;
printProcess.StartInfo.UseShellExecute = true;
printProcess.StartInfo.Verb = "print";
printProcess.Start();
}
/// <summary>
/// Prints the file.
/// </summary>
/// <param name="fullPath">The full path.</param>
private static void PrintFile(string fullPath)
{
FileInfo fileInfo = new FileInfo(fullPath);
if(!fileInfo.Exists)
{
throw new FileNotFoundException();
}
var printProcess = new Process();
printProcess.StartInfo.FileName = fullPath;
printProcess.StartInfo.UseShellExecute = true;
printProcess.StartInfo.Verb = "print";
printProcess.Start();
}
Alte URL:
/snippet/beliebige-dateien-drucken/1061
Unschöner Nebeneffekt ist allerdings, dass beim Drucken von PFDs der AcrobatReader nach dem Druck geöffnet bleibt ….
Gibt es eine Möglichkeit hier auch den Namen eines Druckers anzugeben?
Schau mal, vielleicht hilft dir das ja:
http://ss64.com/nt/print.html