Re: Force Download PDF Problem



If, by some chance, you have entered an IIS->asp.net mapping for PDF
documents, delete it. The problem will go away. This happened to me
when I tried to add a mapping so as to allow for asp.net to control
security on PDF documents.

gaubo79 wrote:
> I am wishing to force the Open|Save dialog box for a PDF and Excel
> file.
>
> I am using the following code:
>
> Response.Clear();
> Response.ContentType = "application/octet-stream";
> Response.AddHeader("Content-Disposition", "attachment; filename=" +
> saveFilename );
> Response.Flush();
> Response.WriteFile(savePath);
>
> While this works perfect for the Excel file, however, the PDF file does
> not open, whether direct from the dialog box or by saving it to disk
> and opening it, I get the following error in Adobe Acrobat Reader (v5.0
> & v7.0):
>
> "There was an error opening this document. The file is damaged and
> could not be repaired."
>
> The original PDF file is okay. Also, the size of the original PDF is
> 50k, where as the one that is downloaded to the client is 237k.
>
> I have tried various other things such as creating a FileStream and
> using Response.BinaryWrite, and various other ContentTypes, including
> application/pdf.
>
> Has anyone had this before, or know of a workaround? Ideally I would
> like the dialog box to always appear for this pdf.

.



Relevant Pages

  • impact of mapping .??? to ASP.NET ISAPI???
    ... good to secure ASPX pages, but those pages contains images, links to PDF ... I know that ISP don't like mapping those files... ... Also tell me if there would be other easy solution to help me ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Force Download PDF Problem
    ... >> While this works perfect for the Excel file, however, the PDF file does ... >> "There was an error opening this document. ... the size of the original PDF is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Force Download PDF Problem
    ... > While this works perfect for the Excel file, however, the PDF file does ... > "There was an error opening this document. ... the size of the original PDF is ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: impact of mapping .??? to ASP.NET ISAPI???
    ... look at only mapping the the files you really need to be handled by ... > Form Security with those files. ... > good to secure ASPX pages, but those pages contains images, links to PDF ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Force Download PDF Problem
    ... > security on PDF documents. ... >> While this works perfect for the Excel file, however, the PDF file does ... >> "There was an error opening this document. ... the size of the original PDF is ...
    (microsoft.public.dotnet.framework.aspnet)