0

I can't open PDF files created with php html2pdf even if with browsers I can display it correctly why?

<?php
    ob_start();
?>
<page orientation="P" backtop="10mm" backbottom="30mm" backleft="10mm" backright="10mm" style="font-family:Century_Gothic">
    some text
</page>

<?php
    $content=ob_get_clean();
    require_once(dirname(__FILE__).'/../../html2pdf/html2pdf.class.php');
    $html2pdf=new HTML2PDF('P','A4','it');
    $html2pdf->addFont('Century_Gothic','normal','Century_Gothic.php');
    $html2pdf->WriteHTML($content);
    $pdf=addslashes($html2pdf->Output('',true));
    $html2pdf->Output("test.pdf","F");
?>
Billal Begueradj
  • 20,717
  • 43
  • 112
  • 130
Miky
  • 181
  • 1
  • 5
  • 15
  • 1. what _exact_ error message do you get and 2. what if you try other pdf viewers? – arkascha Mar 08 '17 at 16:59
  • ERROR: An error has occurred with this page. The page could not be displayed correctly. Contact the author of the PDF to correct the problem. I tried only with browsers – Miky Mar 08 '17 at 17:04
  • Try with a few other PDF renderers (viewers), start them directly from the command line to receive their error output. You need to find out the cause of the issue. – arkascha Mar 08 '17 at 17:25
  • once, trying to find a solution, remember I read on adobe reader an error like "couldn't use font..." – Miky Mar 08 '17 at 20:55
  • PDF renderers usually select a replacement font, so a default, in case of a specific font not being available. That should _not_ lead to the issue that the document cannot be opened. – arkascha Mar 08 '17 at 22:23
  • One question: is there a specific reason why you do not want to try some other PDF viewer? – arkascha Mar 08 '17 at 22:23
  • no, simply I'm out of office. can you suggest me a PDF viewer that can help me in debug? – Miky Mar 08 '17 at 23:03
  • I think you will find loads on google. I personally love `okular`, best document viewer that exists, but on MS-Windows you are limited, maybe the fox viewer is of interest. – arkascha Mar 08 '17 at 23:04
  • on adobe reader I receive "there was an error processing a page. there was a problem reading this document (135)" , now I'll try other viewers – Miky Mar 09 '17 at 08:50

0 Answers0