PDF cache problem

E

e_marquess

I have been successful in getting Persits ASPPDF to create pdf files
for me but I have run into a problem.

I have a page to create my pdf from a dynamic asp page. Each time the
script runs it overwrites the previous pdf file. I then use
response.redirect to load the pdf file in the browser.

The problem is that the browser always displays the previous pdf file
until you click the refresh button. I've check to make sure that the
new pdf file is always created on the server - it is ! So I assume
this must be a problem with browser cache retaining the previous
file.

I tried all sorts of ways to solve this but to no avail. Any ideas
would be much appreciated :)

This is the relevant code :

---------------------------------------------------------------------
<!-- CREATE VARIABLE TO HOLD THE URL -->
string1 = "http://www.thecareersroom.com/wx/admin/employ_letter.asp?
Rec_ID=" & Recordset1.Fields.Item("Rec_ID").Value

<!-- CREATE AND SAVE THE PDF FILE -->
Set Pdf = Server.CreateObject("Persits.Pdf")
Set Doc = Pdf.CreateDocument
Doc.ImportFromUrl string1, "LeftMargin=50", "RightMargin=10",
"PageWidth=650"

Filename = Doc.Save( Server.MapPath("employ_letter.pdf"), True )

<!-- -LOAD TO THE BROWSER ->
Response.CacheControl = "private; no-store"
response.ContentType = "application/pdf"
response.Redirect(Filename)
 
E

Evertjan.

wrote on 05 nov 2007 in microsoft.public.inetserver.asp.general:
<!-- -LOAD TO THE BROWSER ->
Response.CacheControl = "private; no-store"
response.ContentType = "application/pdf"

These two have no influence on the header of the redirect target file.
response.Redirect(Filename)

You could send the pdf as a bitstream with the above headers

function pdf(file)
Response.Clear

strFileName = file
strFilePath = server.mappath(strFilename)

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open

objStream.Type = 1
objStream.LoadFromFile strFilePath
Response.ContentType = "application/pdf"
Response.CacheControl = "private; no-store"
Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.end
end function
 
E

e_marquess

wrote on 05 nov 2007 in microsoft.public.inetserver.asp.general:


These two have no influence on the header of the redirect target file.


You could send the pdf as a bitstream with the above headers

function pdf(file)
Response.Clear

strFileName = file
strFilePath = server.mappath(strFilename)

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open

objStream.Type = 1
objStream.LoadFromFile strFilePath
Response.ContentType = "application/pdf"
Response.CacheControl = "private; no-store"
Response.BinaryWrite objStream.Read

objStream.Close
Set objStream = Nothing
Response.end
end function

Many thanks Evertjan.

Your solution works perfectly !
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,185
Members
46,736
Latest member
AdolphBig6

Latest Threads

Top