473,568 Members | 2,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using BinaryWrite to output PDF to IE

Hi,

I've created a small application for our company extranet (staff bulletins)
that outputs a list of links to PDF's that are stored in a SQL table. The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than specifically IE,
but as the system works using FireFox, I am guessing it is the relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al

Mar 24 '06 #1
6 4901
It didn't fail on this client. Are you sure that the Adobe acrobat reader
was installed on the machine on which it failed? Can you describe in detail
what you mean by "failed?"

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:e0******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

I've created a small application for our company extranet (staff
bulletins)
that outputs a list of links to PDF's that are stored in a SQL table. The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than specifically
IE,
but as the system works using FireFox, I am guessing it is the
relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al

Mar 24 '06 #2
Hi Kevin,

Thanks for your feedback. You don't mention your OS/browser versions - this
might help me a bit. I know it works when using Firefox.

Yes, Adobe Reader (v.7) is installed on all the machines accessing the
pages.

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in use by another application."

I've been searching further afield and note that a few people have logged
similar problems, particularly for PDF output.

One suggestion is to alter the metabase.xml file to allow greater sizes of
AspBufferingLim it, e.g. set it to "2000000000 " (2Gb).
However, the test files I'm using are only in the 85Kb range, so clearly
shouldn't be a problem for the default limit of 4Mb.

Interestingly, the XP PC I'm using to develop on doesn't have a
metabase.xml - presumably one of the differences between the versions of IIS
for XP and Windows Server 2003.

Al

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Oi******** ******@tk2msftn gp13.phx.gbl...
It didn't fail on this client. Are you sure that the Adobe acrobat reader
was installed on the machine on which it failed? Can you describe in
detail what you mean by "failed?"

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:e0******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

I've created a small application for our company extranet (staff
bulletins)
that outputs a list of links to PDF's that are stored in a SQL table.
The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by
putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than specifically
IE,
but as the system works using FireFox, I am guessing it is the
relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al


Mar 24 '06 #3
Hi Alec,

I was able to duplicate the problem by making multiple requests for the file
with multiple browser instances. I'm running XP/IE 6, BTW. I was able to
reproduce the problem on both IE and FireFox. The error is coming from the
Acrobat Reader, alright. I can only guess at the cause, as it doesn't give
any additional information, or log the error. You may want to contact their
support group.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:OH******** ******@TK2MSFTN GP14.phx.gbl...
Hi Kevin,

Thanks for your feedback. You don't mention your OS/browser versions -
this might help me a bit. I know it works when using Firefox.

Yes, Adobe Reader (v.7) is installed on all the machines accessing the
pages.

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in use by another application."

I've been searching further afield and note that a few people have logged
similar problems, particularly for PDF output.

One suggestion is to alter the metabase.xml file to allow greater sizes of
AspBufferingLim it, e.g. set it to "2000000000 " (2Gb).
However, the test files I'm using are only in the 85Kb range, so clearly
shouldn't be a problem for the default limit of 4Mb.

Interestingly, the XP PC I'm using to develop on doesn't have a
metabase.xml - presumably one of the differences between the versions of
IIS for XP and Windows Server 2003.

Al

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Oi******** ******@tk2msftn gp13.phx.gbl...
It didn't fail on this client. Are you sure that the Adobe acrobat reader
was installed on the machine on which it failed? Can you describe in
detail what you mean by "failed?"

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:e0******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

I've created a small application for our company extranet (staff
bulletins)
that outputs a list of links to PDF's that are stored in a SQL table.
The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but
no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by
putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than specifically
IE,
but as the system works using FireFox, I am guessing it is the
relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al



Mar 24 '06 #4
It worked for me as well. Running XP Pro SP2 with all security
updates. Adobe 7.0 and IE version 6
(6.0.2900.2180. xpsp_sp2_gdr.05 0301-1519 to be exact). Hope this helps
you find your problem. And it also worked for me via FireFox.

Well after I typed that I clicked on your link again and got the error
that you received. Unfortunately I don't have any suggestions on how
to resolve the problem at the moment. I do have an observation. The
pdf opened in FireFox while I got an external reader window and a blank
browser screen via IE. Perhaps a client side process isn't being
cleaned up?

Mar 24 '06 #5
Hi Alec,

In my guess, it seems that you open pdf file then write to browser. But you
forget to close the pdf file. Because I can open it in the first time. Then
no matter I use IE, Firefox, or NS, I cannot open it any more.

HTH

Elton Wang

"Alec MacLean" wrote:
Hi Kevin,

Thanks for your feedback. You don't mention your OS/browser versions - this
might help me a bit. I know it works when using Firefox.

Yes, Adobe Reader (v.7) is installed on all the machines accessing the
pages.

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in use by another application."

I've been searching further afield and note that a few people have logged
similar problems, particularly for PDF output.

One suggestion is to alter the metabase.xml file to allow greater sizes of
AspBufferingLim it, e.g. set it to "2000000000 " (2Gb).
However, the test files I'm using are only in the 85Kb range, so clearly
shouldn't be a problem for the default limit of 4Mb.

Interestingly, the XP PC I'm using to develop on doesn't have a
metabase.xml - presumably one of the differences between the versions of IIS
for XP and Windows Server 2003.

Al

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Oi******** ******@tk2msftn gp13.phx.gbl...
It didn't fail on this client. Are you sure that the Adobe acrobat reader
was installed on the machine on which it failed? Can you describe in
detail what you mean by "failed?"

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:e0******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

I've created a small application for our company extranet (staff
bulletins)
that outputs a list of links to PDF's that are stored in a SQL table.
The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by
putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than specifically
IE,
but as the system works using FireFox, I am guessing it is the
relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al



Mar 26 '06 #6
In case anyone was monitoring this thread...

I have managed to create a work-around.

In my original version, I was setting the target of the link to the display
aspx as "_new". (This is a hyperlink control set as a template column on a
datagrid). By removing this target option (leaving it blank) and setting
the output header for "Content-Disposition" to "attachment " instead of
"inline", I now get the prompt from Adobe Reader to Open or Save the target
PDF. I no longer get the blank IE window at all.

While not my original intention, this is close to my desired aim and at
least is more intuitive to use for my end-users than having two windows pop
up with one (the IE window) being empty. The menu of PDF's remains in the
background, and the Adobe Reader floats wherever they want it. Close the
reader and they still have the pdf list.

Al
"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:e8******** ******@TK2MSFTN GP09.phx.gbl...
Hi Alec,

I was able to duplicate the problem by making multiple requests for the
file with multiple browser instances. I'm running XP/IE 6, BTW. I was able
to reproduce the problem on both IE and FireFox. The error is coming from
the Acrobat Reader, alright. I can only guess at the cause, as it doesn't
give any additional information, or log the error. You may want to contact
their support group.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:OH******** ******@TK2MSFTN GP14.phx.gbl...
Hi Kevin,

Thanks for your feedback. You don't mention your OS/browser versions -
this might help me a bit. I know it works when using Firefox.

Yes, Adobe Reader (v.7) is installed on all the machines accessing the
pages.

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open or
in use by another application."

I've been searching further afield and note that a few people have logged
similar problems, particularly for PDF output.

One suggestion is to alter the metabase.xml file to allow greater sizes
of AspBufferingLim it, e.g. set it to "2000000000 " (2Gb).
However, the test files I'm using are only in the 85Kb range, so clearly
shouldn't be a problem for the default limit of 4Mb.

Interestingly, the XP PC I'm using to develop on doesn't have a
metabase.xml - presumably one of the differences between the versions of
IIS for XP and Windows Server 2003.

Al

"Kevin Spencer" <ke***@DIESPAMM ERSDIEtakempis. com> wrote in message
news:Oi******** ******@tk2msftn gp13.phx.gbl...
It didn't fail on this client. Are you sure that the Adobe acrobat
reader was installed on the machine on which it failed? Can you describe
in detail what you mean by "failed?"

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

"Alec MacLean" <al**********@N O-SPAM-copeohs.com> wrote in message
news:e0******** *****@TK2MSFTNG P10.phx.gbl...
Hi,

I've created a small application for our company extranet (staff
bulletins)
that outputs a list of links to PDF's that are stored in a SQL table.
The
user clicks a link and the PDF is loaded into a new browser window.

This works as expected on the test PC (using forms authentication, but
no
SSL) using IE. It also works as expected on the production server when
using FireFox. The production server environment is using forms
authentication and SSL.

However the PDF load fails when using IE as the browser to access the
production server (which my users/staff colleagues will be doing).

I have also tested it without using SSL or Forms authentication by
putting
it on our public site on the production server.
This also means you can (temporarily) see the problem for yourself
at: www.copeohs.com/ebulletins/bulletins.aspx

The error seems to be generated by Adobe Reader rather than
specifically IE,
but as the system works using FireFox, I am guessing it is the
relationship
between IE and Adobe Reader that is the problem?

The Adobe Reader error message provided is:
"There was an error opening this document. This file is already open
or in
use by another application."

I am using VB.NET 1.1 on IIS 6 (win 2003 svr).

Code snippet that outputs the PDF from the DB:
--------------------------------------------------------
'The required file ID comes from the querystring.
If Me.Request.IsAu thenticated Then
If Request.QuerySt ring.Count <> 0 Then
'Get the (pdf) filename to display
Me.FileID = CInt(Request.Qu eryString("doc" ).ToString)
Dim ds As New DataSet
Dim PDFfileSize As Long
Dim db As Database = DatabaseFactory .CreateDatabase
Dim cmd As DBCommandWrappe r =
db.GetStoredPro cCommandWrapper ("usp_Bulletin_ Single_SELECT")
cmd.AddInParame ter("@BID", DbType.Int32, Me.FileID)

Try
Me.lblErr.Visib le = False
'Load the record (PDF file) into local dataset
db.LoadDataSet( cmd, ds, "theBulleti n")

'Resize the byte array for file
PDFfileSize =
CLng(ds.Tables( "theBulletin"). Rows(0).Item("B File").length)
Dim thePDF(CInt(PDF fileSize)) As Byte

'Put the PDf into the byte array
thePDF = ds.Tables("theB ulletin").Rows( 0).Item("BFile" )

'Send the file to the output stream
Response.Buffer Output = True

'Try and ensure the browser always opens the file and doesn't just
prompt to "open/save".
Response.AddHea der("Content-Disposition", "inline")

'Set the output stream to the correct content type (PDF).
Response.Conten tType = "applicatio n/pdf"

'Output the file
Response.Binary Write(thePDF)

thePDF = Nothing

Catch ex As Exception
Me.lblErr.Visib le = True
Me.lblErr.Text = ex.Message.ToSt ring

Finally
'Tidy memory
ds = Nothing
cmd = Nothing
db = Nothing
End Try

End If
Else
Response.Redire ct("/logon/applist.aspx")
End If
--------------------------------------------------------

I would greatly appreciate any help/ideas offered...thank s in advance.

Al




Mar 31 '06 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3873
by: Kevin Humphreys | last post by:
Hi, How can I output the Response.BinaryWrite content in an asp page that has html tags inside? I need to write the binary data to the client browser inside the html tags. Thanks In Advance, Kevin.
1
3387
by: unotin | last post by:
I have an application in ASP that exports to Word using the Response.ContentType method. The application references another ASP page through the img tag that uses a Response.BinaryWrite (of an img content type) for its output. In other words: App A.ASP contains the code: <%Response.ContentType = "application/vnd-msword"%> <img...
2
6125
by: Bammer22 | last post by:
I am trying to BinaryWrite an image from a binary string that I am storing in the web.config file. The image is just a 1x1 pixel gif. I am setting the content type to "image/gif", but the output is just my string. Any suggestions? Code is below byte bytes = Encoding.UTF8.GetBytes(ConfigurationSettings.AppSettings.ToString())...
15
4383
by: A. Gharbeia | last post by:
Greetings: It turned out that using COM objects from .NET C# isn't straight forward at all. Now, I have successfully used reflection to instantiate the object, and invoked the methods and properties through Type.InvokeMember, but... One property whose value I retrieve through : TImagingObject.InvokeMember("JPGData",...
3
1519
by: Anders | last post by:
Hi, This is the code I am using: string filepath = "Themes/img/logo.rar"; string filename = System.IO.Path.GetFileName(filepath); Response.Clear(); Response.ContentType = "application/zip";
7
7582
by: Jim | last post by:
I am trying to display images that are stored in a database, and I am using a repeater control. What I still use the Response.BinaryWrite method with a binding expression, if so, what with the code look like?
3
3067
by: Hitesh | last post by:
Hi, I am getting the response from another Website by using the HttpHandler in my current site. I am getting the page but all the images on that page are not appearing only placeholder are displayed. Can anybody know this issue and help me to resolve this. In past i received the response saying that i should download the image first...
0
1569
by: csgraham74 | last post by:
Hi guys back again with another issue. im trying to develop an application which displays a pdf document using the binary.write method. i have 2 pages A and B what i want to do is to load my pdf document on the load event of page B (ie it gives me the open or save option) and have page b loaded in the browser with the pdf cancel save...
14
11881
by: S N | last post by:
I am using the following code to hide the download url of files on my website. The code uses Response.Binarywrite to send file to the client. Kindly indicate the maximum size of the file that can be downloaded using this method. I am hosting this site on a public server, so I will not be able to change anything on the webserver. Kindly indicate...
0
7604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8117
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7660
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6275
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5498
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2101
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1207
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.