Zend framework2 直接设置视图内容,而不是使用模板

Zend framework2 直接设置视图内容,而不是使用模板,zend-framework2,wkhtmltopdf,Zend Framework2,Wkhtmltopdf,我想知道是否有人知道在Zend Framework 2中不使用模板而设置视图内容的方法。我让用户在ckeditor中创建电子邮件,存储在文本文件中,然后抓取文件内容并尝试生成pdf打印。以下是控制器中发生的情况: $emails = $this -> email() -> getEmails(); //Render the display $viewRender = $this->getServiceLocator()->get('ViewRenderer'); $vi

我想知道是否有人知道在Zend Framework 2中不使用模板而设置视图内容的方法。我让用户在ckeditor中创建电子邮件,存储在文本文件中,然后抓取文件内容并尝试生成pdf打印。以下是控制器中发生的情况:

$emails = $this -> email() -> getEmails();

//Render the display
$viewRender = $this->getServiceLocator()->get('ViewRenderer');
$view->setTemplate('module/controller/template.phtml');
$html = $viewRender->render($view);

//Create the HTML to PDF class instance & set the bin path
$wkpdf = new WkHtmlToPdf(array('bin'=>'C:\\Program Files (x86)\\wkhtmltopdf\\wkhtmltopdf'));

//Add it to the PDF
$wkpdf->addPage($html);

//Send it to the client
$wkpdf->send();
我想将setTemplate()方法替换为直接用我从电子邮件文件中检索到的html字符串设置视图内容的方法。有什么想法吗

这就是我想到的:

 $emails = $this -> email() -> getEmails();

 $email = $emails->$email_name;

 //Create the HTML to PDF class instance & set the bin path
 $wkpdf = new \WkHtmlToPdf(array('bin'=>$this->settings()->getSettings()->wkhtmltopdf_path));

 //Add the email to the PDF
 $wkpdf->addPage("<html>".$email."</html>");

 //Send it to the client
 $wkpdf->send();
$emails=$this->email()->getEmails();
$email=$email->$email\u name;
//创建HTML到PDF类实例并设置bin路径
$wkpdf=new\WkHtmlToPdf(数组('bin'=>$this->settings()->getSettings()->WkHtmlToPdf_path));
//将电子邮件添加到PDF
$wkpdf->addPage(“$email.”);
//将其发送给客户机
$wkpdf->send();

我所需要做的就是用html标签包装字符串,以便WkHtmlToPdf处理它。

在将内容返回到视图文件之前

  $result = new ViewModel(array('view_contant_variable' => $content_to_assign));
  $result->setTerminal(true);
  return $result;
我希望这可以帮助您显示没有模板内容的视图文件