1

Form Created

Hi, I am looking at creating a button which will capture the users data in a PDF format. This will then need to be saved and emailed (the attached image is an example of what will need to be included on this PDF document)

My code at the moment is written in HTML & JavaScript

seenukarthi
  • 8,241
  • 10
  • 47
  • 68
Our Kloud
  • 11
  • 2

2 Answers2

0

there are lots of options .

You can use jsPDF, phantomJS

Example fiddle of jsPDF

http://jsfiddle.net/cn18yyza/

function demoFromHTML() {
    var pdf = new jsPDF('p', 'pt', 'letter');
    // source can be HTML-formatted string, or a reference
    // to an actual DOM element from which the text will be scraped.
    source = $('#customers')[0];

    // we support special element handlers. Register them with jQuery-style 
    // ID selector for either ID or node name. ("#iAmID", "div", "span" etc.)
    // There is no support for any other type of selectors 
    // (class, of compound) at this time.
    specialElementHandlers = {
        // element with id of "bypass" - jQuery style selector
        '#bypassme': function (element, renderer) {
            // true = "handled elsewhere, bypass text extraction"
            return true
        }
    };
    margins = {
        top: 80,
        bottom: 60,
        left: 10,
        width: 700
    };
    // all coords and widths are in jsPDF instance's declared units
    // 'inches' in this case
    pdf.fromHTML(
    source, // HTML string or DOM elem ref.
    margins.left, // x coord
    margins.top, { // y coord
        'width': margins.width, // max width of content on PDF
        'elementHandlers': specialElementHandlers
    },

    function (dispose) {
        // dispose: object with X, Y of the last line add to the PDF 
        //          this allow the insertion of new lines after html
        pdf.save('Test.pdf');
    }, margins);
}
Parth Ghiya
  • 6,929
  • 2
  • 30
  • 37
0

I am sorry, I cannot comment yet. I found another stack overflow on creating PDFs with JavaScript though generating a PDF with JS

For emailing it afterwards I believe you can use JavaScript mailto JavaScript mailto function, I believe there is a "&attachment" parameter. For emailing though it might be better to do it through a server like nodejs which has a nodemailer module.