FrDeamon / EnseparHtml2pdfBundle

Html2pdf for Symfony 2 as a service.
MIT License
22 stars 22 forks source link

render pdf #7

Closed nicosampler closed 11 years ago

nicosampler commented 11 years ago

hello, i have a problem when i want render the pdf.

in my controller.. i have public function indexAction() { $content = " page> h1>Exemple d'utilisation/h1> br> Ceci est un b>exemple d'utilisation/b> page>";

    $html2pdf = $this->get('html2pdf')->get();
    $html2pdf->writeHTML($content);       
    $rta = $html2pdf->Output('exemple.pdf');

    return $this->render($rta, array());
}

in my browser i have...

%PDF-1.7 3 0 obj <> /Resources 2 0 R /Annots [ 200001 0 R ] /Contents 4 0 R>> endobj 4 0 obj <> stream x���1O�0�w����}!��)��Jު��UP)�MU~>!iHma�-߻{�t�-)�X�ч����da\C��q�p�SP2���H�����[W�՗�YV��~�Urs^L̃��# RWF�PC'��ax����שGv�*�i�|(�����_� ��;�6b������9���j�MF����DF�j�}�wH4�-%�ņ�oui/m�ٚPl�yq7�����z5N#� b��z0����?���TԢ�F�ڏ�H�y�<��{��v�& endstream endobj 1 0 obj <> endobj 5 0 obj << /Type /OCG /Name (��print) /Usage << /Print <> /View <> >> >> endobj 6 0 obj << /Type /OCG /Name (��view) /Usage << /Print <> /View <> >> >> endobj 7 0 obj <> endobj 8 0 obj <> endobj 2 0 obj << /ProcSet [/PDF /Text /ImageB /ImageC /ImageI] /Font << /F1 7 0 R /F2 8 0 R >> /XObject << >> /Properties <> /ExtGState << >> >> endobj 200001 0 obj <> /H /I>> endobj 9 0 obj << /Creator (��HTML2PDF - TCPDF) /Producer (��TCPDF 5.0.002 (http://www.tcpdf.org) (TCPDF)) /CreationDate (D:20130609233814+00'00') /ModDate (D:20130609233814+00'00') >> endobj 10 0 obj << /Type /Catalog /Pages 1 0 R /OpenAction [3 0 R /FitH null] /PageLayout /SinglePage /PageMode /UseNone /Names << >> /ViewerPreferences << /Direction /L2R >> /OCProperties <> <>]>>>> >> endobj xref 0 11 0000000000 65535 f 0000000536 00000 n 0000001049 00000 n 0000000009 00000 n 0000000198 00000 n 0000000596 00000 n 0000000715 00000 n 0000000832 00000 n 0000000938 00000 n 0000001477 00000 n 0000001726 00000 n 200001 1 0000001218 00000 n trailer << /Size 11 /Root 10 0 R /Info 9 0 R >> startxref 2092 %%EOF

thanks and im sorry for my bad english.

OwlyCode commented 11 years ago

I'm sorry I don't understand anything at what you are writing. If I guess right what you're asking for, it looks like you are not defining a content-type for your response.

Try to add the code below to your controller.

$this->get('response')->headers->set('Content-Type', 'application/pdf');
nicosampler commented 11 years ago

im sorry, i can resolve my problem. you right, i not set the content-type

nicosampler commented 11 years ago

thanks!