export to PDF problem

Discussion in 'ASP .Net' started by Sze, Jul 8, 2010.

  1. Sze

    Sze Guest

    I got a method to export the report to PDF directly, However, it sometimes
    work (export the pdf in 5 secs) but sometimes. (there is dialog box prompt
    out and said downloading.........) , and the doc can't export as pdf


    Public Sub ExportToCrystalPDF(ByVal Filter As String, ByVal Filename As
    String)
    Dim Login As New MasterData.Login
    Dim rptCount As New
    CrystalDecisions.CrystalReports.Engine.ReportDocument()
    rptCount.Load(Server.MapPath("./Reports/" + Filename + ".rpt"))
    ' Dim customerFilePath As String =
    Server.MapPath("App_Data\FineArtMaster.xsd")
    Login.Sub_CrystalLogin(rptCount)

    Dim crParameterFieldDefinitions As
    CrystalDecisions.CrystalReports.Engine.ParameterFieldDefinitions =
    rptCount.DataDefinition.ParameterFields

    ' rptCount.RecordSelectionFormula = "TRUE and
    {mounting.mounting} = ""Mounting Type 1"""
    rptCount.RecordSelectionFormula = Filter
    Dim crExportOptions As ExportOptions

    crExportOptions = rptCount.ExportOptions
    With crExportOptions
    .FormatOptions = New PdfRtfWordFormatOptions()
    .ExportFormatType = ExportFormatType.PortableDocFormat
    End With

    Dim req As ExportRequestContext = New ExportRequestContext()
    req.ExportInfo = crExportOptions


    Dim st As System.IO.Stream

    st = rptCount.FormatEngine.ExportToStream(req)

    Response.ClearContent()
    Response.ClearHeaders()
    Response.ContentType = "application/pdf"
    Response.AddHeader("content-disposition", "attachment; filename= " &
    Filename & ".pdf")

    Dim b(st.Length) As Byte
    st.Read(b, 0, st.Length)
    Response.BinaryWrite(b)

    Response.End()
    Response.Close()

    rptCount.Dispose()
    st.Dispose()

    End Sub
    Sze, Jul 8, 2010
    #1
    1. Advertising

  2. Hi,

    >I got a method to export the report to PDF directly, However, it sometimes
    >work (export the pdf in 5 secs) but sometimes. (there is dialog box prompt
    >out and said downloading.........) , and the doc can't export as pdf


    To resolve this issue I think first we need to identify whether it's a
    server side issue or client side issue.

    Could you please set a breakpoint at:

    Response.End()

    Can the breakpoint be hit when it doesn't work?

    In addition, you mentioned "there is dialog box prompt
    out and said downloading.........". Could you share a screenshot of that
    dialog box?

    BTW, which browser are you using?

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .

    ==================================================
    Get notification to my posts through email? Please refer to
    http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

    Note: MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 2 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions. Issues of this
    nature are best handled working with a dedicated Microsoft Support Engineer
    by contacting Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
    ==================================================
    This posting is provided "AS IS" with no warranties, and confers no rights.
    Allen Chen [MSFT], Jul 12, 2010
    #2
    1. Advertising

  3. Hi,

    >I got a method to export the report to PDF directly, However, it sometimes
    >work (export the pdf in 5 secs) but sometimes. (there is dialog box prompt
    >out and said downloading.........) , and the doc can't export as pdf


    Do you have any progress on this issue?

    Regards,
    Allen Chen
    Microsoft Online Support

    Delighting our customers is our #1 priority. We welcome your comments and
    suggestions about how we can improve the support we provide to you. Please
    feel free to let my manager know what you think of the level of service
    provided. You can send feedback directly to my manager at:
    .
    Allen Chen [MSFT], Jul 21, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Richard Coltrane

    ReportViewer export to PDF = PDF[1].

    Richard Coltrane, Feb 25, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    1,042
    Richard Coltrane
    Feb 25, 2007
  2. Ricardo Pog
    Replies:
    1
    Views:
    400
    Austin Ziegler
    Mar 26, 2008
  3. Maarten Porters
    Replies:
    1
    Views:
    420
    Florian Gilcher
    Jul 28, 2008
Loading...

Share This Page