NetTalk Central
NetTalk Web Server => Web Server - Ask For Help => Topic started by: jking on October 18, 2024, 03:51:06 PM
-
Hello all,
I have setup a simple Clarion report to output as a PDF using the Clarion Report to PDF template. I do get the report generated in a new browser tab but when I try to save it to the local drive, it defaults to the name of the report procedure. I have tried the following code in numerous report procedure embeds without success:
loc:PDFName = '.\PREDICT2 Study ID Assignment_'&p_web.GSV('Enr:Study_ID')&'.pdf'
Some of the embeds I have tried:
PDF (PDFReportGenerator), Setup, after parent call
Previewer (PrintPreviewClass), OnSaveAs
Prime Report Options when run in web mode
Can anyone tell me how this should be done?
Thanks,
Jeff King
-
Hello everyone,
I think I found a solution, after looking at more posts here. In the PDF (PDFReportGenerator) Setup embed, I have the following:
p_web.HeaderDetails.ContentDisposition = 'filename="PREDICT2 Study ID Assignment_'&p_web.GSV('Enr:Study_ID')&'.pdf"'
The generated PDF displays in a new browser tab (have report set to use '_blank') and when I click to download the PDF, it now has a unique filename filled in for me. The filename no longer defaults to the procedure name. Next I'll test how this does with a few other browsers.
Thanks,
Jeff
-
Hi Jeff,
I use an Embed "RenameFile PROCEDURE in the Web Handler - after Parent call: ( this renames a file and sets the correct path for the chosen data set)
!MESSAGE('pname ' & p_name)
if p_name = 'upfilename' ! uploading schedule file
locpath = p_web.GSV('tProvRptDir') ! this is the provider file
! message('report dir ' & locpath)
locpath = clip(locpath) & '\INFILE\' ! this adds the Infile path
! message('upload path: ' & locpath)
RETURNVALUE = Parent.RenameFile(p_name,p_filename,locpath)
RETURN RETURNVALUE
END
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Second: This sends a file which is stored in a BLOB - get the blob, check it to see if it holds a file, if it does then extract it and send it
WebHandler - -SendFile PROCEDURE
Data section:
blobname StringTheory
sendstring StringTheory
CODE - Before Parent Call
!! working on generic code in the class to do this. This is for making a file from BLOB to send
Access:Blobfile.Open()
Access:Blobfile.UseFile()
blobname.SetValue(sub(p_FileName,len(clip(self.site.WebFolderPath)) + 2,255))
if blobname.sub(1,1) = '/' then blobname.setvalue(blobname.sub(2,255)).
blobname.replace('/','\')
BF:FileName = blobname.GetValue()
If Access:Blobfile.Fetch(BF:NameKey) = 0
sendstring.FromBlob(BF:Bin)
! allows the browser to cache this file.
! self.ForceNoCache = false
self.HeaderDetails.CacheControl = ''
self.FileDate = today() - 200
self.FileTime = 6000 !clock()
! or tell browser not to cache file
self.ForceNoCache = true
! end of cache settings
self.SendString(sendString,1,0,true)
loc:done = true
End
Access:Blobfile.Close()
If loc:done then return.
-------------------------------------------------------------------
Hopefully these two code snippets will help you get done what you need to get done.
Ron