1

嗨,我已经使用下面的代码将我的数据上传到 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 。

这有什么不对吗?

4

1 回答 1

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:
    }

它有效。

于 2012-02-24T10:26:52.247 回答