2012-02-24 85 views
1

你好我已經上傳的數據轉換成PDF使用下面的代碼類似保存PDF文件使用默認名稱在導出PDF

我的頁面:empdata.aspx

代碼:

Fname = "1.pdf" 
    crDiskFileDestinationOptions = New DiskFileDestinationOptions 
    crDiskFileDestinationOptions.DiskFileName = Fname 
    crExportOptions = crReportDocument.ExportOptions 
    With crExportOptions 
     .DestinationOptions = crDiskFileDestinationOptions 
     .ExportDestinationType = ExportDestinationType.DiskFile 
     .ExportFormatType = ExportFormatType.PortableDocFormat 
    End With 
    crReportDocument.Export() 

    With Response 
     .ClearContent() 
     .ClearHeaders() 
     .ContentType = "application/pdf name=1.pdf" 
     .AddHeader("content-disposition", "inline; filename=1.pdf") 
     .WriteFile(Fname) 
     .Flush() 
     .Close() 
    End With 

但是當我嘗試保存我的文件時,默認情況下它會顯示我的頁面名稱(empdata)。但是我想要默認顯示1.pdf。

這裏有什麼問題嗎?

回答

1

我用這個代碼:

try 
    { 
    reportDocument.ExportToHttpResponse( 
       ExportFormatType.PortableDocFormat 
       ,Response, true, "1.pdf"); 
    } 
catch (System.Threading.ThreadAbortException) 
    { 
     //System.Threading.ThreadAbortException is thrown 
     //because, Response.End is called internally in ExportToHttpResponse method: 
    } 

和它的作品。

+0

非常感謝你......對我也有效:) – jestges 2012-02-24 11:07:47