我使用Pechkin将我的页面转换为pdf,每次我尝试转换时,生成的页面总是登录页面。但是,当我直接打开页面时,它会正常打开。这是我用来转换为pdf的代码:
var client = new WebClient();
String url = Request.Url.AbsoluteUri;
string urlMap = new Uri(HttpContext.Current.Request.Url.AbsoluteUri).OriginalString;
string urll = urlMap.Substring(0, urlMap.LastIndexOf("/"));
string urlpdf = urll+"/PrintPdf.aspx?No=" + txtNo.Text + "&VoyNo=" + txtVoyage.Text + "";
Response.Redirect(urlpdf);
var pechkin = Factory.Create(new GlobalConfig());
var pdf = pechkin.Convert(new ObjectConfig()
.SetLoadImages(true).SetZoomFactor(1.5)
.SetPrintBackground(true)
.SetScreenMediaType(true)
.SetCreateExternalLinks(true)
.SetIntelligentShrinking(true).SetCreateInternalLinks(true)
.SetPageUri(urlpdf));
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.ContentType = "application/pdf";
Response.AddHeader("Content-Disposition", string.Format("attachment;filename=test.pdf; size={0}", pdf.Length));
Response.BinaryWrite(pdf);
Response.Flush();
Response.End();发布于 2017-02-02 20:09:24
听起来您的应用程序需要您登录。由于转换为PDF步骤是在服务器上进行的,因此服务器实际上并未登录。您需要在本地呈现该页面并进行转换,而不是尝试将当前URI传递给Pechkin。
如果要将http URL传递给pechkin,则必须可以在不登录的情况下访问它,或者必须传递足够的信息才能登录。
https://stackoverflow.com/questions/42001850
复制相似问题