C# 利用pdf虚拟打印机将word转换成pdf
C# 利用pdf虚拟打印机将word转换成pdf
using System.ComponentModel;
using System.Drawing.Printing;
using System.IO;
using Word;
public partial class Form1 : Form
{
{
object oMissing = System.Reflection.Missing.Value;
private string regRoot = "SOFTWARE\\Adobe\\Acrobat Distiller\\";
/// /// <returns></returns>
RegistryKey regKey = null;
int i;
regKey = Registry.LocalMachine;
for (i = 4; i < 9; i++)
acrodistKey = regKey.OpenSubKey(regRootVersion);
{
{
}
}
/// 或 "Acrobat Distiller"
private string GetAdobePrinter()
{
{
}
if (PrinterSettings.InstalledPrinters.Count == 0)
if (!File.Exists(sourceFile))
string prnFile = string.Format("{0}\\{1}.prn",strDir,strName);
object background = true;
object append = false;
object range = Word.WdPrintOutRange.wdPrintAllDocument;
Word._Application word = new Word.Application();
// ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing,
string oldPrint = doc.Application.ActivePrinter;
doc.Application.ActivePrinter = adobePrinter;
// Word ref missing, ref missing,ref missing, ref printToFile, ref collate, ref missing, ref missing,
if (DateTime.Now > end)
}
System.Windows.Forms.Application.DoEvents();
word.Documents.Close(ref SaveChanges, ref oMissing, ref oMissing);
Process objProcess = new Process();
objProcess.StartInfo.FileName = GetAdobeDisFilePath();
start = DateTime.Now;
{
throw new Exception("Word document print to prn document overtime");
{
}
|