Add Reference to PDF Sharp. First inform PdfFilePrinter about path of Adobe reader exe on target machine.
PdfFilePrinter.AdobeReaderPath = @"C:\Program Files\Adobe\Reader 8.0\Reader\AcroRd32.exe";
///Then in next step create a instance of the class PdfFilePrinter and provide path of file to print and your default active printer.
try
{
PdfFilePrinter Pdfprinter = new PdfFilePrinter(filetoprint, printer);
Pdfprinter.Print();
}
catch(Exception ex)
{
throw ex;
}
Now get the Adobe Process and kill it if it has finished its job.
foreach (Process proc in Process.GetProcesses())
{
if (proc.ProcessName.StartsWith("Acro"))
{
if (proc.HasExited == false)
{
proc.WaitForExit(10000);
proc.Kill();
break;
}
else
{
proc.Kill();
break;
}
}
}
if you have any question please free to ask. Hope this helps.
Thanks for posting this!
ReplyDeleteDear Waqar,
ReplyDeleteIf the printer is not a real printer but needs a provide a file name (like something print to file's type printer driver) then what to do?
Please help. Thanks
Yeong Shih
Dear Yeong
ReplyDeleteIf you want to print using Virtual or Type printer just set that printer as your default printer from printer settings. and run the code it will ask for the file name and location to save
hi i need to print a pdf document without showing a acrobat reader . your solution can lead to a problem because it will kill all the process which are acobat related that i dont want . Can you provide another soltiion
ReplyDeleteHi,unfortunately this didn' worked for me, I have tried a few solutions also and the one I like the most is CLPRINT tool. Take a look at http://commandlinepdf.com/
ReplyDeleteThis comment has been removed by the author.
Deletec# acrobat print pdf with comments is the most helpful software can be download on rasteredge page http://www.rasteredge.com/how-to/csharp-imaging/pdf-annotate-sticky-note/
ReplyDelete