首先寻求帮助:)
我在Symfony 4.4 Framework上工作,我让控制器生成PDF并通过邮件附件发送,但是我想直接在控制器上发送pdf,而不是在系统上的库存文件发送并删除它们。
$pdf = new Dompdf( $pdfOptions );
$html = $this->render('recommendations/synthesePdf.html.twig',[
'products' => $products,'recommendations' => $recommendations,'customer' => $customer,'cultureTotal' => $cultureTotal
]);
$pdf->loadHtml( $html->getcontent() );
$pdf->setPaper('A4','portrait');
$pdf->render();
//-- SEND PDF TO USER
$message = (new \Swift_Message('Nouvelle recommendation disponible'))
->setfrom('send@example.com')
//->setTo( $customer->getEmail() )
->setTo( '***' )
->setBody(
$this->renderView(
'emails/recommendation.html.twig',[
'identity' => $customer->getIdentity()
]
),'text/html'
)
->attach( \Swift_Attachment::fromPath( $pdf->output() ) )
;
$mailer->send($message);
您好,请使用$ pdf-> output / $ pdf-> getHtml,但如果您有任何建议,它将无法正常工作:)
Thx