是否可以通过c#activex直接打印独立的html页面? [英] Is it possible to print a stand alone html page directly through c# activex?
本文介绍了是否可以通过c#activex直接打印独立的html页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以通过c#activex打印独立的html页面而无需打印对话框。
i不想显示打印对话框我想静默打印html页面。
如果有可能.....帮助我....
Is it possible to print stand alone html page without print dialog through c# activex.
i don't want to show print dialog i want to print html page silently.
if it is possible..... help me....
推荐答案
我不想显示打印对话框我想要默默地打印html页面。
我真的不能想到任何合理的理由这样做。
c #activex。
你是一种特殊的邪恶。哈哈。
哦,这就是你想要的东西。
"i don't want to show print dialog i want to print html page silently."
I can't really think of any legitimate reason to do this.
c# activex.
You are a special kind of evil. haha.
Oh, here is what you are looking for i think.
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PdfPrinter
{
class Program
{
static void Main(string[] args)
{
string[] files = Directory.GetFiles(@"c:\temp");
foreach (string file in files.Where(
file => file.ToUpper().Contains(".PDF")))
{
Pdf.PrintPDFs(file);
}
}
}//END Class
public class Pdf
{
public static Boolean PrintPDFs(string pdfFileName)
{
try
{
Process proc = new Process();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
proc.StartInfo.Verb = "print";
//Define location of adobe reader/command line
//switches to launch adobe in "print" mode
proc.StartInfo.FileName =
@"C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe";
proc.StartInfo.Arguments = String.Format(@"/p /h {0}", pdfFileName);
proc.StartInfo.UseShellExecute = false;
proc.StartInfo.CreateNoWindow = true;
proc.Start();
proc.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (proc.HasExited == false)
{
proc.WaitForExit(10000);
}
proc.EnableRaisingEvents = true;
proc.Close();
KillAdobe("AcroRd32");
return true;
}
catch
{
return false;
}
}
//For whatever reason, sometimes adobe likes to be a stage 5 clinger.
//So here we kill it with fire.
private static bool KillAdobe(string name)
{
foreach (Process clsProcess in Process.GetProcesses().Where(
clsProcess => clsProcess.ProcessName.StartsWith(name)))
{
clsProcess.Kill();
return true;
}
return false;
}
}//END Class
}//END Namespace
这篇关于是否可以通过c#activex直接打印独立的html页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文