You are on page 1of 5

<?

php session_start();
ob_start();
//ini_set("display_errors","on");
ini_set("memory_limit","24m");
include("includes/connect.php");
$xmlid=$_request['xmlid'];
$filename = "http://203.122.11.36/onlineartwork.co.uk/visitingcard/$xmlid.xml";
$content=file_get_contents($filename);

$xml = simplexml_load_string($content);
//echo "i am here";
//echo "<pre>";
//var_dump($xml);

for($i=0;$i<sizeof($xml->object);$i++){
$name[]=$xml->object[$i]->name;
$width[]=$xml->object[$i]->width;
$height[]=$xml->object[$i]->height;
$x[]=$xml->object[$i]->x;
$y[]=$xml->object[$i]->y;
$rtn[]=$xml->object[$i]->rtn;
$a[]=$xml->object[$i]->a;
$layer[]=$xml->object[$i]->layer;
}
/*
echo "name<pre>";
var_dump($name);
echo "width<pre>";
var_dump($width);
echo "height<pre>";
var_dump($height);
echo "x<pre>";
var_dump($x);
echo "y<pre>";
var_dump($y);
echo "a<pre>";
var_dump($a);
echo "layer<pre>";
var_dump($layer);
*/

//print_r($xml->object->name);
/*
foreach ($xml as $v1){
foreach ($v1 as $key => $value){

echo $key."-------".$value."\n";

}
}
*/

//exit();

$im = @imagecreate(800, 1200);


$targetfile="visitingcard/merge.jpg";
$background_color = imagecolorallocate($im, 255, 255, 255);
imagejpeg ($im,"$targetfile");
$sourcefile="visitingcard/merge.jpg";
$sourcefile_id = imagecreatefromjpeg($sourcefile);
$newfile="new_".$xmlid;
$targetfile="visitingcard/$newfile.jpg";
$count=array();

$count3=count($name);

for ($j=0;$j<$count3;$j++)
{
$transition=$a[$j];
$insertfile="visitingcard/acme/julian/".$name[$j].".jpg";
$insertfile_id = imagecreatefromjpeg($insertfile);
$insertfile_width=$width[$j];
$insertfile_height=$height[$j];

$colour= imagecolorallocate($insertfile_id, 255, 255, 255);


$rtna=(integer)$rtn[$j];
$rotated = imagerotate($insertfile_id, $rtna, $colour);
imagecolortransparent($rotated, $colour);
imagejpeg($rotated , $targetfile);
imagecopymerge($sourcefile_id,
$rotated,abs($x[$j]),abs($y[$j]),0,0,$insertfile_width,$insertfile_height,$transit
ion);
}
$font_size='30';
$angle='';
$left='';
$top='';
$im1 = imagecreate(100, 100);
$black = imagecolorallocate($im1, 0, 0, 0);
$font='yahoo.ttf';
$string1='this is my text to try out.';
imagettftext($sourcefile_id, 20, 0, 100,400, $black, $font, $string1);
imagejpeg ($sourcefile_id,"$targetfile");

/////// for creating html file start here/////////////////////sufyan-3-jan-


07////////

$filehtml= fopen("visitingcard/$newfile.html" , "w"); //fopen -- opens file


or url

$_html ="<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en'


lang='en'><head>";
$_html .="<meta http-equiv='content-type' content='text/html; charset=iso-
8859-1'><title>onlinedesignerb</title></head>
<body >
<table width='500' height='550' border='0' cellspacing='0' cellpadding='0'>
<tr>
<td><img src='$newfile.jpg'></td>
</tr>
</table>

</body></html>";

fwrite($filehtml, $_html); //fwrite -- binary-safe file write


fclose($filehtml); //fclose -- closes an open file pointer
//////////// for creating html file ends here/////////////////////////////

///////////for creating pdf file start here////////////////////sufyan-3-jan-


07////////

require('visitingcard/html_to_pdf.inc.php');
$htmltopdf = new html_to_pdf();

$htmltopdf->useurl(hkc_use_easyw); // default hkc_use_abc other


hkc_use_easyw
$htmltopdf->savefile("visitingcard/$newfile.pdf");

$filepath="http://203.122.11.36/onlineartwork.co.uk/visitingcard/$newfile.html";
$result = $htmltopdf->converturl("$filepath");
if($result==false)
echo $htmltopdf->error();
@unlink($filepath);

/////// for creating pdf file ends here///////sufyan-3-jan-07/////

?>

<table border="0" width="100%" cellspacing="0" cellpadding="0" valign="middle"


height="400">
<tr>
<td valign="top">
<table border="0" width="100%" cellspacing="0" cellpadding="0"
valign="middle">

<td valign="top" align="center">


<table border="0" width="95%" cellspacing="0" cellpadding="0"
valign="top">
<tr>
<td height="5"></td>
</tr>
<tr>
<td align="center"><b><font face="verdana" size="2"
color="#4551b6"><u>product name</u></font></b></td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td align="center">
<table border="0" width="90%" cellspacing="0" cellpadding="0"
valign="top">
<tr>
<td valign="top">
<img src="visitingcard/<?php echo $newfile?>.jpg"
width="200" height="200" border="0" alt="<?php echo $newfile;?>">
</td>
<td width="25"></td>
<td valign="top">
<table border="0" width="100%" cellspacing="0"
cellpadding="0">
<tr>
<td height="10"></td>
</tr>
<tr>
<td
class="toplinks"><b>price</b></td><td>$ 4.00</td>
</tr>
<tr>
<td height="5"></td>
</tr>
<tr>
<td
class="toplinks"><b>quantity</b></td><td>1</td>
</tr>

<tr>
<td height="5"></td>
</tr>
<tr>
<td valign="top"
class="toplinks"><b>description</b></td><td>sfdsdfsdf</td>
</tr>

<tr>
<td height="5"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td height="5"></td>
</tr>

<tr>
<!--<td valign="top" align="left">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href="user.php?act=productdescflash&save=yes" name="savepdf"
id="savepdf">savepdf</a>
</td>-->
<!--<td valign="top" align="left">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href="visitingcard/<?php echo $newfile?>.pdf" name="savepdf" id="savepdf">view
saved pdf file</a>
</td>-->
<td valign="top" align="left">

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a
href="viewsave.php?newfile=<?php echo $newfile?>" name="savepdf" id="savepdf">view
saved pdf file</a>
</td>
</tr>
<tr>
<td valign="top" align="right">
<form method=post action="" name="cart_form">
<input type="hidden" name="product_id" value="<?php echo
$result_product_row['id']?>">
<input type="image" src="images/buy.gif" name="cart">
</form>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</td>
</tr>
<tr><td height="5"></td></tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
<?php
if(isset($_request['save']) &&$_request['save']='yes'){
$filename1="visitingcard/".$_session['filenamesave'].".xml";
$file = fopen ($filename1, "rb");
require_once("dompdf_config.inc.php");
$a= "<img src=visitingcard/$filenamesave.jpg >";
$dompdf = new dompdf();
$dompdf->load_html(($a));
$dompdf->load_html_file($file);
echo $dompdf->get_protocol();
$dompdf->render();
$dompdf->stream("$filenamesave.pdf");

}?>

You might also like