private function getContents($pdf_file) { $this->locked = true; // echo $file; $info = new Pdf($pdf_file); $pdf = new Base($pdf_file, array('singlePage' => true, 'noFrames' => false)); $pages = $info->getPages(); // print_r($pages); // print_r($pages); $random_dir = uniqid(); $outputDir = Config::get('pdftohtml.output', dirname(__FILE__) . '/../output/' . $random_dir); if (!file_exists($outputDir)) { mkdir($outputDir, 0777, true); } $pdf->setOutputDirectory($outputDir); $pdf->generate(); $fileinfo = pathinfo($pdf_file); $base_path = $pdf->outputDir . '/' . $fileinfo['filename']; $contents = array(); for ($i = 1; $i <= $pages; $i++) { $content = file_get_contents($base_path . '-' . $i . '.html'); if ($this->inlineCss()) { // $content = str_replace(array('<!--','-->'),'',$content); $parser = new Emogrifier($content); // print_r($parser); $content = $parser->emogrify(); } file_put_contents($base_path . '-' . $i . '.html', $content); $contents[$i] = file_get_contents($base_path . '-' . $i . '.html'); } $this->contents = $contents; $this->goToPage(1); }
public function testConfiguration() { $pdf = new Base(); $this->assertEquals('/usr/bin/pdftohtml', $pdf->bin()); Config::set('pdftohtml.bin', '/usr/local/bin/pdftohtml'); $this->assertEquals('/usr/local/bin/pdftohtml', $pdf->bin()); Config::set('pdftohtml.bin', '/usr/bin/pdftohtml'); }