0

アプリケーションのページを PDF として保存しようとしています。ページには現在ログインしているメンバーに関するデータがありますが、ページの URL を wkhtmltopdf に渡すと、新しいプロセスがログインしていないため、そのデータを表示できません。

wkhtmltopdf を特定のメンバーとしてログインさせることはできますか? ユーザー名とパスワードのパラメーターを使用してみましたが、これらは基本的な http 認証用であり、効果がないようです。

https://github.com/codaxy/wkhtmltopdfを使用して wkhtmltopdf をラップしています。私の使用法:

string filename = "file.pdf";
MemoryStream memory = new MemoryStream();
PdfDocument document = new PdfDocument() { Url = Request.Url.AbsoluteUri };
PdfOutput pdfoutput = new PdfOutput() { OutputStream = Response.OutputStream };

PdfConvert.ConvertHtmlToPdf(document, pdfoutput);

Response.ContentType = "Application/pdf";
Response.AppendHeader("content-disposition", "attachment; filename=" + filename);
Response.End(); 
4

1 に答える 1

0

認証 Cookie を wkhtmltopdf プロセスに含める方法を見つけました。

// Authentication
paramsBuilder.Append("--cookie " + System.Web.Security.FormsAuthentication.FormsCookieName + " " + umbraco.library.RequestCookies(System.Web.Security.FormsAuthentication.FormsCookieName) + " ");

トリックを行うようです!

于 2013-11-20T13:24:55.940 に答える