I have to run the view in the background. Below code is displaying both views on the single page.
My project is just filling the form and after filling the form display the PDF in 300*400px in the image(only display the half pdf)
Explain What I am doing is, I have a registration form. After filling the registration form I have to call the URL in the background that URL will generate the PDF of it(PDF will not display to the student)then I have to pass the PDF URL which is generated to take the screenshot of it and screenshot of that image will display it in the view page.
This logic I am trying it. Or is there any other Idea?
public function generate_img(){
$session_stud_id=$this->session->userdata['student_session']['stud_id'];//student session id
$bg_link['bg_link']='index.php/Invoice/index/'.$session_stud_id;
$view_a=$this->load->view('test', $bg_link);//sending $bg_link to test view page and I have to run this view in the background
$req = curl_init();
curl_setopt($req, CURLOPT_URL,$view_a);
curl_exec($req);
$this->load->view('invoice_generate', $background_url_link);//What variable I have to use here? background URL i have to send it to other view page
}
Screenshot code
<?php
echo $siteURL=base_url($background_url_link);
//call Google PageSpeed Insights API
$googlePagespeedData = file_get_contents("https://www.googleapis.com/pagespeedonline/v2/runPagespeed?url=$siteURL&screenshot=true");
//decode json data
$googlePagespeedData = json_decode($googlePagespeedData, true);
//screenshot data
$screenshot = $googlePagespeedData['screenshot']['data'];
$screenshot = str_replace(array('_','-'),array('/','+'),$screenshot);
//display screenshot image
echo "<img src=\"data:image/jpeg;base64,".$screenshot."\" />";
?>