资源简介
利用 Acrobat pdf 虚拟打印机来生成pdf ,但是会有错误。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing.Printing;
using System.IO;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Word;
using Microsoft.Win32;
namespace Acrobat.word2pdf1
{
class Program
{
private string adobePdfPrint = “Adobe PDF“;
private string adobeDisPrint = “Acrobat Distiller“;
private string regRoot = “SOFTWARE//Adobe//Acrobat Distiller//“;
private string printerFileName = “acrodist.exe“;
private string regName = “InstallPath“;
///
/// 获取acrodist.exe的安装路径
///
///
private string GetAdobeDisFilePath()
{
RegistryKey regKey = null;
RegistryKey acrodistKey = null;
string printerName = string.Empty;
int i;
string regRootVersion = string.Empty;
regKey = Registry.LocalMachine;
// acrodist的4-8版本适用
for (i = 4; i < 9; i++)
{
regRootVersion = string.Format(“{0}{1}.0“ regRoot i);
acrodistKey = regKey.OpenSubKey(regRootVersion);
if (acrodistKey != null)
{
printerName = acrodistKey.GetValue(regName ““) + “//“ + printerFileName;
if (File.Exists(printerName))
{
return printerName;
}
}
}
throw new Exception(“Acrobat Distiller printer not found!“);
}
///
/// 获取Adobe Printer
/// “Adobe PDF“ 或 “Acrobat Distiller“
///
///
private string GetAdobePrinter()
{
foreach (string printername in PrinterSettings.InstalledPrinters)
{
if (printername.ToUpper().IndexOf(adobePdfPrint.ToUpper()) != -1 || printername.ToUpper().IndexOf(adobeDisPrint.ToUpper()) != -1)
{
return printername;
}
}
return string.Empty;
}
public void ConvertWord2Pdf(string sourceFile)
{
Microsoft.Office.Interop.Word.ApplicationClass word = null;
Microsoft.Office.Interop.Word.Document doc = null;
object paramMissing = Type.Missing;
object paramSourceDocPath = sourceFile;
try
{
if (PrinterSettings.InstalledPrinters.Count == 0)
throw new Exception(“Did not find the printer please install the printer.“);
if (!File.Exists(sourceFile))
throw new Exception(string.Format(“File not found:{0}“ sourceFile));
string strDir = Path.GetDirectoryName(sourceFile);
string strName = Pa
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2012-02-22 19:56 Acrobat.word2pdf1\
文件 29458320 2012-02-22 19:52 Acrobat.word2pdf1\Acrobat.dll
文件 3181 2012-02-22 19:54 Acrobat.word2pdf1\Acrobat.word2pdf1.csproj
文件 781104 2012-02-22 19:53 Acrobat.word2pdf1\Microsoft.Office.Interop.Word.dll
文件 7732 2012-02-22 19:56 Acrobat.word2pdf1\Program.cs
目录 0 2012-02-22 19:51 Acrobat.word2pdf1\Properties\
文件 1378 2012-02-22 19:51 Acrobat.word2pdf1\Properties\AssemblyInfo.cs
- 上一篇:矩阵分析与应用第二版
- 下一篇:天地伟业 2011校招 计算机 笔试题
相关资源
- PDF转图片各DLL及demo
- Acrobat 简体中文字体问题需要的CIDFo
- Adobe Acrobat DC Classroom in a Book.pdf
- AcrobatPortable_简体中文语言支持包
- Adobe Acrobat 10 开发说明文档及
- acrobat x pro 简体中文语言支持包
- acrobat dc pro 补丁
- AdobeAcrobat破解方法.txt
- Acrobat_DC_2018.txt
- Acrobat XI Pro 破解补丁
- acrobat x 破解补丁 amtlib.dll
- Acrobat DC2015 Pro 破解补丁文件amtlib.dl
- IEEE-PDF-Acrobat6-17Mar04.joboptions
- AdobeAcrobat9Pro.txt
- Adobe.Acrobat.9.0.Pro.ExtendedCrack.zip
- 黑马校对软件支持Acrobat6.0/7.0/8.0/9.0版
- Acrobat pdf 二次开发.net 源代码
- adobe acrobat 9.0.0 pro extended
评论
共有 条评论