}
}
+ public function getCroppedPDF(){
+ if(!file_exists($this->cropped)){
+ return $this->in;
+ }
+ return $this->cropped;
+ }
+
public function copyOriginalFromUpload($tmp_file)
{
move_uploaded_file($tmp_file, $this->in);
mkdir($this->out . '/pdf');
$pdftk = new cubeCommandLine('pdftk');
$pdftk->setPath(CONVERTER_PATH);
- $pdftk->setArg(null, $this->cropped);
+ $pdftk->setArg(null, $this->getCroppedPDF());
$pdftk->setArg(null, 'burst');
$pdftk->setArg(null, 'output');
$pdftk->setArg(null, $this->out . 'pdf/p%d.pdf');
{
$fwstk = new cubeCommandLine('fwstk.sh');
$fwstk->setPath(CONVERTER_PATH);
- $fwstk->setArg('--input ' . $this->cropped);
+ $fwstk->setArg('--input ' . $this->getCroppedPDF());
$fwstk->setArg('--extractLinks ' . $this->out . 'p%d.csv');
$fwstk->setArg('--threads 1');
$fwstk->execute();
{
$fwstk = new cubeCommandLine('fwstk.sh');
$fwstk->setPath(CONVERTER_PATH);
- $fwstk->setArg('--input ' . $this->cropped);
+ $fwstk->setArg('--input ' . $this->getCroppedPDF());
$fwstk->setArg('--layout ' . $this->html . 'p%d.fby');
$fwstk->setArg('--cmaps ' . $this->html);
$fwstk->setArg('--fonts' . $this->out . 'fonts/web/');
{
$error = false;
if (is_null($in)) {
- $in = $this->cropped;
+ $in = $this->getCroppedPDF();
}
// Delete all old files
$res = $this->out . $prefix . $page . '.jpg';
protected function makeShotGS($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null)
{
if (is_null($in)) {
- $in = $this->cropped;
+ $in = $this->getCroppedPDF();
}
// Fabrication des thumbanails avec ghostscript
$gs = new cubeCommandLine('gs', null, true);
protected function makeShotPNM($page, $prefix = '', $resolution = 72, $quality = 90, $antialiasing = 4, $in = null, $texts = true)
{
if (is_null($in)) {
- $in = $this->cropped;
+ $in = $this->getCroppedPDF();
}
$tmp = cubeFiles::tempnam();
public function makeSVGFile($page)
{
$svgFile = $this->out . '/html/fp' . $page . '.svg';
- $source = $this->cropped;
- if (!file_exists($this->cropped)) {
- $source = $this->in;
- }
+ $source = $this->getCroppedPDF();
$pdftocairo = new cubeCommandLine('pdftocairo');
$pdftocairo->setPath(CONVERTER_PATH);
self::$_r = $resolution;
$osvg = preg_replace_callback('|\<image([^>]*)\>|', 'wsTools::optimizeRaster', $svg);
$ofname = sprintf($optimized, '-' . $resolution);
- echo $ofname . "\n";
file_put_contents($ofname, $osvg);
}
}
preg_match_all('/([\d\-\.]+)/', $attrs['transform'], $ma);
$values = $ma[0];
$scale = max($values[0], $values[1]);
-
}
$resolutionScale = ($iw / $attrs['width']) * $scale * (self::$_r / 72);
- echo $resolutionScale . "\n";
$dw = round($resolutionScale * $iw);
$dh = round($resolutionScale * $ih);
$thisimagesvg = !$thisrasterize && $this->svg;
$thisbackgroundPrefix = $thisrasterize ? ['t'] : $this->backgroundsPrefix;
+ foreach ($this->getResolutions() as $r) {
+ foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
+ $srcPrefix = $backgroundsPrefix;
+ if ($backgroundsPrefix == 'p') {
+ $srcPrefix = 'h';
+ }
+ $source = $docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg';
+ if (!file_exists($source)) {
+ if (!isset($doc) || $doc->document_id != $infos['document_id']) {
+ $dao = new wsDAODocument($core->con);
+ $doc = $dao->selectById($infos['document_id']);
+ }
+ $doc->makeHTML5Files($infos['document_page']);
+ }
+ $ok = $this->vdir->copy($source, 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg');
+ if (!$ok && $r = 300) {
+ $this->maxRes = 150;
+ }
+ }
+ }
+
if ($thisimagesvg) {
$full = $docdir . 'html/fp' . $infos['document_page'] . '.svg';
$fullopt = $docdir . 'html/fo' . $infos['document_page'] . '%s.svg';
}
}
- foreach ($this->getResolutions() as $r) {
- foreach ($thisbackgroundPrefix as $backgroundsPrefix) {
- $srcPrefix = $backgroundsPrefix;
- if ($backgroundsPrefix == 'p') {
- $srcPrefix = 'h';
- }
- $ok = $this->vdir->copy($docdir . 'html/' . $srcPrefix . $r . '-' . $infos['document_page'] . '.jpg', 'data/background/' . $r . '/' . $backgroundsPrefix . $page . '.jpg');
- if (!$ok && $r = 300) {
- $this->maxRes = 150;
- }
- }
- }
$thumb = false;
if ($this->book->parametres->pdfThumbnails) {