Reputation: 6378
I am using mPdf to generate a pdf and it is working great.
function generate_pdf()
{
$bom =$_POST["bom_contents"];
$html = $this->load->view("public/print",array($bom),TRUE); //returns the html
$this->load->library("mpdf");//loading the library
$this->mpdf->WriteHTML($html); //setting the html content to generate
$this->mpdf->Output(); //send to browser
}
My html is as follows:
<div>
<embed id="doc" class="doc" src="what_i_put_here ?"></embed>
</div>
How can I set the src attribute of the embedded element, because mPdf is sending the content directly to the browser also I am using POST data, so that I cannot access it through URL.
Upvotes: 0
Views: 4463
Reputation: 6378
I managed it to work .
When i click on Preview button ,it will show a notification that tells Please wait generating pdf...
,also i did a ajax request.
I generated a file using a ajax request and after that file creation i opened a popup,so that i can use the src
attribute to the embed.
Upvotes: 0
Reputation: 1585
Put your generate_pdf()
function inside another file, such as pdf_generator.php. Then set that file as the source:
<div>
<embed id="doc" class="doc" src="pdf_generator.php<?=$_POST["bom_contents"];?>"></embed>
</div>
Updated function:
function generate_pdf()
{
$bom =$_GET["bom_contents"];
$html = $this->load->view("public/print",array($bom),TRUE); //returns the html
$this->load->library("mpdf");//loading the library
$this->mpdf->WriteHTML($html); //setting the html content to generate
$this->mpdf->Output(); //send to browser
}
Upvotes: 2