But it has no problem when opened in Google Chrome. When I opened it with Safari/Preview, I got a blank page. Zooming in/out does nothing.
Below is the code I used for generating the PDF files:
require_once('../vendor/tecnickcom/tcpdf/tcpdf.php');
class MYPDF extends TCPDF {
//Page header
public function Header() {
// get the current page break margin
$bMargin = $this->getBreakMargin();
// get current auto-page-break mode
$auto_page_break = $this->AutoPageBreak;
// disable auto-page-break
$this->SetAutoPageBreak(false, 0);
// set bacground image
$img_file = '../assets/img/background.jpg';
$this->Image($img_file, 0, 0, 150, 90, '', '', '', false, 150, '', false, false, 0);
// restore auto-page-break status
$this->SetAutoPageBreak($auto_page_break, $bMargin);
// set the starting point for the page content
$this->setPageMark();
}
}
$pdf = new MYPDF('L', PDF_UNIT, [150, 90], true, 'UTF-8');
$pdf->SetCreator(PDF_CREATOR);
$pdf->SetAuthor('Kent');
$pdf->SetTitle('Title Here');
$pdf->SetSubject('Subject Here');
$pdf->SetTopMargin(44);
$pdf->setPrintFooter(false);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);
$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO);
$pdf->SetFont('helvetica', '', 44);
$pdf->AddPage();
$pdf->writeHTML('This is the content.', false, false, false, false, 'C');
$pdf->Output(__DIR__ . '/output.pdf', 'F');
2 reasons for this problem , first please use absolute path, secondly your pdf does not open in adobe acrobat either. it is because your image is missing icc profile . open your photo and save it again in Photoshop or similar software.