How do I create reports in Symfony2?
<p>Im creating an application un Symfony2.7 and I want to start creating reports, I have been reading for a couple of days and cant find a solution.
Ive tried ps pdfbundle, but I cant generate reports. Cant find more Documentation.
Please help</p>

<p>My Code:</p>

<pre><code>    public function formatoOcAction($id)

{
    $facade = $this-&gt;get('ps_pdf.facade');

    $response = new Response();

    $em = $this-&gt;getDoctrine()-&gt;getManager();

    $InOc = $em-&gt;getRepository('NivalInventarioBundle:InOrdenCompra')-&gt;findById($id);

    $InOcDet = $em-&gt;getRepository('NivalInventarioBundle:InOrdenCompraDetalle')-&gt;findBy(array(
        'idOrdenCompra' =&gt; $id));

    $stylesheetXml = $this-&gt;renderView('NivalInventarioBundle:InOrdenCompra:ordencompra.xml.twig', array());


    $this-&gt;render('NivalInventarioBundle:InOrdenCompra:ordencompra.pdf.twig', array(
        "entities1" =&gt; $InOc,
        "entities2" =&gt; $InOcDet,
        "id" =&gt; $id),
        $response);

    $xml = $response-&gt;getContent();

    $content = $facade-&gt;render($xml, $stylesheetXml);

    $filename = $this-&gt;getParameter('upload_directory').'orden_compra_'.$id.'.pdf';

    file_put_contents($filename, $content);

    return new Response($content, 200, array('content-type' =&gt; 'application/pdf'));
}
</code></pre>

<p>Where $id is the Id of the purchase order.</p>

<p>This renders a xml file to PDF but without sylesheet.</p>

<p>This is the twig:</p>

<pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE pdf SYSTEM "%resources%/dtd/doctype.dtd"&gt;
{% set empresa = app.session.get('empresa') %}

&lt;pdf&gt;
    &lt;page&gt;
&lt;div&gt;
    &lt;div&gt;
        &lt;table&gt;
            &lt;tr&gt;
                &lt;td&gt;
                    &lt;h3&gt;{{ empresa }}&lt;/h3&gt;
                &lt;/td&gt;
                &lt;td id="s1"&gt;
                    &lt;h2&gt;Número: &lt;b&gt;{{ id }}&lt;/b&gt;&lt;/h2&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;td&gt;
                    &lt;h3&gt;Orden de compra&lt;/h3&gt;
                &lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
                &lt;td&gt;&lt;/td&gt;
                &lt;td&gt;
                    Departamento de Finanzas
                &lt;/td&gt;
            &lt;/tr&gt;
        &lt;/table&gt;
    &lt;/div&gt;
    &lt;div&gt;
        {% for entity1 in entities1 %}
            Fecha: {{ entity1.fecha|date('d-m-Y') }}
        {% endfor %}
    &lt;/div&gt;
&lt;/div&gt;
        &lt;div&gt;
            &lt;div&gt;
                &lt;table width="100%"&gt;
                    &lt;tr&gt;
                        &lt;td width="60%"&gt;Producto&lt;/td&gt;
                        &lt;td width="20%"&gt;Unidad&lt;/td&gt;
                        &lt;td&gt;Cantidad&lt;/td&gt;
                        &lt;td&gt;Precio&lt;/td&gt;
                        &lt;td&gt;Total&lt;/td&gt;
                    &lt;/tr&gt;
                        {% set gran_total = 0 %}
                    {% for entity2 in entities2 %}
                        &lt;tr&gt;
                            &lt;td&gt;{{ entity2.productoOc.nombre }}&lt;/td&gt;
                            &lt;td&gt;{{ entity2.productoOc.unidadMedida.nombre }}&lt;/td&gt;
                            &lt;td class="text-right"&gt;{{ entity2.cantidad }}&lt;/td&gt;
                            &lt;td class="text-right"&gt;{{ entity2.precioCompra }}&lt;/td&gt;
                            &lt;td class="text-right"&gt;{{ entity2.total }}&lt;/td&gt;
                        &lt;/tr&gt;
                        {% set gran_total = gran_total + entity2.total %}
                    {% endfor %}
                    &lt;tr&gt;
                        &lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;/td&gt;
                        &lt;td class="text-right" &gt;{{ gran_total|number_format(2) }}&lt;/td&gt;
                    &lt;/tr&gt;
                &lt;/table&gt;
            &lt;/div&gt;
        &lt;/div&gt;

    &lt;/page&gt;
&lt;/pdf&gt;
</code></pre>