protected $log_pointer;\r
protected $infos;\r
protected $textes;\r
+ protected $phperrors;\r
\r
private $_basicInfos = null;\r
private $_advancedInfos = null;\r
private $_links = array();\r
+ private $_memoErrorLog;\r
\r
const NORMAL = 0;\r
const FLATTEN = 1;\r
$this->in = $this->out . 'original.pdf';\r
$this->infos = $this->out . 'infos.txt';\r
$this->textes = $this->out . 'textes.txt';\r
+ $this->phperrors = $this->out . 'php.err';\r
if (!file_exists($this->out)) {\r
mkdir($this->out, 0755, true);\r
}\r
$this->log_pointer = fopen($this->log, 'a');\r
+ $this->_memoErrorLog = ini_get('error_log');\r
+ ini_set('error_log', $this->phperrors);\r
}\r
\r
public function copyOriginal($tmp_file)\r
$this->makeMiniShot($page);\r
$this->makeRealShot($page);\r
$this->makeSWFFiles($page);\r
+ $this->makeAS3($page);\r
}\r
\r
public function processAllPages()\r
}\r
}\r
\r
- public function getTexts($page = null)\r
+ public function getTexts($page)\r
{\r
$pdftotext = new cubeCommandLine('pdftotext', null, true);\r
$pdftotext->setPath(CONVERTER_PATH);\r
$pdftotext->setArg('q');\r
- if (is_null($page)) {\r
- $pdftotext->setArg('f', 1);\r
- $pdftotext->setArg('l', 10000);\r
- } else {\r
- $pdftotext->setArg('f', $page);\r
- $pdftotext->setArg('l', $page);\r
- }\r
+ $pdftotext->setArg('f', $page);\r
+ $pdftotext->setArg('l', $page);\r
$pdftotext->setArg('-eol', 'unix');\r
$pdftotext->setArg('-enc', 'UTF-8');\r
$pdftotext->setArg(null, $this->in);\r
- $pdftotext->setArg(null, $this->textes);\r
+ $pdftotext->setArg(null, $this->out . 'p' . $page . '.txt');\r
$pdftotext->execute();\r
$this->addToLog($pdftotext);\r
}\r
\r
- public function makeMiniShot($page = null)\r
+ public function makeMiniShot($page)\r
{\r
$this->makeShotFixedWidth($page, 'p', 100, 70, 4, 'GS');\r
}\r
\r
- public function makeRealShot($page = null)\r
+ public function makeRealShot($page)\r
{\r
$this->makeShot($page, 'te', 72);\r
}\r
\r
- public function makeShotFixedWidth($page = null, $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ public function makeShotFixedWidth($page , $prefix = '', $w = 100, $quality = 90, $antialiasing = 4, $method = 'GS')\r
{\r
// Make thumbs of $w width\r
// resolution 72 make 1pt=1px\r
$this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
}\r
\r
- public function makeShotFixedHeight($page = null, $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ public function makeShotFixedHeight($page , $prefix = '', $h = '', $quality = 90, $antialiasing = 4, $method = 'GS')\r
{\r
// Make thumbs of $w height\r
// resolution 72 make 1pt=1px\r
$this->makeShot($page, $prefix, round(72 / $ratio, 2), $quality, $antialiasing, $method);\r
}\r
\r
- public function makeShot($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS')\r
+ public function makeShot($page , $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $method = 'GS')\r
{\r
// Delete all old files\r
- for($i = 1;$i <= $this->generalInfos['pages'];$i++) {\r
- if (file_exists($this->out . $prefix . $i . '.jpg')) {\r
- @unlink($this->out . $prefix . $i . '.jpg');\r
- }\r
- }\r
if ($method == 'GS') {\r
$this->makeShotGS($page, $prefix, $resolution, $quality, $antialiasing);\r
} elseif ($method == 'PNM') {\r
$this->makeShotPNM($page, $prefix, $resolution, $quality, $antialiasing);\r
}\r
// Test the result by checking all files\r
- $error = false;\r
- $startpage = is_null($page)?1:$page;\r
- $endpage = is_null($page)?$this->generalInfos['pages']:$page;\r
-\r
- for($i = $startpage;$i <= $endpage;$i++) {\r
- if (!file_exists($this->out . $prefix . $i . '.jpg')) {\r
- $error = true;\r
- break;\r
- }\r
+ if (!file_exists($this->out . $prefix . $page . '.jpg')) {\r
+ $error = true;\r
}\r
// If error, we try to make thumbs with other method\r
if ($error) {\r
}\r
}\r
\r
- protected function makeShotGS($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
+ protected function makeShotGS($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
{\r
// Fabrication des thumbanails avec ghostscript\r
$gs = new cubeCommandLine('gs', null, true);\r
$gs->setArg('-dTextAlphaBits=' . $antialiasing);\r
$gs->setArg('-dGraphicsAlphaBits=' . $antialiasing);\r
// $gs->setArg('-dUseCropBox');\r
- if (!is_null($page)) {\r
- $gs->setArg('-dStartPage=' . $page);\r
- $gs->setArg('-dEndPage=' . $page);\r
- }\r
+ $gs->setArg('-dFirstPage=' . $page);\r
+ $gs->setArg('-dLastPage=' . $page);\r
$gs->setArg('-sOutputFile=' . $this->out . '/' . $prefix . '%d.jpg');\r
$gs->setArg('-dAutoRotatePages=/None');\r
$gs->setArg(null, $this->in);\r
$this->addToLog($gs);\r
}\r
\r
- protected function makeShotPNM($page = null, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
+ protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4)\r
{\r
$antialiasing = $antialiasing?'yes':'no';\r
$resolution = round($resolution);\r
// Exporte les fichiers\r
$pdftoppm = new cubeCommandLine('pdftoppm', null, true);\r
$pdftoppm->setPath(CONVERTER_PATH);\r
- if (is_null($page)) {\r
- $pdftoppm->setArg('f', 1);\r
- $pdftoppm->setArg('l', 10000);\r
- } else {\r
- $pdftoppm->setArg('f', $page);\r
- $pdftoppm->setArg('l', $page);\r
- }\r
+\r
+ $pdftoppm->setArg('f', $page);\r
+ $pdftoppm->setArg('l', $page);\r
\r
$pdftoppm->setArg('-freetype yes');\r
$pdftoppm->setArg('-aa ' . $antialiasing);\r
}\r
}\r
\r
- public function makeSWFFiles($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1)\r
+ public function makeSWFFiles($page , $resolution = 150, $quality = 90, $storeAllChars = true, $maxObjects = 1800, $method = 0, &$muliply = 1)\r
{\r
if ($maxObjects <= 1) {\r
$method = self::POLY2BITMAP;\r
$written = true;\r
}\r
if ($written && $method < self::BITMAP && !isset($this->_links[$page])) {\r
- file_put_contents(ROOT . '/test.txt', print_r($out, true));\r
$this->_links[$page] = $this->extractLinks($page, $out['outputfile'], $out['multiply']);\r
}\r
// On teste si le fichier est écrit et qu'il a été généré par le premier niveau\r
return false;\r
}\r
\r
- protected function pdf2swf($page = null, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0)\r
+ protected function pdf2swf($page , $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0)\r
{\r
/*\r
-h , --help Print short help message and exit\r
disablelinks Disable links.\r
*/\r
\r
- if (!is_null($page) && file_exists($this->out . 'p' . $page . '.swf')) {\r
+ if (file_exists($this->out . 'p' . $page . '.swf')) {\r
unlink($this->out . 'p' . $page . '.swf');\r
}\r
\r
\r
$pdf2swf = new cubeCommandLine('pdf2swf', null, true);\r
$pdf2swf->setPath(CONVERTER_PATH);\r
- if (!is_null($page)) {\r
- $pdf2swf->setArg('p', $page);\r
- }\r
+\r
+ $pdf2swf->setArg('p', $page);\r
+\r
if ($method == self::NORMAL) {\r
// Default\r
$multiply = 1;\r
}\r
}\r
\r
- protected function makeAS3($swffile)\r
+ protected function makeAS3($page)\r
{\r
+ $swffile = $this->out . 'p' . $page . '.swf';\r
+\r
$swfcombine = new cubeCommandLine('swfcombine');\r
$swfcombine->setPath(CONVERTER_PATH);\r
$swfcombine->setArg('merge');\r
$this->addToLog($swfcombine);\r
}\r
\r
- protected function pdf2swfBarbare($page = null, $resolution = 150, $quality = 85, $method = 4)\r
+ protected function pdf2swfBarbare($page, $resolution = 150, $quality = 85, $method = 4)\r
{\r
// Fabrique les images\r
if ($method == BARBARE_PNM) {\r
$this->makeShot($page, 'barbare', $resolution, $quality, 4, 'GS');\r
}\r
// A partir des images, on crée les swf\r
- if (is_null($page)) {\r
- $startpage = 1;\r
- $endpage = $this->generalInfos['pages'];\r
- } else {\r
- $startpage = $endpage = $page;\r
- }\r
+ $jpeg2swf = new cubeCommandLine('jpeg2swf');\r
+ $jpeg2swf->setPath(CONVERTER_PATH);\r
+ $jpeg2swf->setArg('q', $quality);\r
+ $jpeg2swf->setArg('o', $this->out . 'p' . $page . '.swf');\r
+ $jpeg2swf->setArg('f');\r
+ $jpeg2swf->setArg(null, $this->out . 'barbare' . $page . '.jpg');\r
+ $jpeg2swf->execute();\r
+ $this->addToLog($jpeg2swf);\r
+ // Suppression du jpeg\r
+ @unlink($this->out . '/barbare' . $page . '.jpg') ;\r
\r
- for($i = $startpage;$i <= $endpage;$i++) {\r
- $jpeg2swf = new cubeCommandLine('jpeg2swf');\r
- $jpeg2swf->setPath(CONVERTER_PATH);\r
- $jpeg2swf->setArg('q', $quality);\r
- $jpeg2swf->setArg('o', $this->out . 'p' . $i . '.swf');\r
- $jpeg2swf->setArg('f');\r
- $jpeg2swf->setArg(null, $this->out . 'barbare' . $i . '.jpg');\r
- $jpeg2swf->execute();\r
- $this->addToLog($jpeg2swf);\r
- // Suppression du jpeg\r
- @unlink($this->out . '/barbare' . $i . '.jpg') ;\r
- }\r
return '';\r
}\r
\r
$c .= $cl->output . "\n\n";\r
}\r
} elseif (is_string($cl)) {\r
- $c = $cl;\r
+ $c = '--- ' . "\n\n";\r
+ $c .= $cl . "\n\n";\r
}\r
fwrite($this->log_pointer, $c);\r
}\r
if (isset($this->log_pointer) && is_resource($this->log_pointer)) {\r
fclose($this->log_pointer);\r
}\r
+ ini_set('error_log', $this->_memoErrorLog);\r
}\r
}\r
\r