This doesn't require a library, but it does require you to have Adobe Reader DC on the machine the application is on. If you don't want to use any type of external tool then you'll need to create your own functionality to do this. Adobe Reader DC can be invoked with a command to allow you to print the document. This isn't an elegant solution at all for error handling or closing the process, but it's a skeleton that you can tweak:
private static void PrintDocument(string fileName)
{
var process = new Process
{
StartInfo =
{
WindowStyle = ProcessWindowStyle.Hidden,
Verb = "print",
FileName = @"C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe", //You could use an app config string here
Arguments = $@"/p /h {fileName}",
UseShellExecute = false,
CreateNoWindow = true
}
};
process.Start();
if (process.HasExited == false)
{
process.WaitForExit(10000);
}
process.EnableRaisingEvents = true;
try
{
//Try to gracefully exit the process first
var proccessIsClosed = process.CloseMainWindow();
//If it doesn't gracefully close, kill the process
if (!proccessIsClosed)
{
process.Kill();
}
}
catch
{
throw new Exception("Process ID " + process.Id +
" is unable to gracefully close. Please check current running processes.");
}
}