簡體   English   中英

在Live Server(Windows Server 2008 R2企業)中,無法使用wkhtmltopdf.exe生成PDF,但可以在本地主機中使用

[英]In Live Server (Windows server 2008 R2 enterprise) PDF Is Not Generating with wkhtmltopdf.exe, but works in Local Host

我們正在使用wkhtmltopdf.exe(長達10個月沒有出現問題),但是從幾天開始,我們就遇到了wkhtmltopdf.exe的問題。 目前,我們從wkhtmltopdf.exe得到錯誤,並且沒有為我們生成PDF,我們使用JavaScript。 當我單擊頁面時,將轉到我們的書面錯誤頁面。 我們在PDF中的問題不是來自wkhtmltopdf.exe的任何版本。 我們的代碼和應用程​​序非常清晰。.wkhtmltopdf.exe在本地工作,為什么不在實時服務器(Windows 2008 R2企業版)中工作? 我們已經嘗試了(wkhtmltopdf站點)[ http://wkhtmltopdf.org/downloads.html]中的所有版本,所有版本均在localhost中工作,但未在實時服務器中工作。我們的本地服務器iis版本(7.5)與實時服務器中的相同關於iis版本(7.5),下一步該怎么做? 在localhost中的pdf生成的iis版本是(7.5)在Windows Server 2008 R2企業中具有相同的版本,但是PDF未生成。

   protected void Export(object sender, EventArgs e)
    {          
        String GlobalDomainName = System.Configuration.ConfigurationManager.AppSettings["live_domainName"];

        string url = "PropertyEWC.aspx?id=" + PropertyId + "&bid=" + UserData.BranchId + "&aid=" + UserData.CompanyId;


        string args = string.Format("\"{0}\" - ", GlobalDomainName + url);
        var startInfo = new ProcessStartInfo("C:\\Program Files\\wkhtmltopdf1\\bin\\wkhtmltopdf.exe", args)
        {

            UseShellExecute = false,
            CreateNoWindow = true,
            RedirectStandardOutput = true

        };
        var proc = new Process { StartInfo = startInfo };
        proc.Start();
        string output = proc.StandardOutput.ReadToEnd();
        byte[] buffer = proc.StandardOutput.CurrentEncoding.GetBytes(output);
        proc.WaitForExit();
        proc.Close();
        Response.ContentType = "application/pdf";
        Response.AddHeader("Content-Disposition", "attachment;filename=ElectronicWindow.pdf");
        Response.BinaryWrite(buffer);
        Response.End();
    }

在上面的代碼中,我們在proc.start()中遇到錯誤,解決該錯誤的方法是使用proc.start的任何替代方法。

通過在wkhtmltopdf.exe屬性中進行更改,它對我有用。 在wkhtmltopdf.exe上用鼠標右鍵單擊,選擇屬性。在屬性中,選擇安全選項。 因此,您可以更改您的訪問選項。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM