|
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
namespace CPDFPrinter
{
//we want an abstract base class
abstract class CPrinter
{
protected String _strFileToPrint = "";
protected String strFileToPrint
{
get { return _strFileToPrint; }
set {_strFileToPrint = value; }
}
//save original settings
protected abstract void pushSettings();
//restore original settings
protected abstract void popSettings();
//start printing process
protected void printFile()
{
//Define properties for the print process
ProcessStartInfo procStartInfo = null;
if (File.Exists(_strFileToPrint))
{
procStartInfo = new ProcessStartInfo();
procStartInfo.FileName = _strFileToPrint;
procStartInfo.Verb = "Print";
//Make process invisible
procStartInfo.CreateNoWindow = true;
procStartInfo.WindowStyle = ProcessWindowStyle.Hidden;
//start print process for the file with/from the associated application
System.Diagnostics.Process procPrint = Process.Start(procStartInfo);
//give the system some time
System.Threading.Thread.Sleep(2500);
if (procPrint.Handle != System.IntPtr.Zero)
{
procPrint.WaitForExit();
}
}
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.