Home All Groups Group Topic Archive Search About


Author
5 Nov 2007 10:13 AM
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)
-------------------------------------------------------------------------

Regards

Author
5 Nov 2007 10:21 AM
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



--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Author
5 Nov 2007 5:42 PM
e_marquess
Show quote
On 5 Nov, 10:21, "Evertjan." <exjxw.hannivo***@interxnl.net> wrote:
>  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
>
> --
> Evertjan.
> The Netherlands.
> (Please change the x'es to dots in my emailaddress)

Many thanks Evertjan.

Your solution works perfectly !

AddThis Social Bookmark Button