Streaming PDF to IE 6.0 browser

  • Thread starter Thread starter Alhambra Eidos Kiquenet
  • Start date Start date
A

Alhambra Eidos Kiquenet

Hi all misters,

I hope someone can help me here.

Here is my problem.

I stream the PDF files to the browser because they contain private
information and they are not located within the web site itself. The
application opens the PDF file and then streams it to the browser. I call to
ASPX page like this: ShowFile.aspx?IDFILE=100&NAME=000040.pdf.

The aspx page calls WCF service and gets all bytes of a PDF file.

When streams bytes of PDF file to browser, Acrobat Reader OCX reads bytes
and shows PDF, the user can save PDF to disk file with a name.

I want that the filename could be the NAME querystring parameter.

I try but doesn't works fine.

Here is the code that I use:

Thanks for any help you can offer, thanks in advance, any help will be very
grateful, regards, greetings



Response.Buffer = True '//<<- Va con el Response.Flush();

'Response.BufferOutput = True

Response.Clear()

Response.ClearContent()

Response.ClearHeaders()

'Response.CacheControl = "Private" 'Public



Response.AddHeader("Accept-Header", tamanoFichero.ToString())

Response.AddHeader("Content-Size", tamanoFichero.ToString())

Response.AddHeader("Content-Length", tamanoFichero.ToString())

Dim abrirEnAcrobatReader As Boolean = False

If abrirEnAcrobatReader Then

' Aparecería un cuadro de diálogo para Abrir o Guardar fichero

Response.AddHeader("Content-Disposition", "attachment; filename=" +
Path.GetFileName(nombreFichero))

Else

Response.AddHeader("Content-Disposition", "inline;filename=" + nombreFichero)

End If

'Response.AddHeader("Content-Disposition", "attachment; filename=" & fn)

'Response.AddHeader("Content-Disposition", "attachment; filename=" & fn & ";")

'Response.AddHeader("Content-Disposition", "inline; filename=" & fn)

'Response.AddHeader("Content-Disposition", "inline; filename=" & fn & ";")

'Response.AddHeader("Content-Disposition", "filename=" & fn)

'Response.AddHeader("Content-Disposition", "filename=" & fn & ";")

Response.AddHeader("Expires", "0")

Response.AddHeader("Pragma", "cache")

Response.AddHeader("Cache-Control", "private")





'//Set the output stream to the correct content type (PDF).

Response.ContentType = sMimeType

'Response.AddHeader("Content-Type", sMimeType)

Response.AddHeader("Accept-Ranges", "bytes")

Response.Charset = ""

Response.BinaryWrite(infoFichero.ContenidoFichero)

Response.Flush()

'Response.WriteFile(fichero)

'Response.Close()

Response.End()
 
Hi all misters,

I hope someone can help me here.

Here is my problem.  

I stream the PDF files to the browser because they contain private
information and they are not located within the web site itself.  The
application opens the PDF file and then streams it to the browser.  I call to
ASPX page like this: ShowFile.aspx?IDFILE=100&NAME=000040.pdf.

The aspx page calls WCF service and gets all bytes of a PDF file.

When streams bytes of PDF file to browser, Acrobat Reader OCX reads bytes
and shows PDF, the user can save PDF to disk file with a name.

I want that the filename could be the NAME querystring parameter.

I try but doesn't works fine.

Here is the code that I use:

Thanks for any help you can offer, thanks in advance, any help will be very
grateful, regards, greetings

Response.Buffer = True '//<<- Va con el Response.Flush();

'Response.BufferOutput = True

Response.Clear()

Response.ClearContent()

Response.ClearHeaders()

'Response.CacheControl = "Private" 'Public

Response.AddHeader("Accept-Header", tamanoFichero.ToString())

Response.AddHeader("Content-Size", tamanoFichero.ToString())

Response.AddHeader("Content-Length", tamanoFichero.ToString())

Dim abrirEnAcrobatReader As Boolean = False

If abrirEnAcrobatReader Then

' Aparecería un cuadro de diálogo para Abrir o Guardar fichero

Response.AddHeader("Content-Disposition", "attachment; filename=" +
Path.GetFileName(nombreFichero))

Else

Response.AddHeader("Content-Disposition", "inline;filename=" + nombreFichero)

End If

'Response.AddHeader("Content-Disposition", "attachment; filename=" & fn)

'Response.AddHeader("Content-Disposition", "attachment; filename=" & fn& ";")

'Response.AddHeader("Content-Disposition", "inline; filename=" & fn)

'Response.AddHeader("Content-Disposition", "inline; filename=" & fn & ";")

'Response.AddHeader("Content-Disposition", "filename=" & fn)

'Response.AddHeader("Content-Disposition", "filename=" & fn & ";")

Response.AddHeader("Expires", "0")

Response.AddHeader("Pragma", "cache")

Response.AddHeader("Cache-Control", "private")

'//Set the output stream to the correct content type (PDF).

Response.ContentType = sMimeType

'Response.AddHeader("Content-Type", sMimeType)

Response.AddHeader("Accept-Ranges", "bytes")

Response.Charset = ""


Maybe this code below is a problem? What has
infoFichero.ContenidoFichero exactly, did you check it?
 
Thanks, mister.

ContenidoFichero is Byte(), array of bytes of the file.

I'm sure, that I get all bytes right.

Greetings.
 
Thanks, mister.

ContenidoFichero is Byte(), array of bytes of the file.

I'm sure, that I get all bytes right.

Greetings.




- Show quoted text -

Oh, sorry, now I see what the question is. You added the file name for
the download stream at the following line

Response.AddHeader("Content-Disposition", "attachment; filename=" +
Path.GetFileName(nombreFichero))

The Filename parameter is used to suggest a file name in the download
dialog. I think you would need to change it

Response.AddHeader("Content-Disposition", "attachment; filename=" +
Request.QueryString("NAME"))
 
Back
Top