2016-11-10 123 views
1

在我的ASP .Net应用程序中,我正在使用'PDFTron 6.0.1.0'。 在将我的docx文件转换为xod(使用pdftron.PDF.Convert.ToXod方法)之前,我们检查是否存在虚拟打印机,如果不存在,请安装它。为此,我们使用以下代码:无法安装Pdftron虚拟打印机

private void CheckIfVirtualPrinterRequired(string inputFilePath, out bool uninstallVirtualPrinter) 
{ 
    uninstallVirtualPrinter = false; 
    if (pdftron.PDF.Convert.RequiresPrinter(inputFilePath)) 
    { 
     if (pdftron.PDF.Convert.Printer.IsInstalled("PDFTron Creator")) 
     { 
      pdftron.PDF.Convert.Printer.SetPrinterName("PDFTron Creator"); 
     } 
     else if (!pdftron.PDF.Convert.Printer.IsInstalled()) 
     { 
      pdftron.PDF.Convert.Printer.Install(); 
      uninstallVirtualPrinter = true; 
     } 
    } 
} 

但是,在'pdftron.PDF.Convert.Printer.Install();'代码中,我得到SEHException:的“PDFTron Creator”和“PDFTron PDFNet”打印机

External component has thrown an exception. Stack Trace: at trn.PDF.Convert.Printer.Install(UString*) at pdftron.PDF.Convert.Printer.Install() at *****.PDFTronService.CheckIfVirtualPrinterRequired(String inputFilePath, Boolean& uninstallVirtualPrinter) in c:***\PDFTronService.cs:line 126

我已经后试图手动安装64位版本,但转换仍失败,出现错误:

Unable to convert file, too many attempts. Conditional expression: false, Filename : Convert.cpp, Function : trn::PDF::Convert::ToPdf, Linenumber : 1742 at pdftron.PDF.Convert.ToXod(inputFilePath, outFileName);

请帮助解决这个问题。

回答

0

首先,虚拟打印机实际上并不需要Office转换,如果您安装了MS Office。如果安装了MS Office,PDFNet将使用Interop进行通信。 RequiresPrinter对于办公文档返回true,但对于office文档来说它是真正可选的。

虚拟打印机通常用于其他文件类型,例如, AutoCad DWG。

如果您没有安装MS Office,并且希望使用类似LibreOffice的东西来转换Office文档,那么您需要虚拟打印机。

此外,您只需要安装一次打印机。不是每次你想要转换。

要安装虚拟打印机,您需要使用提升的权限运行,并且PDFNet 32​​位| 64位需要与您的操作系统32位| 64位匹配。

如果SEH错误仍然存​​在,那么我会推荐使用最新版本的PDFNet。