//new object[]{false,false,oWord.WdPrintOutRange.wdPrintAllDocument,printFileName}
//对应脚本中的word.PrintOut(false, false, 0, psfile);的参数
//退出WORD
//对应脚本中的word.Quit();
wordType.InvokeMember("Quit", System.Reflection.BindingFlags.InvokeMethod, null, word, null);
object o1 = "c:aaa.ps";
object o2 = "c:aaa.pdf";
object o3 = "";
//引用将PS转换成PDF的对象
//try catch之间对应的是脚本中的 PDF.FileToPDF(psfile,pdffile,""); //你可以使用 pdfConvert.FileToPDF("c:test.ps","c:test.pdf","");这样的转换方法,本人只是为了保持与WORD相同的调用方式
try
{
ACRODISTXLib.PdfDistillerClass pdf = new ACRODISTXLib.PdfDistillerClass();
Type pdfType = pdf.GetType();
pdfType.InvokeMember("FileToPDF", System.Reflection.BindingFlags.InvokeMethod, null, pdf, new object[] { o1, o2, o3 });
pdf = null;
}
catch { } //读者自己补写错误处理
//为防止本方法调用多次时发生错误,必须停止acrodist.exe进程
foreach (System.Diagnostics .Process proc in System.Diagnostics.Process.GetProcesses())
{
int begpos;
int endpos;
string sProcName = proc.ToString();
begpos = sProcName.IndexOf("(") + 1;
endpos = sProcName.IndexOf(")");
sProcName = sProcName.Substring(begpos, endpos - begpos);
if (sProcName.ToLower().CompareTo("acrodist") == 0)
{
try
{
proc.Kill(); //停止进程
}
catch { } //读者自己补写错误处理
break;
}
}
}
private void button3_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
string s = openFileDialog1.FileName;
WordConvert(s);
}
}
//getnextcode
private void button4_Click(object sender, EventArgs e)