Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

pdf will not download

Guest
Mar 25, 2016 Mar 25, 2016

Get error message. aspx is of invalid format. Any help?

TOPICS
Acrobat SDK and JavaScript
363
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2016 Mar 26, 2016

How did you download the PDF file?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Mar 26, 2016 Mar 26, 2016
LATEST

If you have control of the .aspx source code, then make sure the output buffer is sending the correct MIME type and only sending the PDF data:

Note: Make sure it is only outputting the PDF, and not HTML or anything else:

A VB.NET Example:

Try

     Dim pdf_path_String as string = Server.MapPath("/path/to/document.pdf")

     Dim pdf_file_bytes() as byte = System.IO.File.ReadAllBytes(pdf_path_String)

     'Clears HTML and other stream data

     Response.Clear

     'Set MIME

     Response.ContentType = "application/pdf"

     'Output file

     Response.WriteFile(pdf_path_String)

     'OR output bytes

     'Response.BinaryWrite(pdf_file_bytes())

     ' Call Response.End to ensure nothing else is written to output stream

     Response.End

Catch Ex As Exception

     'NOTE: Important to trap and clear error; because, Response.End throws an exception

     Err.Clear

End Catch

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines