473,799 Members | 3,276 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Display PDF from database without caching

I am trying to display a PDF in the users browser that is pulled from a
binary field in our database, and keep that PDF from caching on the
client computer. I can successfully pull the PDF and display it using
the following code:

Response.Conten tType = "applicatio n/pdf"
Response.Binary Write objRS("Attachme nt")

where objRS("Attachme nt") is a reference to the binary field retrieved
from the database. However, I have tried adding virtually every header
known to have anything to do with caching, and I cannot seem to prevent
the PDF from caching in the client's browser. So then I tried to use
the adodb.stream object, as follows:

set objStream=serve r.createObject( "ADODB.Stre am")
objStream.Open
objStream.Type= 1 'adTypeBinary
objStream.write objRS.fields("A ttachment").val ue

Response.Conten tType = "applicatio n/pdf"
Response.Binary Write objStream.Read( )

This follows, more or less, several examples I've found on the web,
although most examples are reading a file into the stream, not a binary
field returned from a database. This code gives me the following
error:

Response object, ASP 0106 (0x80020005)
An unhandled data type was encountered.

I'm looking for a way to make the stream work, or any other suggestions
on how to display the pdf to the client without it caching in their
browser.

Sep 29 '06
14 11903

<ro*****@gmail. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
That's basically the conclusion that I had come to - there is a
Microsoft support document (several, actually) on the problem of
downloading PDF's over an SSL, but I'm not using SSL - actually, in
this particular scenario, the client may or may not use SSL (inside
the company they don't - outside they do). Anyway, I will experiment
some more with the private; no-store heading - at least now I know the
correct header - thanks.

As to the question about how do you prevent a client from just saving
the PDF - you don't, and as has been stated already, that is
irrelevant. Of course someone can just save the PDF from their browser
- that's not the concern. the concern is someone ELSE pulling from a
users cache without their knowledge. Basically I am dealing with
people's pay stubs in PDF form, so if they want to save it, fine - they
can do whatever they want with it. I just don't want people pulling
OTHER employees pay stubs from their internet caches - at home, at
work, at the library, etc, etc.
Yeah um just don't do that then.
Rather than mucking about with various headers lets just use the correct
headers for your requirement.

You want to attempt to stop the file from being cached at all. This
could
be a problem for PDFs.

The correct code to acheive this is:-

Response.CacheC ontrol = "private; no-store"

This informs all proxies between the origin server and the client not to
store a copy of the resource. It also tells the client that it should
not
keep a copy of the resource. (no-cache actually means keep a copy if
you
want but always check back with the origin server before using it)

The problem with this, at least with IE and PDFs, is that the
implementation
doesn't appear to be able to handle rendering a PDF stream directly, it
needs to map the stream in to a file so despite the http headers saying
otherwise it is stored anyway. Why it isn't deleted after it has been
finished with I don't know it ought to be possible.

Oct 3 '06 #11

ro*****@gmail.c om wrote:
That's basically the conclusion that I had come to - there is a
Microsoft support document (several, actually) on the problem of
downloading PDF's over an SSL, but I'm not using SSL - actually, in
this particular scenario, the client may or may not use SSL (inside
the company they don't - outside they do). Anyway, I will experiment
some more with the private; no-store heading - at least now I know the
correct header - thanks.

As to the question about how do you prevent a client from just saving
the PDF - you don't, and as has been stated already, that is
irrelevant. Of course someone can just save the PDF from their browser
- that's not the concern. the concern is someone ELSE pulling from a
users cache without their knowledge. Basically I am dealing with
people's pay stubs in PDF form, so if they want to save it, fine - they
can do whatever they want with it. I just don't want people pulling
OTHER employees pay stubs from their internet caches - at home, at
work, at the library, etc, etc.
Is password-protecting the PDFs not an option?

--
Mike Brind

Oct 3 '06 #12
Is password-protecting the PDFs not an option?

I wish. The pdf's are stored in the database by third party software,
so I have no control over how they are created. There may be some
option of pulling them out, password protecting them, then putting them
back in the database using some third-party pdf app, but I wouldn't
really know where to begin there...

Oct 5 '06 #13
Persits ASPPdf allows you to open existing PDF documents and alter their
security settings, including applying passwords.

http://www.asppdf.com/manual_08.html

You would probably have to create a temp copy of the PDF on the server,
apply new security settings to that, then stream it and delete the temp
file.

The 30 day evaluation is definitely worth taking up. And no, I'm not on
commission - I have found it to be a very good product :-)

--
Mike Brind
<ro*****@gmail. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
>Is password-protecting the PDFs not an option?

I wish. The pdf's are stored in the database by third party software,
so I have no control over how they are created. There may be some
option of pulling them out, password protecting them, then putting them
back in the database using some third-party pdf app, but I wouldn't
really know where to begin there...

Oct 5 '06 #14
Thanks for the reference, I will definitely look into it.

Mike Brind wrote:
Persits ASPPdf allows you to open existing PDF documents and alter their
security settings, including applying passwords.

http://www.asppdf.com/manual_08.html

You would probably have to create a temp copy of the PDF on the server,
apply new security settings to that, then stream it and delete the temp
file.

The 30 day evaluation is definitely worth taking up. And no, I'm not on
commission - I have found it to be a very good product :-)

--
Mike Brind
<ro*****@gmail. comwrote in message
news:11******** **************@ k70g2000cwa.goo glegroups.com.. .
Is password-protecting the PDFs not an option?
I wish. The pdf's are stored in the database by third party software,
so I have no control over how they are created. There may be some
option of pulling them out, password protecting them, then putting them
back in the database using some third-party pdf app, but I wouldn't
really know where to begin there...
Oct 5 '06 #15

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

Similar topics

19
2091
by: nospammmer | last post by:
Hello group, I have a rather general but interesting inquiry that is related to PHP and I hope this is the appropriate place to post it. I'm looking for a way to improve dramatically the performance of my PHP application. The application is getting slow as it is taking more load. It is performing a very high number of queries to a database, and I believe that this is taking up most of the ressources.
5
2216
by: Mark Kirkwood | last post by:
Dear all, Here is the first installment concerning ATA disks and RAID controller use in a database server. I happened to have a Solaris system to myself this week, so took the opportunity to use it as a "control". In this post I used the ATA RAID controller merely to enable UDMA 133 for an oldish x86 machine, the effect of any actual RAID level will (hopefully) be examined subsequently.
2
2057
by: Joe Shum | last post by:
Hi All: I am pretty new at ASP.NET development. Currently I need to build a Web Server app using C# and ASP.NET to automatically and repeatly refresh data changes at fixed intervals (2 to 30 secs) occurring at the server side, and refresh them at the table fields at the Browser screen without any user intervention. Typically, the user submit to the Server URL which returns a page that has a lot of table fields in it but without any...
19
2759
by: Andy B | last post by:
Hello, Sorry for this newbish question. Briefly, my problem: ------------------ I expect the database I'm working on to reach something in the order of 12-16 Gigabytes, and I am interested in understanding as much as I can about how I can make this go as fast as possible on a linux system. I haven't run such a large database before. The nature of the database is such that
1
1345
by: Ben Fidge | last post by:
What are best practices for page output caching on pages that are dynamically generated from database tables. Our site has left-hand navigation that is comprised of dynamically generated menus of product categories. The categories are taken from several database tables which rarely change. This left-hand navigation is included on every single page in the site and as such is wrapped up in a user-control. However, when I enabled caching...
17
4895
by: shineofleo | last post by:
Here is the situation: I wrote a VB programm, which stores all the information in a single Access database file using jet engine. It worked well, however one of my customs reported that there was some problems with this programm. I checked, the log files showed that the database was corrupted. The customer told me that there no 'illegal' operation such as pull out the plug, or kill the programm via task manager... So is there any...
9
1847
by: veg_all | last post by:
I have a script that takes collects info from various websites to compile a report. However whenever I run it, my web browser waits for the script to finish ( 1 minute ) before displaying the report. But my script is outputting data every few seconds . So is there a way to make my browser display the web page every few seconds and update automatically as more data comes?
3
1956
by: phil67b | last post by:
Hello everybody, I have a page rech.php where I'm doing a multi-criteria research Ex. choose your car model, choose your country. After validation of my form, on the same page, the lines will be displayed (I put a max limitation of 500 lines). Ex. list of cars Fiat to buy in UK. A clic on a line will bring me to the display page disp.php Ex. I will clic on the car n° 5 =<a href="disp.php?
3
1595
by: DNB | last post by:
I did post this message in C# group also... I would like to know what you guys think is the best way to access data: Asp.Net session vs. Database Queries. In our application we are using asp.net tree view to display hierarchical data and when user clicks on particular node it brings up totally different page with all the asp.net controls dynamically generated.
0
9687
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10484
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10251
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9072
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7565
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3759
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.