静默打印.pdf和.tif文件,不会弹出任何窗口 [英] Print .pdf and .tif files silently without any pop-up
问题描述
我正在尝试在Windows应用程序中使用C#打印.pdf和.tif文件.打印成功完成了.但是我的问题是Adobe阅读器在后台打开了pdf文件,而Windows打印对话框打开了tif文件.我的方法使用服务.因此,这些过程应该静默进行.为避免这种情况,我必须做些什么.我确实需要帮助.
这是我的代码
Am trying to print .pdf and .tif files using C# in windows application.Printing is done successfully.But my problem is Adobe reader is opening in background for pdf files and windows print dialogue opens for tif files.Actually i will run my method using a service.So these process should occur silently.What i have to do to avoid this .i am really in need of help.
Here is my code
public void PrintDocument(string filepath)
{
//PrintDialog pd = new PrintDialog();
printProcess.StartInfo.FileName = filepath;
//Also tried usecellexcecution=false;
//Redirect=true; something like this
printProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
printProcess.StartInfo.Verb = "Print";
printProcess.StartInfo.CreateNoWindow = true;
PrinterSettings setting = new PrinterSettings();
setting.DefaultPageSettings.Landscape = true;
printProcess.Start();
printProcess.CloseMainWindow();
}
我也尝试使用MSDN中建议的RawprinterHelper.但是它会打印垃圾字符.
Also i try to use RawprinterHelper suggested in MSDN.But it prints junk characters.
推荐答案
您可以使用默认设置:
you can use the default setting :
doc.PrintController = new StandardPrintController();
doc.Print();
也许该链接会为您提供帮助:
http://social.msdn.microsoft.com/论坛/en-US/csharpgeneral/thread/8ce3dd94-ff2c-4c3c-ba85-f67b9dd2f2e8 [
and maybe that link will help you :
http://social.msdn.microsoft.com/forums/en-US/csharpgeneral/thread/8ce3dd94-ff2c-4c3c-ba85-f67b9dd2f2e8[^]
regards..
这篇关于静默打印.pdf和.tif文件,不会弹出任何窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!