G
GJK
Hello,
I am trying to download a pdf file using HTTPWebRequest class and then
save the downloaded pdf to a SQL Server 2005 database image column and
then display the pdf on a web app.
When I try to display the PDF, Adobe reader comes up and shows an error
msg "an uncrecognized token aID was found".
Here is my code to download
Dim binByte As Byte()
ResponseStreamRdr = New StreamReader(theResponse.GetResponseStream(),
New UnicodeEncoding)
Dim objMemoryStream As New MemoryStream(New
UnicodeEncoding().GetBytes(ResponseStreamRdr.ReadToEnd()))
binByte = objMemoryStream.ToArray()
return binByte
Then I write store the binByte to an image datatype column in SQL
Server which works.
Then I try to display the pdf using the following code where I get the
error "an uncrecognized token aID was found".
byte[] bteContent = (byte[])dr["file_content"];
Response.AddHeader("Content-Disposition","attachment;filename=" +
fileName);
Response.OutputStream.Write(bteContent, 0, bteContent.Length);
Response.Flush();
Response.End();
Any idea what is wrong with the code?
Note: One thing I noticed during debugging:
theResponse.contentlength=22069 where as objMemoryStream.Length
=21890.
Does this has to do something with pdf corruption. Why is this
difference?
I am trying to download a pdf file using HTTPWebRequest class and then
save the downloaded pdf to a SQL Server 2005 database image column and
then display the pdf on a web app.
When I try to display the PDF, Adobe reader comes up and shows an error
msg "an uncrecognized token aID was found".
Here is my code to download
Dim binByte As Byte()
ResponseStreamRdr = New StreamReader(theResponse.GetResponseStream(),
New UnicodeEncoding)
Dim objMemoryStream As New MemoryStream(New
UnicodeEncoding().GetBytes(ResponseStreamRdr.ReadToEnd()))
binByte = objMemoryStream.ToArray()
return binByte
Then I write store the binByte to an image datatype column in SQL
Server which works.
Then I try to display the pdf using the following code where I get the
error "an uncrecognized token aID was found".
byte[] bteContent = (byte[])dr["file_content"];
Response.AddHeader("Content-Disposition","attachment;filename=" +
fileName);
Response.OutputStream.Write(bteContent, 0, bteContent.Length);
Response.Flush();
Response.End();
Any idea what is wrong with the code?
Note: One thing I noticed during debugging:
theResponse.contentlength=22069 where as objMemoryStream.Length
=21890.
Does this has to do something with pdf corruption. Why is this
difference?