aldaflux/doc-img-bundle

Symfony 扩展包用于测试

安装: 12

依赖: 0

建议者: 0

安全: 0

星级: 0

关注者: 1

分支: 0

开放问题: 0

类型:symfony-bundle

v0.0.2 2018-11-07 15:56 UTC

This package is auto-updated.

Last update: 2024-09-25 21:54:47 UTC


README

在 AppKernel.php 中添加

 new Aldaflux\DocImgBundle\AldafluxDocImgBundle(),

在 config.yml 中添加...

  aldaflux_doc_img:
    web_dir: "%kernel.root_dir%/../web"

并在您的模板中验证此

framework:
    templating:
        engines: ['twig']

...

  <img src="/bundles/aldafluxdocimg/images/inda.png">
  <img src="https://upload.wikimedia.org/wikipedia/fr/thumb/9/94/Logo_Microsoft_Word_2013.png/220px-Logo_Microsoft_Word_2013.png">

重要!:请使用双引号,单引号不起作用...

在您的控制器中

  $view_html = $this->renderView('AldafluxDocImgBundle:Default:example.html.twig');
  $view_mht=$this->get('HtmlToMht')->GenereHtmlToMht($view_html);

您可以在文件(".doc")中编写视图或在响应中发送它

        $response = new Response();
        $response->headers->set('Cache-Control', 'private');
        $response->headers->set('Content-type', "application/vnd.ms-word");
        $response->headers->set('Content-Disposition', 'attachment; filename="file.doc"');
        $response->sendHeaders();
        $response->setContent($view_mht);
        return ($response);

如果您想测试功能,请将此添加到 routing.yml 中

aldaflux_doc_img:
    resource: "@AldafluxDocImgBundle/Controller"
    type:     annotation

并转到 http://yourserver/aldaflux/