I try to make a pdf out of html. I use the following code.
require_once dirname(__FILE__).'/../vendor/autoload.php';
use Spipu\Html2Pdf\Html2Pdf;
use Spipu\Html2Pdf\Exception\Html2PdfException;
use Spipu\Html2Pdf\Exception\ExceptionFormatter;
try {
ob_start();
include dirname(__FILE__).'/res/experiment.php';
$content = ob_get_clean();
$html2pdf = new html2pdf('P','A4','fr');
$html2pdf->pdf->SetDisplayMode('fullpage');
$html2pdf->writeHTML($content);
$html2pdf->Output('experiment.pdf');
} catch (Html2PdfException $e) {
$formatter = new ExceptionFormatter($e);
echo $formatter->getHtmlMessage();
}
The experiment.php is as follows.
<page>
<p>First page</p>
</page>
<page>
<p>Second page</p>
</page>
As a result I get a blank page with a question mark at the beginning, followed by the expected different First page and Second page.
How to avoid the blank page. Is the question mark on it some kind of error notification. It happens if only experiment.php is UTF-8 encoded. If it is encoded as ansi everything is ok. But I need UTF-8 as my text to convert to pdf uses cyrillic.