打印机坐着使用C# [英] Printer sittings using C#

查看:88
本文介绍了打印机坐着使用C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我正在尝试使用以下代码更改打印机坐位,当按下按钮时它正在打印但是打印机没有改变,打印机是共享打印机而我给了用户权限改变坐着。有什么想法请求?



我尝试过:



Hi,
I am trying to change printer sittings using the below code, when press on button it is printing but printer sittings not changed , the printer it is shared printer and i gave permissions for user to change the sittings.any idea pleas?

What I have tried:

 private void button1_Click(object sender, EventArgs e)
        {
                   string exeFolder = Application.StartupPath;
                   string Filepath = Path.Combine(exeFolder, @"Form.pdf");
                    Process printjob = new Process();
                    printjob.StartInfo.FileName = Filepath;
                    printjob.StartInfo.Verb = "Print";
                    printjob.StartInfo.CreateNoWindow = true;
                    printjob.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
                    PrinterSettings ps = new PrinterSettings();
                   PrintDocument printdoc= new PrintDocument();
                   printdoc.PrinterSettings = ps;
                   IEnumerable<PaperSize> paperSizes = ps.PaperSizes.Cast<PaperSize>();
                   PaperSize sizeA4 = paperSizes.First<PaperSize>(size => size.Kind == PaperKind.A4);
                    printdoc.DefaultPageSettings.PaperSize = sizeA4;
                    PaperSource oPSource = new PaperSource();
                    oPSource.RawKind = (int)PaperSourceKind.Lower;
                    printdoc.DefaultPageSettings.PaperSource = oPSource;
                    printdoc.PrinterSettings.Copies = 2;            
                    printjob.Start();
}

推荐答案

您正在使用外部流程打印PDF文件。该过程将使用它自己的打印设置并自行进行打印。



您的PrintDocument代码无用,因为它仅适用于您自己的应用程序内的打印,当您的代码执行时实际渲染到PrintDocument页面。这些类在外部进程执行打印时根本不起作用。



您无法控制外部应用程序如何打印PDF。
You're using an external process to print a PDF file. That process will use it's own print settings and do the printing itself.

Your PrintDocument code is useless as it only applies to printing inside your own application, when your code does the actual rendering to a PrintDocument page. These classes will not work at all with an external process doing the printing.

You have no control at all over how the external application prints the PDF.


这篇关于打印机坐着使用C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆