TCPDF not formatting
I'm using an ajax call to print a pdf and email it to user, but the problem is that the data in the pdf is not formatted.
Here's my ajax call
$(document).ready(function() { $(function() { $(".submit").click(function() { $('.simpleCart_items').css({'position:':'relative'}); $('.headerRow div').css({'display':'none'}); $('.item-remove').css({'display':'none'}); $('.itemRow').css({'position':'absolute'}, {'left':'0px'}, {'top':'50px'}); $('.item-name').css({'position':'absolute'}, {'left':'50px'}, {'top':'0px'}); $('item-price').css({'position':'absolute'}, {'left':'150px'}, {'top':'0px'}); $('.item-total').css({'position':'absolute'}, {'left':'250px'}, {'top':'0px'}); var data = $('#yhteystiedot').serializeArray(); data.push( { name: 'cartContent', value: $('#emailedcart').html()}); //alert (data);return false; $.ajax({ type: "POST", data: data, url: "order/order.php", dataType: "html", error: function(){ alert("Jotakin meni pahasti pieleen! Yritä uudelleen?"); }, success: function() { alert("Onnistui"); } }); return false; }); }); });
It adds style to the data that is being pushed to the script, but it doesn't look like it should. Here's a screenshot about it:
Answers
Sorry, here is the corrected answer.
Use only INLINE CSS to work with TCPDF like;
<table style="width: 100px;" cellspacing="0" cellpadding="0"> <tr> <td style="border: 1px solid #000000; height: 20px; text-align:center; font-weight: bold; font-size: x-large;" colspan=11> REPORT </td> </tr>
Or wrap inside your code like <style>p{color:red;}</style>
TCPDF has class issues. Send this HTML data using AJAX. Try like this and comment here.