FrDeamon / EnseparHtml2pdfBundle

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

Bulk Creation of multipage PDFs #12

Closed adyballa closed 10 years ago

adyballa commented 10 years ago

Hello,

We use your bundle to create a few longer reports. After the first PDF we got the error: Undefined property HTML2PDF_myPdf::$h We solved by creating new Instances. Notice clone doesnt work either. We changed the method get() in your ensepar\html2pdf-bundle\Ensepar\Html2pdfBundle\Service\Html2pdf.php file like that:

  public function get($fReset = false)
  {
      if ($fReset || null === $this->html2pdf) {
          $this->html2pdf = new \HTML2PDF($this->mode, $this->format, $this->lang, $this->unicode, $this->encoding, $this->margin);
      }

      return $this->html2pdf;
  }

By the way, we could not generate the PDF on the fly and send it via mail, because of bad encoding. That's really off-topic - perhaps you know something helpful.

Regards adyballa

OwlyCode commented 10 years ago

Hello,

Thank you for this report ! I will try to reproduce your problem this week-end and come up with a solution.

Concerning the encoding, can you provide me more details ?

OwlyCode commented 10 years ago

So it turns out using the same Html2pdf instance multiple time is not supported. So I made a v2.0 version which provide a factory instead of some kind of singleton. The 1.0 was actually a pretty bad implementation. I also added a testcase for this issue.

Beware there are some breaking changes, does it solves your problem ?

adyballa commented 10 years ago

Yes it works. btw the off-topc issue was a bug in my programm.

Perhaps I can bother you our project is not in time (its saturday :( ). I will not exaggerate. Nevermind thanks