2

We’ve using dompdf for months without any problem. Recently we had some other problems with the server (Ubuntu 16.04) and after fix them and reboot. It seems that DOMDocument has gone and we reinstall it (on PHP 7.0). But we can’t get it working again.

Our code:

$dompdf = new Dompdf();  
$dompdf->loadHtml("hello world");
$dompdf->render();
$dompdf->stream("document");

After that only happen these two things:

1) When we comment $dompdf->stream() line it only shows this message:

Notice: Undefined property: DOMText::$data in /var/www/project/vendor/dompdf/src/FrameDecorator/Text.php on line 71

2) When uncomment it only generates blank PDF.

We are so lost on this for days and any kind of help will be great.

A lot of thanks at advance.

Regards.


If we use

var_dump($this->_frame->get_node()); 

at the line from the message (/var/www/project/vendor/dompdf/src/FrameDecorator/Text.php)

…It throws this:

object(DOMText)#1221 (17) {
  ["data"]=>  string(0) ""
  ["nodeName"]=>  string(5) "#text"
  ["nodeValue"]=>  string(11) "hello world"
  ["nodeType"]=>  int(3)
  ["parentNode"]=>  string(22) "(object value omitted)"
  ["childNodes"]=>  NULL
  ["firstChild"]=>  NULL
  ["lastChild"]=>  NULL
  ["previousSibling"]=>  NULL
  ["nextSibling"]=>  NULL
  ["attributes"]=>  NULL
  ["ownerDocument"]=>  string(22) "(object value omitted)"
  ["namespaceURI"]=>  NULL
  ["prefix"]=>  string(0) ""
  ["localName"]=>  NULL
  ["baseURI"]=>  NULL
  ["textContent"]=>  string(11) "hello world"
}

Thanks for the help anyway. Really :)

Bhargav Rao
  • 50,140
  • 28
  • 121
  • 140

2 Answers2

0

I have been using domPDF successfully, the only difference to your routine is that in between $dompdf->loadHtml(...); and $dompdf->render(); I am setting the paper size with

$dompdf->setPaper('A4', 'portrait');

You could try to add that - not sure if it makes a difference.

Johannes
  • 64,305
  • 18
  • 73
  • 130
  • We used that settings (among others) before it stopped working. Throws the same results. Thanks Johannes, we are still trying. – Jose A. Gomez May 10 '17 at 10:09
0

I faced this trouble, In my case, my app worked in development environment ( windows and windows server, apache, php), but problem occured in produciton ( ubuntu 18, nginx, php7.2-fpm).

when I run this : php --ini ; I got the following warning!

Warning: Module 'dom' already loaded in Unknown on line 0 Warning: Module 'mbstring' already loaded in Unknown on line 0 Warning: ........................ Warning: Module 'xxx' already loaded in Unknown on line 0

so I fix them like in these posts: here and here.

Remember that dompdf use php 'dom' extention and other. So if there is any problem occurs in dompdf then dompdf will not work.

Bussller
  • 1,961
  • 6
  • 36
  • 50
hamil.Dev
  • 137
  • 2
  • 9