2012-02-28 13 views
4

私のウェブサイトには、ページの内容をPDFとして印刷できる機能があります。私はこれに対していくつかのオプションを試しましたが、多言語の文字を扱うので、wkhtmltopdfがベストマッチでした。wkhtmltopdf.exeクラウドWebサーバーのSystem.Security.SecurityException。サーバーのセキュリティポリシーを無効にするにはどうすればいいですか

私はそれは私のローカルサーバーに取り組んでしまったが、私は今、それは私に次のエラー

Security Exception 
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file. 

Exception Details: System.Security.SecurityException: Request failed. 

を与えているホスティングのためのクラウドWebサーバにアップロードするとき、私は、web.configファイル内にセキュリティポリシーを変更し

<securityPolicy> 
    <trustLevel name="Full" policyFile="internal"/> 
</securityPolicy> 

しかし、それはまだ

テストURLを動作していない http://www.noor.com.asp1-20.dfw1-2.websitetestlink.com/ArticleDetails.aspx?Language=en-US&PageID=19&ArticleID=4

です

このダウンロードリンクの裏にあるダウンロードリンクをクリックすると、Webページの特定のセクションをPDFに変換できます。ローカルサーバー上で正常に動作しますが、Webサーバー上のセキュリティ上の理由で動作しません。私はPDFを稼働させるために何日も探していましたが、現在はWebサーバー上で動作していません。私は他のオプションを試してみましたが、何らかの理由でiTextがアラビア語を変換していなかったのは、アラビア語のページのみのジャンク文字を印刷していたためです。

私はそれを正しくするために何を変えるべきかアドバイスしてください。

C#の

コードを使用してasp.net 4.0を使用して、このウェブサイトを、私を開発してきた私は、PDF

CODE WORKING
string url = "PrintArticle.aspx?articleID=" + Request["articleID"] + "&download=yes&Language=" + Request["Language"]; 

// string args = string.Format("\"{0}\" - ", url); 
string args = string.Format("\"{0}\" - ", "http://www.domain.com.asp1-20.dfw1-2.websitetestlink.com/" + url); 
var startInfo = new ProcessStartInfo(Server.MapPath("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=download.pdf"); 
Response.BinaryWrite(buffer); 
Response.End(); 

答えて

3

を生成するために使用します。 を私からPrintArticle.aspxを呼び出すことによって、問題を解決MainPage.aspx、ユーザーがクリックしたときlnkbtnダウンロードリンクボタンPrinteArticle.aspx(印刷記事ページは記事タイトル、日付を示す簡単なページです条解説)とコードにHTMLを渡すこれを下回るその後、PDFファイルとして出力します私は情報でarticleID、ダウンロード、言語などのようなクエリ文字列として他のパラメータを渡しています

protected void lnkbtnDownload_Click(object sender, EventArgs e) 
    { 
     string url = "PrintArticle.aspx?articleID=" + Request["articleID"] + "&download=yes&Language=" + Request["Language"]; 

     string args = string.Format("\"{0}\" - ", "http://xyz.net/" + url); 
     var startInfo = new ProcessStartInfo(Server.MapPath("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=download.pdf"); 
     Response.BinaryWrite(buffer); 
     Response.End(); 
    } 

..

関連する問題