NetTalk Central

Author Topic: Where to Rename PDF before emailing  (Read 5740 times)

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Where to Rename PDF before emailing
« on: July 19, 2016, 06:07:57 PM »
Hi All:  I'm using the Tracker PDF tools to produce pdf's that get attached to emails from the webserver.  Having the $$$ in front of the pdf file looks suspicious to some so I'd like to rename the files before they are sent.  Where is the best place to do that, please?

Thanks,

Jim

Clarion 10, Nettalk 9.11

terryd

  • Hero Member
  • *****
  • Posts: 759
    • View Profile
    • Davcomm
    • Email
Re: Where to Rename PDF before emailing
« Reply #1 on: July 20, 2016, 01:48:05 AM »
Hi Jim
If you are using PDF tools you can name the file in the After Opening Report embed.
Terry Davidson
Windows 10 64 bit/Windows7 64bit
Clarion 9.1.11529/Clarion10 12567
Nettalk 913
Nettalk 1015
StringTheory267/Winevent515/XFiles298/MessageBox239/Cryptonite186

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Where to Rename PDF before emailing
« Reply #2 on: July 20, 2016, 03:25:39 AM »
Thanks Terry.  Wasn't even thinking about that.

Best,

Jim

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Where to Rename PDF before emailing -- Doesn't Work
« Reply #3 on: July 20, 2016, 08:08:39 AM »
Maybe I'm putting the code in the wrong embed point in the report procedure, but I'm not getting the pdf named as I'd like or expect it to be. 

My hunch is that it may have to happen in the webhandler...but I'm not sure where.


Thanks.

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Where to Rename PDF before emailing
« Reply #4 on: July 20, 2016, 08:12:54 AM »
NM.  Just found it in the source of the report.  Will handle it there.

Sorry.

Stu

  • Hero Member
  • *****
  • Posts: 510
    • View Profile
    • Email
Re: Where to Rename PDF before emailing
« Reply #5 on: July 25, 2016, 03:59:03 PM »
Just for any future reference to this.

You absolutely can rename files in Webhandler, and if you're building a system that allows people to download files from links (ie, here's a link instead of an attachment), then it's a great thing to understand.

_SendFile, before the Parent Call, is where you can do it.

The thinking is, simply, if I rename a file then it's something I want the person to download (because in here all kinds of things are dealt with).

My code is:

Code: [Select]
!** SEND the actual file **
  if (found# = 1)
    Debug('('&sa:ProcedureName&', Rewrite) Sending file: '&clip(str4.GetValue()))
    str5.SetValue(str4.FileNameOnly())
    str5.Replace('$$$','')
    Debug('('&sa:ProcedureName&', Rewrite) Filename: '&str5.GetValue())
    PARENT.ForceNoCache = 1
    PARENT.HeaderDetails.ContentDisposition = 'attachment;filename="'&str5.GetValue()&'"'
    PARENT._SendFile(str4.GetValue(),p_header)
    str4.Free()
  else

* found# is saying "yes, the file is here"
* str4 has the filename that I used to create the pdf report
* str5 gets the filename, removes the $$$ (which is used to tell the webserver it's a temp report)
* We use our own call to _SendFile and content stuff etc, to make sure the file is downloaded the way we want

(attachment shows the else / end code that wraps the parent call)

Hope that helps someone in the future.
Cheers,

Stu Andrews

Jim A

  • Full Member
  • ***
  • Posts: 203
    • View Profile
    • Email
Re: Where to Rename PDF before emailing
« Reply #6 on: July 25, 2016, 06:24:20 PM »
Many thanks Stu!  Very helpful.  I can see several uses for this.