PDF cache problem

Discussion in 'ASP General' started by e_marquess@hotmail.com, Nov 5, 2007.

  1. Guest

    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
    , Nov 5, 2007
    #1
    1. Advertising

  2. Evertjan. Guest

    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)
    Evertjan., Nov 5, 2007
    #2
    1. Advertising

  3. Guest

    On 5 Nov, 10:21, "Evertjan." <> 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 !
    , Nov 5, 2007
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Nokes

    Cache::Cache Stale Segments

    Jeff Nokes, Sep 30, 2003, in forum: Perl
    Replies:
    0
    Views:
    570
    Jeff Nokes
    Sep 30, 2003
  2. DesignerX

    Page.Cache vs HttpContext.Current.Cache

    DesignerX, Jan 20, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    8,243
    vMike
    Jan 20, 2004
  3. =?Utf-8?B?b25l?=
    Replies:
    1
    Views:
    5,280
    Karl Seguin [MVP]
    Mar 8, 2006
  4. Ricardo Pog
    Replies:
    1
    Views:
    416
    Austin Ziegler
    Mar 26, 2008
  5. Sean Nakasone
    Replies:
    1
    Views:
    355
    Farrel Lifson
    Apr 14, 2008
Loading...

Share This Page