psliwa / PdfBundle

This bundle integrates Symfony2 with PHPPdf library.
http://ohey.pl
MIT License
120 stars 45 forks source link

PDF isn't generated right #54

Closed reypm closed 8 years ago

reypm commented 10 years ago

Hi, I'm using your bundle to generate a PDF file and I'm doing in this way:

/**
 * @Pdf()
 * @Route("/admin/generatePDF", name="generatePDF",  defaults={ "_format"="pdf" })
 * @Template()
 */
public function generateInvoicePDFAction($name = 'Pedro')
{
    $facade = $this->get('ps_pdf.facade');
    $response = new Response();
    $this->render('BackendBundle:generateInvoice.pdf.twig', array('name' => $name), $response);
    $xml = $response->getContent();
    $content = $facade->render($xml);
    return new Response($content, 200, array('content-type' => 'application/pdf'));
}

This is the content of generateInvoice.pdf.twig file:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE pdf SYSTEM "%resources%/dtd/doctype.dtd">
<pdf>
<dynamic-page>
Hello {{ name }}!
</dynamic-page>
</pdf>

But in my browser console I get a lot of errors like for example:

Warning: Ignoring invalid character "109" in hex string pdf.worker.js (line 235) Warning: Ignoring invalid character "76" in hex string pdf.worker.js (line 235) Warning: Ignoring invalid character "104" in hex string pdf.worker.js (line 235) Warning: Ignoring invalid character "117" in hex string

Why? What I've missed here?

psliwa commented 10 years ago

The pdf was generated properly? "browser console" - you mean something like firebug or chrome dev console?