2014-02-15 23 views
-1

我正在嘗試使用TCPDF生成pdf,並且希望將此PDF附加到電子郵件中,並且將其發送到各種電子郵件地址。 什麼是在服務中呈現樹枝文件的正確方法?如何渲染自定義位置的樹枝?

+3

歡迎SO!你試過什麼了?請始終包含該信息! –

回答

1

首先,你需要的模板添加到您的服務

your_bundle.your_service_name: 
    class: your_project\your_bundle\Service\your_service 
    arguments: [@templating] 

然後你需要添加模板爲您的服務構造商提供服務

private $templating; 

function __construct($templating) 
{ 
    $this->templating = $templating; 
} 

之後,你只需要調用它在處理TCPDF功能渲染

function renderTCPDF() 
{ 
    $renderedTemplate = $this->templating->render('your_bundle:template_folder:twig_name', array(your_parameters)); 
}