protected $infos;\r
protected $cropped;\r
protected $uncropped;\r
+ protected $rgb;\r
\r
const NORMAL = 0;\r
const FLATTEN = 1;\r
const BITMAP = 3;\r
const BARBARE_PNM = 4;\r
const BARBARE_GS = 5;\r
-\r
const MAX = 5;\r
-\r
const PNM_FILL = 2;\r
\r
protected static $resolution2multiply = array(72 => 2, 100 => 2, 150 => 3, 200 => 3, 300 => 3, 450 => 4, 600 => 5);\r
mkdir($this->html, 0755);\r
}\r
$this->cropped = $this->out . 'crop.pdf';\r
+ $this->rgb = $this->out . 'rgb.pdf';\r
$this->uncropped = $this->out . 'uncrop.pdf';\r
$this->pages_log_pointers = array();\r
\r
$this->addToLog('Detect Spreads : Manual cut ' . $this->manualcut . ' ; Auto cut : ' . $this->autocut);\r
}\r
\r
- public static function compareSizes($x, $y, $tolerance=0.9) {\r
+ public static function compareSizes($x, $y, $tolerance = 0.9) {\r
return cubeMath::compare($x[0], $y[0], $tolerance) && cubeMath::compare($x[1], $y[1], $tolerance);\r
}\r
\r
if ($this->CropAndCut()) {\r
$this->getInfos($this->cropped, true);\r
}\r
+ $this->performColorTransformations();\r
$this->extractFonts();\r
$this->getLinksAndTexts();\r
}\r
\r
+ public function performColorTransformations() {\r
+ $out = $this->out . '/rgb.pdf';\r
+\r
+ $gs = new cubeCommandLine('gs', null, true);\r
+ $gs->setPath(CONVERTER_PATH);\r
+ $gs->setEnv('GS_FONTPATH', FONT_PATH);\r
+ $gs->setArg('-dBATCH');\r
+ $gs->setArg('-dNOPAUSE');\r
+ $gs->setArg('-dNOPROMPT');\r
+ // Device\r
+ $gs->setArg('-sDEVICE=pdfwrite');\r
+ // \r
+ $gs->setArg('-dDownsampleColorImages=false');\r
+ $gs->setArg('-dDownsampleGrayImages=false');\r
+ $gs->setArg('-dDownsampleMonoImages=false');\r
+ // Dispotion & colors\r
+ $gs->setArg('-dConvertCMYKImagesToRGB=true');\r
+ $gs->setArg('-dAutoRotatePages=/None');\r
+ $gs->setArg('-dUseCropBox');\r
+ $gs->setArg('-dShowAnnots=false');\r
+ // Performances\r
+ $gs->setArg('-dNumRenderingThreads=4');\r
+ // Page range\r
+ // Files\r
+ $gs->setArg('-sOutputFile=' . $out);\r
+\r
+ $gs->setArg(null, $this->cropped);\r
+ $gs->execute();\r
+ \r
+ $this->addToLog($gs);\r
+ }\r
+\r
public function CropAndCut() {\r
if (!$this->isCropped()) {\r
copy($this->in, $this->cropped);\r
return $this->autocrop || $this->manualcrop || $this->autocut || $this->manualcut;\r
}\r
\r
- public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null, $version=null) {\r
+ public function makeSWFFiles($page, $resolution = null, $quality = null, $storeAllChars = null, $maxObjects = null, $method = null, $version = null) {\r
$conversionSettings = $this->conversionInfos->pages[$page];\r
if (is_null($storeAllChars)) {\r
$storeAllChars = true;\r
* @param integer $method\r
* @return\r
*/\r
- protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p', $version='stable') {\r
+ protected function pdf2swf($page, $resolution = 150, $quality = 90, $storeAllChars = true, $method = 0, $prefix = 'p', $version = 'stable') {\r
/*\r
-h , --help Print short help message and exit\r
-V , --version Print version info and exit\r
$pdf2swf->setArg('set jpegquality', $quality);\r
$pdf2swf->setArg('set disablelinks');\r
$pdf2swf->setArg('set dots');\r
- $pdf2swf->setArg(null, $this->cropped);\r
+ if(file_exists($this->rgb)){\r
+ $pdf2swf->setArg(null, $this->rgb);\r
+ }else{\r
+ $pdf2swf->setArg(null, $this->cropped);\r
+ }\r
$pdf2swf->setArg('output', $this->out . $prefix . '%.swf');\r
$pdf2swf->execute();\r
\r
}\r
\r
public function resetLog() {\r
- file_put_contents($this->log . '/commons.log', '');\r
+ unlink($this->log . '/commons.log.gz');\r
}\r
\r
public function addToLog($cl, $output = true, $page = null) {\r