2012-07-19 79 views
0

我有一個SOAP webservice,它返回一個.PDF文件的二進制流。Phonegap/HTML - 如何顯示web服務返回的pdf?

文件不實際存在,我需要知道,如果有一種方法可以讓瀏覽器解釋這個流就像一個HTML鏈接顯示生成和顯示文件:<a href="url.pdf">DOWNLOAD FILE</a>

回答

0

你可以把一個頁面在檢索PDF流的Web服務器中,在響應頭中設置所需參數,並將響應發送給客戶端。

使用C#和asp.net實施例:

的HTML鏈接將是:<a href="mypdf.aspx">DOWNLOAD FILE</a>

mypdf.aspx中的代碼將是:

protected void Page_Load(object sender, EventArgs e) 
{ 
    Response.ClearContent(); 
    Response.AddHeader("content-disposition", 
     "attachment;filename=FilledForm.pdf"); 
    Response.ContentType = "application/pdf"; 
    byte[] bytes = GetPDFBytesFromWebService(); 
    Response.BinaryWrite(bytes); 
    Response.End();   
}