打印文档而不显示PrintDialog [英] Print a document without show PrintDialog

查看:118
本文介绍了打印文档而不显示PrintDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨:)



我有一个包含10个pdf的文件夹,而且,我想知道如何在不显示printdialog的情况下打印这10个PDF文件pdf,类似这样:



  public   void  PrintAllDocuments()
{
string [] AllFiles = Directory.GetFiles( @ C:\PDF \ < span class =code-string> * .pdf,SearchOption.AllDirectories);

for int i = 0 ; i < AllFiles.Length; i ++)
{
PrintFile pf = new PrintFile(AllFiles [i]);
pf.printerName = HP ???;
pf.paper = A4;
pf.Print();
}
}





当然,这是一些样本...但是,我如何配置打印机并打印文档,无需使用PrintDialog ...打开PDF并打印PDF,我该怎么做? :(



感谢您的帮助。:)

解决方案

将printDocument控件添加到您的表单并使用例如

  this  .printDocument1.DocumentName =  @   c:\document1.pdf; 
this .printDocument1.Print();



参见http://msdn.microsoft.com/en-us/library/system.drawing。 printing.printdocument(VS.71).aspx [ ^ ]了解更多详情



好​​的 - 上面的所有内容都很好但不适用于Adobe产品 - 即PDF格式。



以下链接将更有用......

用c#打印pdf文件 [ ^ ]





http://bytes.com/topic/c- sharp / answers / 247935-pdf-printing-c [ ^ ]



我想要更好地了解http://itextpdf.com/ [ ^ ]


Hi :)

I have a folder with 10 pdfs, and, I whant to know how I can print this 10 pdfs without show the printdialog, for all pdfs, something like this:

public void PrintAllDocuments()
        {
            string[] AllFiles = Directory.GetFiles(@"C:\PDF\", "*.pdf", SearchOption.AllDirectories);

            for (int i = 0; i < AllFiles.Length; i++)
            {
                PrintFile pf = new PrintFile(AllFiles[i]);
                pf.printerName = "HP ???";
                pf.paper = "A4";
                pf.Print();
            }
        }



of course, that is some a sample... but, How I can configure the printer and print the document, witout use the PrintDialog... to open the PDF and print the PDF, how I can do this ??? :(

Thanks for help. :)

解决方案

add a printDocument control to your form and use that e.g.

this.printDocument1.DocumentName = @"c:\document1.pdf";
this.printDocument1.Print();


See also http://msdn.microsoft.com/en-us/library/system.drawing.printing.printdocument(VS.71).aspx[^] for more details

Ok - everything above here is fine but not for Adobe products - i.e. PDFs.

The following links will be more useful...
Printing pdf files with c#[^]

or
http://bytes.com/topic/c-sharp/answers/247935-pdf-printing-c[^]

and I''m off to have a better look at http://itextpdf.com/[^]


这篇关于打印文档而不显示PrintDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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