我目前无法让dompdf工作。如果我包含dompdf流,它似乎没有任何东西。有人可以建议/告诉我如何保存pdf。
public function indexAction()
{
$formData = new LimitedDirectApplication();
$flow = $this->get('shapehq.form.flow.limitedDirectApplication');
$flow->bind($formData);
$form = $flow->createForm();
if ($flow->isValid($form)) {
$flow->saveCurrentStepData($form);
if ($flow->nextStep()) {
// form for the next step
$form = $flow->createForm();
} else {
// flow finished
$em = $this->getDoctrine()->getManager();
$this->pdfAction($formData);
//var_dump($formData);die();
$em->persist($formData);
$em->flush();
$flow->reset(); // remove step data from the session
$this->sendSuccessEmail($formData);
return $this->redirect($this->generateUrl('shape_hq_greyfriars_sipp_homepage')); // redirect when done
}
}
return $this->render('ShapeHQGreyfriarsSippBundle:Application:directLimitedApplication.html.twig', array(
'form' => $form->createView(),
'flow' => $flow,
));
}
public function pdfAction($formData)
{
require_once('/var/www/src/backend/app/config/dompdf_config.inc.php');
$html = $this->renderView(
'ShapeHQGreyfriarsSippBundle:Application:DirectApplicationPDF.html.twig',
array('data' => $formData)
);
$dompdf = new \DOMPDF();
$dompdf->load_html($html);
$dompdf->render();
//check whether there is a output folder
return new Response($dompdf->output(), 200, array(
'Content-Type' => 'application /pdf'
));
}
}
我正在渲染我的表单数据。
<p><strong>Personal Details</strong></p>
<p>Firstname: {{ data.firstname }}</p>
<p>Middle Name: {{ data.middlename }}</p>
<p>Surname: {{ data.lastname }}</p>
<p>Nationality: {{ data.nationality }}</p>
<p>DOB: {{ data.dateOfBirth | date }}</p>
<p>National Insurance Number: {{ data.nationalInsuranceNumber }}</p>
<p>Preferred retirement age: {{ data.preferredRetirementAge }}</p>
string '<h1>DIRECT</h1>
<p><strong>Personal Details</strong></p>
<p>Firstname: sham</p>
<p>Middle Name: </p>
<p>Surname: test</p>
<p>Nationality: British</p>
<p>DOB: January 10, 1985 00:00</p>
<p>National Insurance Number: QQ 12 34 56 A</p>
<p>Preferred retirement age: 65</p>
'
答案 0 :(得分:0)
在render()
$dompdf->stream( $pdfname );