64 users online (1 members and 63 guests)  


  Results 1 to 3 of 3

Related

  1. Replies: 6
  2. Replies: 4
  3. Warning - Spyware Programs that KILL affiliate cookies    Forum: Affiliate Marketing and Reseller Programs
    Replies: 6
  1. #1
    dlongnecker's Avatar
    Tired Student...(Z_z)

    Status
    Offline
    Join Date
    Aug 2004
    Location
    Wichita, KS
    Posts
    86

    Create and Kill temporary files?

    Okay, this is a followup to the post on Creating PDFs Dynamically. I've figured out the nitty gritty details of creating the PDFs and shooting them to the user; however, as I want to maintain a nice, clean web server and don't want to schedule tasks to clean out these PDFs... how can I redirect them to the PDF, but delete the file?

    Here's the code I have:

    Code:
    <% @Language="VBScript" %>
    <%
    Response.Buffer = True
    %>
    
    <%
    Set theDoc = Server.CreateObject("ABCpdf4.Doc")
    theDoc.Rect.Inset 20, 20
    theURL = Request.ServerVariables("HTTP_REFERER") & "&medium=printer"
    response.Write(theURL)
    theID = theDoc.AddImageUrl(theURL, True, 0, False)
    Do
    	theDoc.FrameRect
    	If theDoc.GetInfo(theID, "Truncated") <> "1" Then Exit Do
    	theDoc.Page = theDoc.AddPage()
    	theID = theDoc.AddImageToChain(theID)
    Loop
    For i = 1 To theDoc.PageCount
    	theDoc.PageNumber = i
    	theDoc.Flatten
    Next
    	filepath = "c:\inetpub\wwwroot\customers\cer\pdfs\"
    	relativepath = "pdfs/"
    	filename = Replace(CStr(CDbl(Now)) & CStr(Timer), ".", "") & ".pdf"
    	theDoc.Save filepath & filename
    	
    	response.addheader "content-disposition","attachment; filename='" & Filename & "'"
    		response.Redirect(relativepath & filename)
    	
    	Set objFSO = Server.CreateObject("Scripting.FileSystemObject")
    		objFSO.DeleteFile(filepath & filename)
    Something better than the response.redirect?

    This "works"; I just can't delete the file because... it's already redirected. I considered a popup window... but ewww...

    Ideas?

    -David

  2. #2
    QuietDean's Avatar
    Administrator

    Status
    Offline
    Join Date
    Oct 2000
    Location
    Bournemouth, UK
    Posts
    2,662
    Would it make more sense to create the PDF dynamically in an ASP script, then write directly to the browser? You can set a content-type of application/pdf, then write to standard output instead of to a file.

    However..I can't remember if you can actually do this with abcPDF.
    Other than that, you could check for an existing file on page load, and delete that one first before creating the new one. As long as its older than 5 minutes, say.
    If one of our members helps you, please click the icon to add to their reputation!
    No support via email or private message - use the forums!
    Before you ask, have you Searched?

  3. #3
    dlongnecker's Avatar
    Tired Student...(Z_z)

    Status
    Offline
    Join Date
    Aug 2004
    Location
    Wichita, KS
    Posts
    86
    The page I posted actually is a createpdf.asp (real original, huh?). The main page's menu points to this ASP page (hence the URL = HTTP_REFERRER), reforms it based on a specific style sheet (the &medium=printer), and proceeds to generate the PDF. The PDF generation works flawlessly (I danced). I guess I'm not sure how to directly write to the screen--if I even can. I'll check that options for saving I have besides .Save--a quick glance while typing hasn't turned up anything that might work.

    Thanks!

    -David



Tags for this Thread