Copy link to clipboard
Copied
Get error message. aspx is of invalid format. Any help?
Copy link to clipboard
Copied
How did you download the PDF file?
Copy link to clipboard
Copied
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
Find more inspiration, events, and resources on the new Adobe Community
Explore Now