-1

I am trying to make an onclick event by which the present html page is saved as document and print them.

<html>
     <body>
       <div class="reportformat">
       <div class="format1">
        <table>
          <tr>
          <td><b> Blood Values </b></td>
          <td><b>Normal Values</b></td>
          </tr>
          <tr>
          <td>Haemoglobin :</td><td><?php echo $_POST["hb"]; ?>G%</td>                               
          <td> [ M:13.5 -17.0G% ---- F:12.5-16.0G% ]</td>           
           </tr>
            </table>    
            <div id="b1"><center>SAVE & PRINT</center></div>
          </div>
        </div>
        </body>
    </html>

 Can anyone please help me saving the current html page as word document using jquery or javascript.
Ravi Vasani
  • 33
  • 1
  • 8
  • You'll need to take that html, send it by ajax, execute the conversion into php and you're fine. I recommend use Pandoc (http://pandoc.org/) to do the conversion using exec/shell_exec into php(http://stackoverflow.com/questions/1624485/how-to-convert-html-file-to-word#22910356) – capcj May 15 '17 at 12:34
  • just a hint: you shouldn't use something like `$_POST["hb"]` as it's not secure at all! – LBA May 15 '17 at 12:35

1 Answers1

0

if you want to do it plain javascript you can save the document using jspdf and you can print the document using window.print

please refer below link for the reference

https://parall.ax/products/jspdf

https://www.w3schools.com/jsref/met_win_print.asp