Jump to content

PHP Print to Email attachment


kirkdaddy

Recommended Posts

I have an operational database I built with PHPRunner software that works flawlessly...for the most part. I want to add functionality for a button which, once pressed will generate a "Print" copy of the current record as it appears in PHP from the actual web page. I don't mind if the content is attached in PDF, HTML, or any other form as long as the "Print" output looks the same as if it were actually printed on paper. The goal is to provide a method for users to simply click a button to send an email copy of the electronic information for the customer's records. I already have a field within the form that contains the customer's email address, so I can have the script pull that email and automatically use that. I just need the script to automatically attach the PDF copy or HTML copy (not sure which would be easier). It seems to me that if there were a way to have the "Print" command generate the copy then attach that generated copy instead of sending it to the "Print" dialog for the web browser, that would be easiest to then somehow attach to the email to be sent. I have scoured the web trying to find an option for this and only now have appealed to the experts on this forum for a possible resolution.

Link to comment
Share on other sites

Focus on giving the user a PDF. If they want to print it then they can.

 

Three basic options:

a) Generate the HTML and then turn that into a PDF - you'll need some sort of HTML->PDF converter,

b) Construct the PDF manually in code - you'll need some sort of PHP PDF library, or

c) If it makes sense, use FPDF to fill in a PDF "template" - you'll need some sort of PHP FPDF library

Edited by requinix
Link to comment
Share on other sites

The PHPRunner program already has a PDF generation script built in which, when it works properly, presents the user with a PDF of the record formatted properly. I'm trying to simplify things a bit more, however, by providing an "E-mail this record" button that, when clicked, will convert to PDF or simply copy the displayed HTML, wrap it into an attachment and prepare it for emailing (or just simply pull the email address out of the field in the record and automatically send that email to the customer. An HTML formatted email would be ok as well as I can send an HTML email. The problem is the coding or scripting to process that information and format the message or PDF the same way it appears on the screen. As one can tell, I'm not too versed with coding very much and haven't written any of the existing code on my own. I have tried to adapt the code that PHPRunner uses to generate the PDF view of the record but I'm getting lost in the coding and can't fully decipher everything that is included in the PHP file that PHPRunner generates and uses to generate the PDF view of the record. I'm not sure if all hope is lost or if there just isn't a way to do everything I want to. Currently, the user can generate the PDF, download it, and attach it to an email with their locally installed email client; I'm just trying to make it more seamless to send the customer their electronic copy of the record and sort of automate most of the process. Additionally, for informational purposes, the PHPRunner program uses FPDF to generate the PDF view of the record. Also, the users are all using Google Chrome as the web browser and, as such, can use the "Print" command to save a PDF copy manually then manually email the record.

Edited by kirkdaddy
Link to comment
Share on other sites

What do you want us to do for you?

 

It's outside of the scope of this forum to modify a commercial scripting package (phprunner) assuming such modification is safe or advisable.

 

It sounds like you're an end-user and not a programmer. I'm by no means trying to run you off, but this is a community to help programmers, students and hobbyists, and even business people who are trying to modify existing code.

 

With that said, you have to do the heavy lifting -- otherwise it's just programmers doing work for people for free, which is not what this forum exists to do.

Link to comment
Share on other sites

With that said, maybe I can be pointed in the correct direction for learning more details on PHP programming? I would consider myself more of a hobbyist at this point, being self taught, I am limited on what knowledge I have ascertained myself but learn very quickly. I would never presume to have others do my work for me, but with the lack of information I've been able to find on this topic, I was hoping a "push in the right direction" by someone who may have script or programming clips or suggestion might spark the fire of the "right track" for me. Suggestions on syntax commands would be much appreciated, if possible, as I can amend and figure out how to adapt the rest of the arguments and coding to my specific needs. Thanks much for the help so far and for any help the future may bring.

Link to comment
Share on other sites

I just glanced at PHPRunner and it appears to be a system that provides a default CMS/Site capability but then also advertises "Code generation" which i assume means you run a web UI and it then spits out new scripts that work within their infrastructure.

 

All of this makes me loathe to advise you to try and modify anything within PHPRunner, as it seems to be designed to do all the programming for you.

 

I don't believe that you'll be able to safely change its code, without making it impossible for you to do future upgrades, and possibly you'll screw up the basic operation of the system in some significant way.

 

You're basically looking to "fork" their code, and you'd want to be a master PHP developer who really understood exactly what PHPRunner does, and how it has been architected.

 

I personally have never heard of the product, and have no experience with it, so I can only conjecture.

 

To go back to Requinix's post, sure it's possible to replace the routines phprunner has, or the scripts involved, and substitute code that does things differently than what phprunner does, and get the result you wanted, but in doing so, you will have to do the very modification that I alluded to previously.

 

My best advice would be that you contact the phprunner people, with your specification (make sure you've illustrated it with a screen mockup and simply and clearly described the change you want) and then ask them if there is a way phprunner can do this.

 

At worst, this would in essence become a feature request that they might be willing to put in for you, and in doing so making the software more desirable. At worst, they might propose a cost to put the mod in for you, or give you information on how a skilled php developer could do it.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.