pdf and content-disposition filename - grapecity

Upload: sakthi18

Post on 30-Oct-2015

23 views

Category:

Documents


0 download

TRANSCRIPT

  • 6/10/13 PDF and Content-disposition filename - GrapeCity

    www.datadynamics.com/forums/80317/PrintPost.aspx 1/4

    PDF and Content-disposition filename

    ActiveReports for .NET 2.0 Support

    PDF and Content-disposition filename

    10-06-2005, 11:30 AM

    I've read the threads about this issue and haven't seen a solution that works for us. Any new ideas?

    Issue: When using PDFExport to create a PDF stream which is then sent to a browser window via

    Response.Clear();

    Response.ContentType = "application/pdf";

    Response.AddHeader("Content-disposition","inline");

    Response.BinaryWrite(rptStream.ToArray());

    Response.End();there doesn't seem to be a way to set the default filename that shows up when the user chooses to save a

    copy in Adobe Reader 7's browser plug-in. Yes, I tried adding filename=whatnot.pdf to my content-disposition header, and about a million other things involving change the URL of the page to have a dummy

    piece which included whatnot.pdf. The closest I came was when I add a dummy piece of the URL that had/whatnot.pdf, the default save name had *all* of the URL up to and including /whatnot.pdf, with various

    characters replaced by underscores.

    Re: PDF and Content-disposition filename

    10-06-2005, 4:42 PM

    As far as we know, there isn't a solution that works 100% of the time when streaming the reports using the

    response object. The only sure way is to export to a file and redirect the user to that file on the webserver.

    brandon.

    webmaster. -DD

    Re: PDF and Content-disposition filename

    10-18-2005, 1:09 PM

    The following is almost verbatim from the samples distributed with Active Reports, plus the added file name,

    this works 100% of the time for me in MSIE & FireFox:

    Private Sub lnkExportPDF_Click( ByVal sender As System.Object, ByVal e AsSystem.EventArgs) Handles lnkExportPDF.Click Dim rpt As ActiveReport = GetReport() Try rpt.Run( False) Catch eRunReport As DataDynamics.ActiveReports.ReportException ' Failure running report, just report the error to the user: Response.Clear() Response.Write("Error running report:") Response.Write(eRunReport.ToString()) Return End Try Dim pdf As New DataDynamics.ActiveReports.Export.Pdf.PdfExport

  • 6/10/13 PDF and Content-disposition filename - GrapeCity

    www.datadynamics.com/forums/80317/PrintPost.aspx 2/4

    Dim memStream As New System.IO.MemoryStream pdf.Export(rpt.Document, memStream) Response.Buffer = True Response.ClearContent() Response.ClearHeaders() Response.ContentType = "application/pdf" Response.AddHeader("content-disposition", "attachment;filename=" & strFileName &".pdf") Response.BinaryWrite(memStream.ToArray()) Response.End() End Sub

    Re: PDF and Content-disposition filename

    04-28-2006, 3:00 PM

    Had tabled this one for a while but it's coming back on me as important again. The solution presented in the

    last post pops up a box asking me if I want to open or save or cancel, due to the disposition of attachment. I

    need to use inline, and the filename doesn't do anything with that option.

    Re: PDF and Content-disposition filename

    05-02-2006, 2:44 PM

    I have a problem with the filename in Firefox. I have the following code in a common class which is exactly

    like the above code in VB:

    public static void ExportToPDF(PdfExport exPDF, Document objDoc, string pdfFileName){

    MemoryStream m_stream = new MemoryStream(); exPDF.Export(objDoc,m_stream);

    HttpContext.Current.Response.Buffer = true; HttpContext.Current.Response.ClearContent(); HttpContext.Current.Response.ClearHeaders();

    HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("content-disposition","attachment;filename=" + pdfFileName +

    ".pdf"); HttpContext.Current.Response.BinaryWrite(m_stream.ToArray());

    HttpContext.Current.Response.End();}

    My report title is "GP2 Performance Report". In IE, the report filename defaults to "GP2 Performance

    Report.pdf", while in Firefox it simply defaults to "GP2" without the rest of the filename or extension.

    Any ideas on why it might do that?

    As far as not popping up the box asking you where you want to save it, replace the attachment line abovewith this:

    HttpContext.Current.Response.AddHeader("content-disposition","inline;filename=" + pdfFileName + ".pdf");

    Any other ideas on why the filename doesn't appear correctly in Firefox?

  • 6/10/13 PDF and Content-disposition filename - GrapeCity

    www.datadynamics.com/forums/80317/PrintPost.aspx 3/4

    Thanks,

    Greg

    Re: PDF and Content-disposition filename

    05-03-2006, 4:31 PM I'm curious if the space in the string is causing the glitch in firefox.

    Re: PDF and Content-disposition filename

    05-03-2006, 4:39 PM

    You are correct. I changed the name to GP2_Performance_Report and it preserved the complete filenameand extension.

    Odd.

    Thanks,Greg

    Re: PDF and Content-disposition filename

    05-08-2006, 1:36 PM

    gknierim wrote:

    As far as not popping up the box asking you where you want to save it, replace

    the attachment line above with this:

    HttpContext.Current.Response.AddHeader("content-

    disposition","inline;filename=" + pdfFileName + ".pdf");

    Except when using inline, filename doesn't do anything.

    Re: PDF and Content-disposition filename

    05-09-2006, 8:49 AM I beg to differ. I can pass a different name to the pdfFileName and that name shows up in the Save As dialog

    box when I save it.

    Re: PDF and Content-disposition filename

    05-11-2006, 1:34 PM

    gknierim wrote:

  • 6/10/13 PDF and Content-disposition filename - GrapeCity

    www.datadynamics.com/forums/80317/PrintPost.aspx 4/4

    I beg to differ. I can pass a different name to the pdfFileName and that name

    shows up in the Save As dialog box when I save it.

    Not me...in both IE and FF using Reader 7 plugins to both browsers the save as shows the name of the webpage as the default save name, no matter what is in the filename part of the content-disposition.

    Re: PDF and Content-disposition filename

    05-12-2006, 11:22 AM Have you taken a look at the following forum thread: http://www.datadynamics.com/forums/ShowPost.aspx?

    PostID=49196 ? There has been a lot of discussion regarding setting the filename.