A way to send direct to printer, but, have to install on the computer the Acrobat Reader (or similar).
Example:
Configure the first 4 lines using local settings on your computer
string NomedaImpressora = "Microsoft XPS Document Writer";
string CaminhoeNomedoArquivo = @"C:\Temp\Exemplo.pdf";
string CaminhoDoAcrobat = @"C:\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe";
string DiretorioTemp = @"c:\Temp\Pdf";
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = CaminhoDoAcrobat;
startInfo.Arguments = string.Format("/t \"{0}\" \"{1}\"",
CaminhoeNomedoArquivo,
NomedaImpressora);
startInfo.CreateNoWindow = true;
startInfo.ErrorDialog = false;
startInfo.UseShellExecute = false;
startInfo.WorkingDirectory = DiretorioTemp;
Process process = Process.Start(startInfo);
process.WaitForInputIdle();
process.CloseMainWindow();
process.Close();
process.Dispose();
the process works until satisfactory by the tests performed.
Reference: MSDN Forum - Print PDF direct p/ printer
In a geal way it is not possible, nor has any advantage to do it. What you can do is use something ready to open and print. You’re not seeing it, but it’s being opened.
– Maniero
@bigown, the idea is as follows. The user schedules an appointment for a patient and the system asks: want to print proof? positive case already sends to printer, without needing to open the pdf and click on the print button.
– Italo Rodrigo
This does not change anything, what is the difference to open and then print?
– Maniero
Just a request from users (not to have to click twice). If it is not possible to do, I will leave as is
– Italo Rodrigo
Take away the need to double click on your application, you have control over it.
– Maniero
I didn’t quite understand, you can explain better?
– Italo Rodrigo
I think I get it now, you’re opening an external PDF reader. I hadn’t really thought about it. It’s not even a C# problem then. There you have to see how to send this reader that is being used to make the impression without user intervention and send this command the way you are doing.
– Maniero
i create the file using iTextSharp, and open it using the standard PDF reader through the above code.
– Italo Rodrigo
As I said, it’s not a problem of C#, nor of programming, it’s knowing how to have this reader print automatically. You always put tags that are not of the problems then confuses.
– Maniero
@bigown, sorry, I’m still learning.
– Italo Rodrigo
if you can, give an edited one to my post and put a more appropriate tag
– Italo Rodrigo
Actually I think this isn’t even a programming problem, it’s knowing how to manipulate this specific reader, how to send the command you know.
– Maniero
Thanks for the help, @Virginio Novic give me the code
– Italo Rodrigo