I have a hidden div that i populate with html. use jquery call to gather html and the populate the hidden div and open with the jquery dialog function. everything work great. now i want to return the same html formated as a pdf
I an using symfony 2
on my page with a button to view html form
<div id="display_dialog"></div>
json code used to populate the dialog
$.ajax({
type: "GET",
dataType: 'json',
url: _path,
success: function (msg) {
$( "#display_dialog").html(msg.form);
$( "#display_dialog" ).dialog({
width: $( window).width() - 200,
height: $( window).height() - 200,
modal: true,
close: function( event, ui ) {
$( "#display_dialog").html("");
}});},
});
current code that returns html and works fine (not formatted as pdf)
public function templateAction($uu_code)
{
$html = $this->renderView('MainBundle:Display:template.html.twig');
return new JsonResponse(array('form'=>$html));
}
this code opens a new page as a pdf and works fine, not embedded in the dialog
public function templatePdfAction($uu_code)
{
$html = $this->renderView('MainBundle:Display:template.html.twig');
$pdf = new cxDomPdf();
$pdf->load_html($html);
$pdf->render();
$pdf->stream('my.pdf', array("Attachment" => 0));
}
now i want to use the first function to format the html as a pdf
this is my DOMPDF class object
class cxDomPdf extends \DOMPDF
{
}
thanks!