Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

February 6, 2008

C# to Print a PDF, HTML, MS-WORD, or any type file.

The Chilkat .NET DLL includes a SysUtil class that makes it easy to print from C# or VB.NET.
This example shows how.

The Chilkat.SysUtil class is free.

	
// If displayFlags = 0, no print dialog is shown.
// If displayFlags = 1, a print dialog is shown and the user may
// select a printer and settings.
int displayFlags = 0;
	
string filename = "myReport.pdf";
string operation = "print";
string param = null;
string cwd = System.IO.Directory.GetCurrentDirectory();
	
// Send the file to the default printer.
Chilkat.SysUtil sysUtil = new Chilkat.SysUtil();
bool success = sysUtil.ShellExecuteW(operation, filename, param, cwd, displayFlags);
if (success)
{
MessageBox.Show("Success.");
}
else
{
MessageBox.Show("Failed.");
}
	
/*  Full set of displayFlags for ShellExecuteW:
#define SW_HIDE             0
#define SW_SHOWNORMAL       1
#define SW_NORMAL           1
#define SW_SHOWMINIMIZED    2
#define SW_SHOWMAXIMIZED    3
#define SW_MAXIMIZE         3
#define SW_SHOWNOACTIVATE   4
#define SW_SHOW             5
#define SW_MINIMIZE         6
#define SW_SHOWMINNOACTIVE  7
#define SW_SHOWNA           8
#define SW_RESTORE          9
#define SW_SHOWDEFAULT      10
#define SW_FORCEMINIMIZE    11
#define SW_MAX              11
*/


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.