Some pages on one of my sites give almost empty PDF output. I tracked down the problem to print_pdf.pages.inc, around line 365.
The code used to replace <p>s by <br />s can trigger many problems. For example, if you take this simple HTML code:
<p class="foo">Bug!</p>
the print module will pass
<p class="foo">Bug!
to tcpdf. This is no valid HTML, and tcpdf doesn't like that at all, thus the almost empty page.
One quick and dirty way to make it work is to change the line to
$matches[1] = preg_replace('!(<p.*?>|<p\s*/>|</p>!i)', '<br />', $matches[1]);
but it would probably need a much better filter, way beyond my knowledge to give.
Comments
Comment #1
jcnventuraIndeed the pattern matching could be improved. Thanks for the suggestion. I have just committed a better preg_replace pattern.
João
Comment #2
voytechs commentedThis fixes my empty book problem, but one little tiny error with the reg expression above:
The closing ')' character was outside the reg-expression. Otherwise the pattern works great in both versions print-1.4 and print-1.5.
Comment #3
jcnventuraActually there are several errors with the expression above:
1. It will also replace <pre> and <param> tags
2. The second alternative is never matched because of the more general first alternative
3. It is creating a group when none is used
4. It deletes whatever attributes used to be in the p tag
The expression that was committed yesterday was:
Which is more confusing to understand, but doesn't suffer from any of the problems I identified above.