我必须从供应商网址阅读pdf,然后流式传输到网页。我正在尝试下面的代码,但它不起作用。我打了个图像字节 - 这些是填充的。
这是图像控件的属性设置ImageUrl =“〜/ Controls / CheckImage / DraftImage.ashx?FB = F”
以下是ashx页面的代码
public void ProcessRequest(HttpContext context) {
WebClient imageWebClient = new WebClient();
CheckImg.Draft.FrontImage.Image = imageWebClient.DownloadData(Url);
context.Response.Clear();
context.Response.ContentType = ("application/pdf");
context.Response.AddHeader("Content-Disposition", "inline;filename=image.pdf");
context.Response.BinaryWrite(CheckImg.Draft.FrontImage.Image);
context.Response.Flush();
context.Response.Close();
// context.Response.End();
HttpContext.Current.ApplicationInstance.CompleteRequest();
答案 0 :(得分:0)
我遇到了很多麻烦。我最后用这个击中了正确的组合。 数据字节数组是abcPdf.net pdf doc。
希望这会有所帮助:
byte[] data = doc.GetData();
Response.Clear();
Response.ClearHeaders();
Response.ClearContent();
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "inline; filename=MyPDF.PDF");
Response.AddHeader("content-length", data.Length.ToString());
Response.BinaryWrite(data);
Response.Flush();
Response.Close();
Response.End();