Skip to content

Instantly share code, notes, and snippets.

@slowprog
Forked from nfreear/pdftohtml-example.php
Created June 11, 2013 21:29
Show Gist options
  • Save slowprog/5760878 to your computer and use it in GitHub Desktop.
Save slowprog/5760878 to your computer and use it in GitHub Desktop.
<?php
// Standalone context.
define('PDFTOHTML_PATH', 'X:/PATH TO/workspace/_ouplayer_data/pdftohtml-0.39/pdftohtml.exe'); # Windows.
#define('PDFTOHTML_PATH', '/usr/bin/pdftohtml'); # Redhat 6.
require_once 'libraries/pdftohtml.php';
//( Or, CodeIgniter context. )
#$config['pdftohtml_path'] = '/usr/bin/pdftohtml';
#$this->load->library('pdftohtml');
$pdf = '/my/data/transcripts/l314audio2.pdf'; #Ok.
$xml = str_replace('.pdf', '.xml', $pdf); //tmp file?
$ofile = str_replace('.pdf', '_transcript.html', $pdf);
try {
$parser = new Pdftohtml();
$out = $parser->parse($pdf, $xml, $delete_xml = TRUE);
$by = file_put_contents($ofile, $out);
echo "Ok, written $by bytes | $ofile".PHP_EOL;
}
catch(Exception $ex) {
die('EX: '.$ex->getMessage().PHP_EOL);
}
/*
pdftohtml binary install (Redhat Linux)
$ yum info poppler
$ yum install poppler
$ pdftohtml -v
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment