1

hello
i need help about javascript tag
how can i use <script> tag or java script
please help

2

You can't using the tag javascript...
Only generate by php...

I search to send variable from ajax...before generate the pdf...

3

I found a solution, if you're interested.

4

doc (./3) :
I found a solution, if you're interested.

how?
can you type one example?

5

Hi Xoni,

I'm using the url to give data to the php page :
So, i'm using a javascript function to serialize the data : (thx to werox for the code)

1- i'm create an object with all i need :

var pdf = new Object();

pdf.data1= $('#data1).val();
pdf.data2= $('#data2).val();
pdf.data3= $('#data3).val();

etc..

2- i'm serialyze the object

var envoie = encodeURIComponent(serialize(pdf));

encodeURIComponent is a native javascript function, i'm using it for the special character ( é, ', \ ..). because i'm using text.


function serialize (txt) {
switch(typeof(txt)){
case 'string':
return 's:'+txt.length+':"'+txt+'";';
case 'number':
if(txt>=0 && String(txt).indexOf('.') == -1 && txt < 65536) return 'i:'+txt+';';
return 'd:'+txt+';';
case 'boolean':
return 'b:'+( (txt)?'1':'0' )+';';
case 'object':
var i=0,k,ret='';
for(k in txt){
//alert(isNaN(k));
if(!isNaN(k)) k = Number(k);
ret += serialize(k)+serialize(txt[k]);
i++;
}
return 'a:'+i+':{'+ret+'}';
default:
return 'N;';
alert('var undefined: '+typeof(txt));return undefined;
}
}

3- i create the url
var url = '../chemin/fichier.php?envoie='+envoie;

4- i load url

$('#page_element').load(url);

that 's for the client navigator

on the serveur, php page is :

fichier.php

<?php
$recu = unserialize($_REQUEST['envoie']);

$data1= $recu[data1];
$data2= $recu[data2];
$data3= $recu[data3];

ob_start();
?> <page>
<table width="672">
<tr><td align="left"><?php echo $data1; ?></td></tr>
<tr><td align="left"><?php echo $data2; ?></td></tr>
<tr><td align="left"><?php echo $data3; ?></td></tr>
</table>
</page>
<?php
$content = ob_get_clean();
require_once('../../plugin/html2pdf/html2pdf.class.php');
try
{
$html2pdf = new HTML2PDF('P', 'A4', 'fr');
$html2pdf->writeHTML($content, isset($_GET['vuehtml']));
$html2pdf->Output($url, 'F');
exit;
}
catch(HTML2PDF_exception $e) {
echo $e;
exit;
}

unserialize is a native php function..

and we have translate data and generate pdf...

if you have more question.

Sorry for my bad englsih