2

This may have been asked multiple times, but is there a good HTML-to-PDF creator for PHP?

I'm currently using dompdf, and there is a whole list of unsupported things (such as postion:absolute inside a position:relative container, and float:right) which make my PDF render incorrectly.

dompdf forces me to make tables in order to align stuff the way I want. I made an HTML page using floats and relative+absolute positioning, but dompdf ignores this and overlaps all my text and positions them wrong.

It also randomly put a blank 2nd page even though I have both page-break-before and page-break-after set to avoid.

So, can anyone tell me a good PHP PDF creator, or tell me a workaround for dompdf's lack of floats or relative+absolute positioning (I hate tables)?

P.S. I am using dompdf 0.6.0beta1

Mark Storer
  • 15,672
  • 3
  • 42
  • 80
gen_Eric
  • 223,194
  • 41
  • 299
  • 337
  • 1
    Although you do not state it explicitly, you mean HTML -> PDF conversion within PHP, as opposed to regular PDF creation. – Orbling Feb 11 '11 at 16:53
  • @Orbling: Yeah, that's want I meant. – gen_Eric Feb 11 '11 at 16:55
  • 2
    Take a look at mPDF - http://mpdf.bpm1.com/ which I've recently discovered... no guarantees (I'm working with HTML tables anyway rather than styles for positioning) but it looks like it generates a good, clean PDF from HTML – Mark Baker Feb 11 '11 at 16:57
  • @Rocket: HTML rendering is incredibly complicated on a screen, rendering to print seems more complicated still, judging by the way most of the major browsers handle it. Always consult the [compatibility list](http://code.google.com/p/dompdf/wiki/CSSCompatibility) when using `dompdf` for HTML. I do not know any *better* HTML to PDF converter in PHP. – Orbling Feb 11 '11 at 17:00
  • @Mark: I tried mPDF, it seems to be better than dompdf. It doesn't support relative+absolute positioning, but it doesn't overlap text. Unfortunately, other HTML files (using tables) don't look right in mPDF. Oh well, guess I can just go and fix those to look correct. – gen_Eric Feb 11 '11 at 18:07
  • 3
    The final 0.6.0 release will have some significant improvements in positioning support. Have you taken a look at the latest code? [The examples](http://eclecticgeek.com/dompdf/docs_0-6-0/examples.php) include a "position_all" document that uses a variety of positioning methods. Unfortunately, float support is still underdeveloped, so I don't know if it'll be ready for the next release. – BrianS Feb 11 '11 at 19:30
  • @BrianS: It's nice to see that they are updating it. I just re-did, my HTML with tables, and it's ok for now. – gen_Eric Feb 11 '11 at 19:47

1 Answers1

0

I just decided to re-write my HTML using tables, so dompdf will render it the way I want. mPDF looked nice, I may switch to that in the future.

gen_Eric
  • 223,194
  • 41
  • 299
  • 337