473,320 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

submit div content to html2pdf page

I'm Needing to submit div content from one page to my html2pdf conversions page. I was wanting to do this using jquery so I do not have to leave my home page to make downloadable PDF file. I found an online example but I can not seem to make it work right. Any help with this project would be appreciated greatly. Here's the code I found. I just want to pass my div content so I can create a downloadable PDF file. I don't need any error message return link this script contains. Thanks



home.php

Expand|Select|Wrap|Line Numbers
  1. <! DOCTYPE>
  2. <html>
  3. <head>
  4. <title></ title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
  6. src="js/jquery-1.9.1.min.js" <script type="text/javascript"> </ script>
  7. <script type="text/javascript">
  8. $ (Document). Ready (function () {
  9. $ ("#exportentry"). Click (function (e) {
  10. e.preventDefault ();
  11. if (submitted) {
  12. var data = $ ("#container"). html ();
  13. var filename = "Entry_Report.pdf";
  14. $. Ajax ({
  15. type: "POST",
  16. url: "convert.php",
  17. data: {data: data, filename: filename}
  18. dataType: "json",
  19. success: function (data) {
  20. alert ('success');
  21. }
  22. })
  23. Else {}
  24. alert ("No Report To Export");
  25. }
  26. });
  27. });
  28. </ Script>
  29.  
  30. </ Head>
  31. <body>
  32. <div id="container">
  33. <center> <h3> Nations and Flags </ h3> </ center>
  34. <table border="1" width="500" cellspacing="0" cellpadding="2" align="center">
  35. <tr> <td> <% = Request.QueryString ("v")%> India </ td> <td width="200"> <img src = "imag / in-t.jpg" width = "48" height = "32"> </ td> </ tr>
  36. <tr> <td> <% = Request.QueryString ("v2")%> Australia </ td> <td width="200"> <img src = "imag / as-t.jpg" width = "48" height = "32"> </ td> </ tr>
  37. <tr> <td> Canada </ td> <td width="200"> <img src="imag/ca-t.jpg" width="48" height="32px" </ td> </ tr >
  38. <tr> <td> China </ td> <td width="200"> <img src="imag/ch-t.jpg" width="48" height="32px" </ td> </ tr >
  39. <tr> <td> Germany </ td> <td width="200"> <img src="imag/de-t.jpg" width="48" height="32px" </ td> </ tr >
  40. <tr> <td> France </ td> <td width="200"> <img src="imag/fr-t.jpg" width="48" height="32px" </ td> </ tr >
  41. <tr> <td> United Kingdom </ td> <td width="200"> <img src="imag/uk-t.jpg" width="48" height="32px" </ td> </ tr>
  42. <tr> <td> United States of America </ td> <td width="200"> <img src="imag/us-t.jpg" width="48" height="32px" </ td> </ tr>
  43. </ Table>
  44.  
  45. <table border="0" width="500" cellspacing="0" cellpadding="2" align="center">
  46. <tr> <td align="center"> <a href = " http://www.scriptarticle.com "target =" _blank "> http://www.scriptarticle.com </ a> </ td> < / tr>
  47. </ Table>
  48. </ Div>
  49. <form method="post" id="exportentry" action="home.php">
  50. <input type="submit" value="Create PDF">
  51. </ Form>
  52. </ Body>
  53. </ Html>
  54.  


convert.php

Expand|Select|Wrap|Line Numbers
  1. <? Php
  2.  
  3. require ('html2fpdf.php');
  4.  
  5. if (isset ($ _POST ['data'])) {
  6. Urlcontents $ = $ _POST ['data'];
  7. $ Filename = $ _POST ['filename'];
  8. $ Date = $ _POST ['date'];
  9. convert ($ urlcontents, $ filename, $ date);
  10. }
  11.  
  12. function convert ($ contents, $ name, $ currdate) {
  13. $ Pdf = new HTML2FPDF ();
  14. $ Pdf-> AddPage ();
  15. $ Pdf-> SetFont ('Arial', 'B', 16);
  16. $ Pdf-> Cell (40.10, "Report Entry");
  17. $ Pdf-> SetFont ('Arial','', 12);
  18. $ Pdf-> Cell (90.12, '-'. $ Currdate);
  19. $ Content = strip_tags ($ contents, '<html> <body> <meta> <img> <h2> <h4> <div> <ul> <li> <span>');
  20. $ Pdf-> Sety (20);
  21. $ Pdf-> WriteHTML ($ contents);
  22. $ Content = $ pdf-> Output ('', true);
  23. $ File = fopen ($ filename, "D");
  24. fwrite ($ file, $ content);
  25. fclose ($ file);
  26. }
  27. ?>
  28.  
Mar 29 '13 #1
0 1862

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Keith | last post by:
Is it possible to submit a form as soon as the page it is on loads and then redirect to another page? Thanks
1
by: Matt | last post by:
When the user submit the form in myform.jsp, it will submit to myaction.jsp. I want it only pop up test message box without having the browser with myaction.jsp, which is a blank page. Any ideas??...
2
by: anonieko | last post by:
Scenario: You have a page that is TOO slow to refresh. But it allows partial flushing of html contents. I.e. Submit button already appears but you don't want your users to click on it prematurely...
5
by: Matthew Speed | last post by:
I want to make a page that automatically refreshes every minute. I can drag the timer control onto my page but I can't figure out what code to write to tell the page to postback to the server. How...
1
by: dsbsolutions | last post by:
Hi, I am making a webpage that can query a database table of employees and return them in a html table. Currently I have submit buttons beside each employee to open the page to edit their details....
0
by: Jean-François Michaud | last post by:
Hello people, I'm having a hard time figuring out how to align my page numbe properly to the right margin in the Table of content I'm generating. I'm using FOP and there are some known issues...
1
by: Ibrahim. | last post by:
Hi, I have a login page, the problem I'm facing is like this; 1. Login page with submit button (being default button); 2. When first time the page is submitted then submit code is called. ...
0
by: sivachitra81 | last post by:
hi i have Richtext box.I have to add content of some RTF files and I have to add Page Break between them.And I have to append some string also to it.I am adding RTF File content by using following...
3
by: Roger Frei | last post by:
hello everybody I have a masterpage and several aspx pages that inerhit controls from the masterpage. In the Page_Load event of the content aspx page I want to add some controls. Example code: ...
6
by: obj63 | last post by:
Hello All, I am posting to a page with out a submit button using the function sendToHost - http://dodds.net/~cardinal/sendtohost.txt I send the following ...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.