2012-02-24 133 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

相关问题