Rectangle 27 2

Hey I got the solution for this. And the correct code is:

require("html2pdf/html2fpdf.php"); 

      $html = '<h2>Resume</h2>';
      $query = "SELECT * FROM wp_resume order by id desc limit 1";
      $result = mysqli_query($con,$query);
      while($row = mysqli_fetch_array($result))
      {
          $html .= '<div>
                      <label>First Name</label> '. $row['firstName'].'<br>
                      <label>Last Name</label> '.  $row['lastName']. '<br>
                    </div>';
      }

      $pdf = new HTML2FPDF('P', 'mm', 'Letter'); 
      $pdf->AddPage(); 
      $pdf->WriteHTML($html); 
      $pdf->Output('test.pdf', 'F');

html - How to convert dynamic php file which accepts data from databas...

php html wordpress pdf html2pdf
Rectangle 27 1

You can check if array contain data or not by :

$data =[
    'fname'=>Input::get('efname'),
    'lname'=>Input::get('elname'),
    'dob'=>Input::get('edob'),
    'reg_date'=>date('Y-m-d'),
    'email'=>Input::get('eemailaddrs'),
    'gender'=>Input::get('gender'),
    'mobile'=>Input::get('emobile'),
    'p_addrss'=>Input::get('epaddress'),
    'c_addrss'=>Input::get('ecaddress'),
    'quals'=>Input::get('quali'),
    'pdfname'=>$pdfname,
    'empId'=>Input::get('employeeId'),
    ];
  dd($data);
 return PDF::loadView('employee/generatepdf',$data)->save(public_path().'/pdfs/'.$pdfname.'.pdf');

just try it and you will find if your array contain data or not

php - Laravel DOMPDF not generating HTML pdf file with dynamic data - ...

php pdf laravel-4 dompdf
Rectangle 27 1

<?php
    //settings
    $cache_ext  = '.html'; //file extension
    $cache_time     = 3600;  //Cache file expires afere these seconds (1 hour = 3600 sec)
    $cache_folder   = 'cache/'; //folder to store Cache files
    $ignore_pages   = array('', '');

    $dynamic_url    = 'http://'.$_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . $_SERVER['QUERY_STRING']; // requested dynamic page (full url)
    $cache_file     = $cache_folder.md5($dynamic_url).$cache_ext; // construct a cache file
    $ignore = (in_array($dynamic_url,$ignore_pages))?true:false; //check if url is in ignore list

    if (!$ignore && file_exists($cache_file) && time() - $cache_time < filemtime($cache_file)) { //check Cache exist and it's not expired.
        ob_start('ob_gzhandler'); //Turn on output buffering, "ob_gzhandler" for the compressed page with gzip.
        readfile($cache_file); //read Cache file
        echo '<!-- cached page - '.date('l jS \of F Y h:i:s A', filemtime($cache_file)).', Page : '.$dynamic_url.' -->';
        ob_end_flush(); //Flush and turn off output buffering
        exit(); //no need to proceed further, exit the flow.
    }
    //Turn on output buffering with gzip compression.
    ob_start('ob_gzhandler');
    ######## Your Website Content Starts Below #########
    ?>
    <!DOCTYPE html>
    <html>
        <head>
            <title>Page to Cache</title>
        </head>
            <body>
                Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer ut tellus libero.
            </body>
    </html>
    <?php
    ######## Your Website Content Ends here #########

    if (!is_dir($cache_folder)) { //create a new folder if we need to
        mkdir($cache_folder);
    }
    if(!$ignore){
        $fp = fopen($cache_file, 'w');  //open file for writing
        fwrite($fp, ob_get_contents()); //write contents of the output buffer in Cache file
        fclose($fp); //Close file pointer
    }
    ob_end_flush(); //Flush and turn off output buffering

    ?>

caching - How to cache dynamic PHP page - Stack Overflow

php caching
Rectangle 27 0

HTML is basically used for Static Contents.If u want to have dynamic content then pages must be dynamic and there must be source to provide data like database.You can generate html files using dynamic source like php.

javascript - How to create dynamic html files - Stack Overflow

javascript jquery html html5 dom
Rectangle 27 0

file_get_contents returns the content of a file, without it being parsed as PHP...

$buffer = file_get_contents($htmlFile);
ob_start();
include($htmlFile);
$buffer = ob_end_clean();

What we are doing: opening an output buffer (this prevents the echo from going to the client as they appear) then we include the PHP file so it gets parsed and all. Remember all the echo's are in the output buffer, so grab it with ob_end_clean() and use the generated HTML to make a PDF.

Hey I have made the changes u told me. Now the result I am getting is: "1" thats it. Its not even showing the html content "First Name" & "Last Name"........ what to do??

html - How to convert dynamic php file which accepts data from databas...

php html wordpress pdf html2pdf
Rectangle 27 0

<?php
    ob_start();

    require_once("dompdf_config.inc.php");

    $file = file_get_contents('http://example.com/file.php');

    $dompdf = new DOMPDF();
    $dompdf->load_html($file);
    $dompdf->render();
    $dompdf->stream("filename.pdf");
?>

html - how to convert dynamic php file to pdf? - Stack Overflow

php html pdf pdf-generation dompdf
Rectangle 27 0

Hey I got the solution for this. And the correct code is:

require("html2pdf/html2fpdf.php"); 

      $html = '<h2>Resume</h2>';
      $query = "SELECT * FROM wp_resume order by id desc limit 1";
      $result = mysqli_query($con,$query);
      while($row = mysqli_fetch_array($result))
      {
          $html .= '<div>
                      <label>First Name</label> '. $row['firstName'].'<br>
                      <label>Last Name</label> '.  $row['lastName']. '<br>
                    </div>';
      }

      $pdf = new HTML2FPDF('P', 'mm', 'Letter'); 
      $pdf->AddPage(); 
      $pdf->WriteHTML($html); 
      $pdf->Output('test.pdf', 'F');

html - How to convert dynamic php file which accepts data from databas...

php html wordpress pdf html2pdf
Rectangle 27 0

You're telling jquery that you're expecting 'json' data in return but you're echo'ing a string of html, and you are also not using the data variable passed back from the php script to your success callback.

$.ajax({
    type:"POST",
    url: "schedule_class.php",
    dataType:"json",
    data: dataString,
    success: function(data)
    {
         $("#pop").html(data.html);
    },
});

save the html string to a variable, then echo using json_encode ..../.php:

$html = 
    '<table class="tbl_sched" align="center" style="position:absolute;width:95%;">'.
    '<thead class="tbl_sched_row_title">
        <tr>
            <td style="padding:3px 20px"><b>'."CODE".'</b></td>
            <td style="padding:3px 50px"><b>'."SUBJECT".'</b></td>
            <td style="padding:3px 50px"><b>'."STUDENT".'</b></td>
            <td style="padding:3px 30px"><b>'."STUDENT#".'</b></td>
            <td style="padding:3px 15px; margin-right: 20px;"><b>'."COLLEGE".'</b></td>
        </tr>
    </thead>
    <tbody class="tbl_sched_row" style="height:inherit">';

echo json_encode(array( 'html' => $html ));

hi thank you for answering but how if there are two variables I want to pass, $html and another $html_2, how do I do that with json_encode? :)

echo json_encode(array( 'html' => $html, 'another_html' => $another_html ));

javascript - Pass dynamic HTML table script response from a PHP file t...

javascript php jquery html ajax
Rectangle 27 0

You should use this URL instead :

http://api.hostip.info/?ip=$rows['UIP']

It returns XML which is easier to parse. You can even do it in AJAX this way \o/

I am such a massive spastic. Cheers. I should've thought of trying the XML.

mysql - I need to strip dynamic information from a html/php file with ...

php mysql html database geolocation
Rectangle 27 0

No need to bother with an XML parser for something so simple.

while($rows=mysql_fetch_array($result)) 
{
    echo $rows['UIP']; //This is the IP stored currently
    $file_l = file_get_contents('http://api.hostip.info/get_html.php?ip='.$rows['UIP'].'&position=true');

    $lines = explode("\n", $file_l);
    $values = array();
    foreach($lines as $line)
    {
        $s = explode(':', $line);
        $values[$s[0]] = trim($s[1]);
    }
    doSomethingWith($values['City'], $values['Latitude'], $values['Longitude']);
}

Awesome, that's exactly what I needed, cheers for all of your input

mysql - I need to strip dynamic information from a html/php file with ...

php mysql html database geolocation
Rectangle 27 0

Try like that, Use an array as second argument for the view.

return PDF::loadView('employee/generatepdf',array('data'=>$data));

php - Laravel DOMPDF not generating HTML pdf file with dynamic data - ...

php pdf laravel-4 dompdf
Rectangle 27 0

Just to let you know, I ran into this very similar problem where any dynamic content created using PHP would not be converted to PDF. There is a very simple solution to it. Dynamically create an HTML page after your PHP content as loaded.

file_get_contents
file_put_contents($content, "page-to-convert.html");

Once that is done, simply use the PDF converter on this HTML page.

Once converted, you can just delete that HTML page. It's a bit of a "hacky" process, but it worked well for me.

As for the HTML to PDF library, I used WKHTMLTOPDF. Here are some instructions on installing it on Ubuntu.

PHP/HTML table to PDF Conversion - Stack Overflow

php html pdf
Rectangle 27 0

The W3C Recommendation for CSS 2.1 contains a section on Conformance: Requirements and Recommendations, which makes no reference to filename extension but does state:

CSS style sheets that exist in separate files are sent over the Internet as a sequence of bytes accompanied by encoding information. The structure of the transmission, termed a message entity, is defined by RFC 2045 and RFC 2616 (see [RFC2045] and [RFC2616]). A message entity with a content type of "text/css" represents an independent CSS document. The "text/css" content type has been registered by RFC 2318 ([RFC2318]).

Therefore, provided that the file is served with the text/css content type (and that any cacheing concerns are addressed as mentioned in @Fluffeh's answer), you should not have a problem. In PHP, the content type can be set with a call to header() before any output is sent:

<? header('Content-type: text/css'); ?>

Missing this out meant my style was broken in Firefox and Chrome, but not IE... this solved it, so thanks!

html - Is it less efficient to write dynamic CSS stylesheets with a PH...

php html css
Rectangle 27 0

I am not so sure that you want to do too much inside the CSS. If anything, I would suggest maybe adding some extra classes rather than doing too much dynamically. If anything, you might be better off with using PHP to pick a CSS sheet to include, but leave them as CSS. If you keep using the same file, the user can cache it, it appears much quicker. It would be better to have a stylesheet of 50k that is used ocne then cached rather than a stylesheet of 10k that is downloaded with each and every single page.

One can set the Expires:, Last-Modified:, Cache-Control: and Pragma: HTTP headers to control the way that caches (both browser and proxy) store the output, as desired.

html - Is it less efficient to write dynamic CSS stylesheets with a PH...

php html css
Rectangle 27 0

You can use ob_start and ob_get_contents to run PHP code and capture the output as a string.

For the JavaScript chart, though, you're out of luck. DOMPDF is pretty smart, but it's not that smart. You'll need to either use a non-JavaScript chart solution, do without the charts, or use a web browser to generate the PDF.

First of all, Thank you for your help!<br/> I'v tried what you suggested, hope I understood it well... I did it like this: '<?php require_once("dompdf_config.inc.php");<br/> ob_start(); <br/> ?><br/> my html+php blabla bla... <br/> <?php <br/> $html = ob_get_contents();<br/> $dompdf = new DOMPDF();<br/> $dompdf->load_html($html);<br/> $dompdf->render(); <br/> $dompdf->stream("hello_world.pdf"); <br/> ?>'<br/> but now it sais: <br/> "Unable to stream pdf: headers already sent"<br/> :-(

html - how to convert dynamic php file to pdf? - Stack Overflow

php html pdf pdf-generation dompdf
Rectangle 27 0

file_get_contents returns the content of a file, without it being parsed as PHP...

$buffer = file_get_contents($htmlFile);
ob_start();
include($htmlFile);
$buffer = ob_end_clean();

What we are doing: opening an output buffer (this prevents the echo from going to the client as they appear) then we include the PHP file so it gets parsed and all. Remember all the echo's are in the output buffer, so grab it with ob_end_clean() and use the generated HTML to make a PDF.

Hey I have made the changes u told me. Now the result I am getting is: "1" thats it. Its not even showing the html content "First Name" & "Last Name"........ what to do??

html - How to convert dynamic php file which accepts data from databas...

php html wordpress pdf html2pdf
Rectangle 27 0

Have you tried domPDF? It's a library too for converting html to PDF either static or dynamic content. Regarding the images, I just use DATA URI as well for the PDF view php file.

Regarding the "(Aw Snap! / stops working)", you might want to try adding target="_blank" on your button.

Hi @theladybug thanks for the reply! I will look at domPDF, but on my searches, jsPDF came up top of the list so I ended up trying it. Re the button, I create the PDF and download it on the fly, but the browser dies before the end. I just tried with 10 dishes and it works, with 20 it fails. I think jsPDF is resource hungry and cannot cope with so many pages in one doc?!

The problem could be resource related. Is this issue related on yours? github.com/MrRio/jsPDF/issues/99

domPDF is not exactly a replacement for jspdf, as domPDF would do it on the server side, while jspdf is for creating pdf's on clients(browser)

javascript - jsPDF browser death - Stack Overflow

javascript pdf jspdf
Rectangle 27 0

One way would be, you can loop all the tables and get the values of the first four table cells(TD) for each row in the table, assuming all the tables have same columns, and generate a json javascript object and send that object to your server via javascript.

var data = {
'department1': {
    'eventname': 'xyz',
    'emailid': 'x@xyz.com',
    'registrationfee' : '300',
    'studentname': 'me',
    'contactno': '999999999'
 }, 
'department2': {
   'eventname': 'xyz2',
    'emailid': 'y@xyz.com',
    'registrationfee' : '500',
    'studentname': 'me2',
    'contactno': '9999988888'
},
.....
};

and send the data via post ajax call using jquery or plain javascript.

You can access the data on the server side. If you are using a php framework it might automatically decode the json and gives you an array orthewise you might have to use json_decode().

I mean, suppose i have 20 rows in each table if send those data to php file, how can i find which data is belong to which table..

On that, you are saying that the tables are generated from javascript for each department then add a data attribute to the table to identify the which department the table belongs.

<table data-department="department1"></table>

javascript - How to sent dynamic html table data from html form to php...

php javascript jquery html5 forms
Rectangle 27 0

<?php
$str="Country: UNITED KINGDOM (GB) City: (Unknown city) Latitude: Longitude: IP: 79.170.40.245";
$arr=explode(" ",$str);
echo "<pre>";
print_r($arr);
?>

mysql - I need to strip dynamic information from a html/php file with ...

php mysql html database geolocation
Rectangle 27 0

The way I solved this is by installing wkhtmltopdf on my server. Since I use a dynamic page with Javascript to add content I send the whole html page to my php wich stores the html file in a temporary folder on my server and then I use wkhtmltopdf to create the pdf. Once thats done my ajax request opens op that new pdf file. and done you can print that pdf.

Its the best solution I found to print out with pdf files, the problem with other things is that you can't get rid of that extra clutter on the top and footer of the webpages.

php - Print pdf with web application - Stack Overflow

php javascript mysql printing label