Você está na página 1de 4

6/10/13

PDF and Content-disposition filename - GrapeCity

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 contentdisposition 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:
P r i v a t eS u bl n k E x p o r t P D F _ C l i c k (B y V a ls e n d e rA sS y s t e m . O b j e c t ,B y V a leA s S y s t e m . E v e n t A r g s )H a n d l e sl n k E x p o r t P D F . C l i c k D i mr p tA sA c t i v e R e p o r t=G e t R e p o r t ( ) T r y r p t . R u n (F a l s e ) C a t c he R u n R e p o r tA sD a t a D y n a m i c s . A c t i v e R e p o r t s . R e p o r t E x c e p t i o n 'F a i l u r er u n n i n gr e p o r t ,j u s tr e p o r tt h ee r r o rt ot h eu s e r : R e s p o n s e . C l e a r ( ) R e s p o n s e . W r i t e ( " < h 1 > E r r o rr u n n i n gr e p o r t : < / h 1 > " ) R e s p o n s e . W r i t e ( e R u n R e p o r t . T o S t r i n g ( ) ) R e t u r n E n dT r y D i mp d fA sN e wD a t a D y n a m i c s . A c t i v e R e p o r t s . E x p o r t . P d f . P d f E x p o r t
www.datadynamics.com/forums/80317/PrintPost.aspx 1/4

6/10/13

PDF and Content-disposition filename - GrapeCity

D i mm e m S t r e a mA sN e wS y s t e m . I O . M e m o r y S t r e a m p d f . E x p o r t ( r p t . D o c u m e n t ,m e m S t r e a m ) R e s p o n s e . B u f f e r=T r u e R e s p o n s e . C l e a r C o n t e n t ( ) R e s p o n s e . C l e a r H e a d e r s ( ) R e s p o n s e . C o n t e n t T y p e=" a p p l i c a t i o n / p d f " R e s p o n s e . A d d H e a d e r ( " c o n t e n t d i s p o s i t i o n " ," a t t a c h m e n t ; f i l e n a m e = "&s t r F i l e N a m e& R e s p o n s e . B i n a r y W r i t e ( m e m S t r e a m . T o A r r a y ( ) ) R e s p o n s e . E n d ( ) E n dS u b

" . p d f " )

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 above with this: HttpContext.Current.Response.AddHeader("content-disposition","inline;filename=" + pdfFileName + ".pdf"); Any other ideas on why the filename doesn't appear correctly in Firefox?
www.datadynamics.com/forums/80317/PrintPost.aspx 2/4

6/10/13

PDF and Content-disposition filename - GrapeCity

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 filename and 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("contentdisposition","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:
www.datadynamics.com/forums/80317/PrintPost.aspx 3/4

6/10/13

PDF and Content-disposition filename - GrapeCity

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 web page 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.

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

4/4

Você também pode gostar