NetTalk Central

Author Topic: Email a PDF Report  (Read 3263 times)

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Email a PDF Report
« on: May 29, 2012, 03:40:40 AM »
I can generate a PDF report (using PDF Tools extension) and display it in browser. I can also send an email from the webserver, but what I cannot work out is how to generate a PDF without displaying it and then emailing it as an attachment?

The issues I have is how to suppress displaying the PDF report and where to find the (temporary) file in order to email it?

Thanks.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Email a PDF Report
« Reply #1 on: May 29, 2012, 05:47:47 AM »
Hi Ian,

You need to step back a moment here.

when you print a report, and send to the browser, then it goes something like this;

a) create a link, or button, that points to a URL containing the report procedure name.
b) when the user clicks the link, that url is sent to the server, which passes the request to the report procedure, which then sees the p_web parameter and creates the file and sends it.

What you want is completely different.
a) create a link or button on a form with no URL.
b) when the user presses the button show a note saying "ok, will do".
c) then call the report procedure -
d) when that's done call the emil procedure.

So the code on the button looks something like this;

p_web.script('alert("okay");')
p_web.replyComplete()
filename = whateverReportProcedure()
! set email parameters here
SendEmail()

Of course where the whatEverReportProcedure stores the file is up to you. In the above case it passes the name back to you, but you can use any mechanism you like to get the name back.

Then set up the email parameters (see Sending Email example) and call that.

cheers
Bruce

ianburgess

  • Full Member
  • ***
  • Posts: 119
    • View Profile
    • Email
Re: Email a PDF Report
« Reply #2 on: May 31, 2012, 04:06:37 AM »
Thanks Bruce, I already have a report procedure (PDF using PDF Tools) that is displayed in the browser when called. What I want to do is be able to call this same report but optionally specify that it is to be saved with a filename and location and then use that file to email as an attachment. Unfortunately, I cannot see how to (conditionally or permanently) change the behaviour of the report so it is not displayed but saves to disk?

I experimented with unticking the Print Preview, but this just makes it print to the printer from the server!

Thanks

Ian