![](/img/trans.png)
[英]Ghostscript.NET pdf to image not working on windows azure
[英]Ghostscript.Net doesn't working in Windows Server 2012 R2
我在我的項目中使用Ghostscript.NET在網絡上打印Pdf文件。 使用Windows 10版本64位和Ghostscript驅動程序到32位(對於Windows 32位為Ghostscript 9.22),可以從https://www.ghostscript.com/download/gsdnld.html下載,在本地運行良好。 安裝32位版本的動機是例外,
Ghostscript.NET.GhostscriptLibraryNotInstalledException:此托管庫在32位進程下運行,並且需要在此計算機上安裝32位Ghostscript本機庫! 要下載適當的Ghostscript本機庫,請訪問: http : //www.ghostscript.com/download/gsdnld.html
,這在使用Ghostscript 64位驅動程序時出現在我的應用程序日志中。
我發布應用程序的目標操作系統是Windows Server 2012 R2。 使用相同的Ghostscript驅動程序(對於Windows 32位為Ghostscript 9.22),print命令無限期地循環,而對我的應用程序無響應。
為此,我禁用了防火牆和防病毒功能,以消除它們成為循環原因的可能性。
我的應用程序從磁盤讀取pdf文件,並使用Ghostscript將其發送到網絡打印機。 為了模擬該過程,我使用TeamViewer遠程連接到客戶端計算機。 因此,我從這台計算機上調用了REST Web服務,該服務將文件保存到磁盤,並使用Ghostscript在網絡打印機中打印文檔。
try
{
var task = Task.Run(() =>
{
using (GhostscriptProcessor processor = new GhostscriptProcessor(GhostscriptVersionInfo.GetLastInstalledVersion(), true))
{
List<string> switches = new List<string>();
switches.Add("-empty");
switches.Add("-dPrinted");
switches.Add("-dBATCH");
switches.Add("-dNOPAUSE");
switches.Add("-dNOSAFER");
switches.Add("-dPDFFitPage");
switches.Add("-dNumCopies=" + numCopias);
switches.Add("-sDEVICE=mswinpr2");
switches.Add("-sOutputFile=%printer%" + "\\\\" + printerIP + "\\" + printerNAME);
switches.Add("-f");
switches.Add(inputFile);
processor.StartProcessing(switches.ToArray(), null);
}
});
if (!task.Wait(TimeSpan.FromSeconds(Int32.Parse(ConfigurationManager.AppSettings["MAX_PRINTER_DELAY"]))))
{
Log.Info(String.Format("A impressão do arquivo ({0}) ({1}) foi encerrada porque ultrapassou MAX_PRINTER_DELAY = {2}!", inputFile, printerNAME, ConfigurationManager.AppSettings["MAX_PRINTER_DELAY"]));
}
}
catch (GhostscriptLibraryNotInstalledException e)
{
Log.Info("O GhostScript não está instalado.");
Log.Error(e);
}
catch (GhostscriptException e)
{
Log.Info("O GhostScript apresentou erro.");
Log.Error(e);
}
catch (Exception exception)
{
Log.Error(exception);
}
我正在使用Ghostscript.NET 1.2.1.0版。
有人能幫我嗎?
Microsoft Windows安全體系結構似乎不允許Asp Net API在不使用模擬的情況下直接作為打印機訪問COM設備。 通過使用第三方庫和連接到具有更高Intranet用戶級別的計算機(作為IIS用戶)的本地打印機,系統打印了文件。 開發Windows服務程序(以Admin用戶身份安裝並可以訪問COM設備)可以得到最佳答案(根據我的觀點,源代碼實現在我需要的情況下無需使用大量“重構”即可清晰且可重用)。目錄,然后使用其他程序作為Adobe Reader將您的內容發送到打印機。 我實際情況的目標打印機是IP打印機,而不是本地打印機。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.