Thursday, August 25, 2016

How to convert PDF file using HTML and CSS with watermark in php

Hi , I am really happy to share which I have found one of the library  to  create PDF file as per design it nice and easily integrate using PHP.

Step1. download the library from github then extract it and paste into http://localhost/mpdf (xampp/htdoc/mpdf).

Step2. Create a generatepdf.php file within mpdf folder and paste the below code like

 Step3. include the library class mPDF

require(mpdf.php");
$img = 'phptechnicalgroupLogo.png';

$html = '<style>
table { border-collapse: collapse; margin-top: 0; text-align: center; }
td { padding: 0.5em; }
h1 { margin-bottom: 0; }z
</style>


<table border="0" cellspacing="0" cellpadding="0" width="100">
<tr>
<td><img style="vertical-align: top" src="'.$img.'" width="300" /></td><td></td><td></td>
</tr>

</table>



<table border="0" cellspacing="0" cellpadding="0" width="90%" align="center">
<tr>
<td style="text-align:center;width:100%;" style="padding-top:100px;padding-bottom:10px;"><h2><u>Candidate Profile Details</u></h2></td>
</tr>
<tr>
<td style="width:100%;vertical-align:top;padding-left:130px;">
<TABLE border="0" cellspacing="0" cellpadding="0" width="100%">

<TR>
<TD  style="text-align:left;width:45%;font-face:verdana;font-size:14px;"><b>First Name</b></TD>
<TD  style="text-align:center;width:5%;font-face:verdana;font-size:14px;"><b>:</b></TD>
<TD  style="text-align:left;width:50%;font-face:verdana;font-size:14px;">Bikash ranjan</TD>
</TR>
<TR>
<TD style="text-align:left;font-face:verdana;font-size:14px;"><b>Last Name</TD>
<TD  style="text-align:center;font-face:verdana;font-size:14px;"><b>:</b></TD>
<TD  style="text-align:left;font-face:verdana;font-size:14px;">nayak</b></TD>
</TR>
<TR>
<TD style="text-align:left;font-face:verdana;font-size:14px;"><b>Position Title</TD>
<TD  style="text-align:center;font-face:verdana;font-size:14px;"><b>:</b></TD>
<TD  style="text-align:left;font-face:verdana;font-size:14px;">role</TD>
</TR><TR>
<TD style="text-align:left;font-face:verdana;font-size:14px;"><b>Candidate Total Experience</TD>
<TD  style="text-align:center;font-face:verdana;font-size:14px;"><b>:</b></TD>
<TD  style="text-align:left;font-face:verdana;font-size:14px;">2 Month</b></TD>
</TR>
<TR>
<TD style="text-align:left;font-face:verdana;font-size:14px;"><b>Candidates Relevant Experience</TD>
<TD  style="text-align:center;font-face:verdana;font-size:14px;"><b>:</b></TD>
</tr>
</TABLE>
</td>
</tr></table>';
##################CREATE AN OBJECT OF mPDF class#################
$mpdf=new mPDF('c');
$mpdf->WriteHTML($html);

//call watermark content aand image
$mpdf->SetWatermarkText('TALENDRONE.COM');
$mpdf->showWatermarkText = true;
$mpdf->watermarkTextAlpha = 0.1;


//save the file put which location you need folder/filname
$mpdf->Output("bikashprofile.pdf", 'F');


//out put in browser below output function
//$mpdf->Output();


Output in New PDF file



Monday, August 22, 2016

how to integrate IBM bluemix personality insight service using php Api

Hi Everyone, I need to share IBM Bluemix service  "Personality Insight" integration using PHP , I do not want to waste the time in RND for anyone which I have wasted. because I could not found complete help from google and finally consolidate all of my code . so  please follow below instruction to easily integration with Ibm tool.

Step1-> Create a free trail account on IBM Bluemix
 and then go to your email inbox which email id you registered the click the activation link then login into IBM Bluemix.

Step-> After login then click on dashboard on  top menu and create SPACE enter following input .

Step3-> Go to the dashboad  then Console->Service->Watson ->Pesonality Insight .



Step4->Add the Personal Insight entering below infromation



Step-> Let side menu get the Pesonality Insight API Credentials following below step

 


 Finally integration IBM Bluemix service "Personality Insight" with PHP below code using curl function.


###################API CALL USING CURL PHP############################
            //IBM Bluemix Pesonal Insite service username
             $username='a2c41634-21e3-485e-b84d-98192819fcc0';
             //IBM Bluemix Pesonal Insite service password
             $password='KafbLpudysBZ';
             $data="Mor than 100 words user profile data";
             $curl = curl_init();
     
               $ciarr = array(
    "contentItems" =>  array(
                        "userid" => "dummyuserid",
                        "id" => "dummyid",
                        "sourceid" => "freetext",
                        "contenttype" => "application/json",
                        "language" => "en",
                        "content" => $data
                  )
              );



                $ciroot = array("contentItems" => $ciarr);
                $data_str=json_encode($ciarr);   
                curl_setopt($curl, CURLOPT_POST, true); 
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data_str);
                curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
                curl_setopt($curl, CURLOPT_USERPWD, $username.':'.$password);
                curl_setopt($curl, CURLOPT_URL, "https://gateway.watsonplatform.net/personality-insights/api/v2/profile");
                curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($curl, CURLOPT_HTTPHEADER,
              array(
                'Content-Type: text/plain',
                'Content-Length: ' . strlen($data_str)

                ));
       
               $result = curl_exec($curl);      
               curl_close($curl);     
               $decoded = json_decode($result, true);     
               return $result;

##########################Write JSON#######################################


        $fp = fopen('resources/profile.json', 'w');
        fwrite($fp, $res);
        fclose($fp);
##########################Call chart JS function ##################################
/* call graph chart personality insight interface function  after include JS*/
      $.getJSON('./resources/profile.json', '', function ( profile )
      {

            //$('#profile').append('<pre>' + JSON.stringify(profile, null, 2) + '</pre>');
            var chart = new PersonalitySunburstChart('sunburstChart');
            chart.show(profile, './resources/profile_photo.jpg');


      });
#######################OUT PUT#############################












Hope it will help you click to full download ->
-------------------------------------------------------------
if you think it would be helpfulplease donate few amount to
improved my blog and free to post.
using below button -------------------------------------------------------------