乳胶文件的枝条

时间:2017-03-02 10:03:34

标签: symfony twig latex

我想知道如何将数据库中的数据添加到Symfony中的latex文件中。

My Latex文件

\begin{flushleft}
{% for occasion in occasions %}
{{ occasion.nom }}
Description de l'occasion
\end {flushleft}
\begin{question}{somme}
{% for competence in occasion.competences %} 
{{ competence.nom }} : {{ competence.description }}
competence nom et description
\AMCOpen{lines=3}{\wrongchoice[E]{E}\scoring{0}\wrongchoice[M]{m}\scoring{1}\wrongchoice[A]{a}\scoring{2}\correctchoice[N]{n}\scoring{3}}
\end{question}
\begin{flushleft}
  {% for sousCompetences in competence.sousCompetences %}
  {{ sousCompetences.description  }} 
Description de la competence
  {% endfor %}
\end {flushleft}
{% endfor %}
{% endfor %}

% \AMCaddpagesto{3} 

}   

我试图通过twig导出数据,但我不知道该怎么做。 这是我的控制器

public function ficheCompetencesAction(Request $request)
    {

        if($request->isXmlHttpRequest()){

            $req=$request->request->get('fiche_occasion');
            $ue=$req['ues'];
            return new JsonResponse($ue);
        }

        $em = $this->getDoctrine()->getManager();
        $form = $this->createForm( FicheOccasion::class );
        $form->handleRequest( $request );

        if( $form->isValid() )
        {
            $req=$request->request->get('fiche_occasion');
            $etudiant=$em->getRepository(Utilisateur::class)->find($req['etudiants']);

            $ueSelected=$req['ues'];
            if($ueSelected!='')
            {
                //on recupere les données du formulaires
                $ue=$em->getRepository(UE::class)->find($ueSelected);

                //on recupere les occasions correspondante
                $occasions=$ue->getOccasions();

                //on genere le twig desiré
                $html = $this->renderView('PolytechSkillsBundle:Admin/Rapport/Rapport:fichesPDF.tex.twig',
                    ['user'=>$etudiant,
                        'occasions'=>$occasions,
                        'ue'=> $ue,
                        'QrCodeNumeroEtu' => $etudiant->getNumero()
                    ]);
                //servira a generer le pdf à partir du twig
                return new Response(
                    $this->get('knp_snappy.pdf')->getOutputFromHtml($html),
                    200,
                    array(
                        'Content-Type'          => 'application/pdf',
                        'Content-Disposition'   => 'attachment; filename="test.pdf"'

                    )
                );
            }
        }

        return $this->render( 'PolytechSkillsBundle:Admin/Rapport/Rapport:fiches.html.twig',[ 'form' => $form->createView()] );
    }

我想从发送的数据中创建FichesPDF.tex.twig文件,但问题是它给我发了一个带有乳胶标签的结果(它将它们视为文本)

0 个答案:

没有答案