From: vincent@cubedesigners.com Date: Fri, 5 Oct 2012 15:53:35 +0000 (+0000) Subject: (no commit message) X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=eb96dc30a41066c8fd133437f243406581cd8188;p=cubeextranet.git --- diff --git a/inc/ws/Controlleur/class.ws.services.php b/inc/ws/Controlleur/class.ws.services.php index 78717f5ec..e1cfc35a2 100644 --- a/inc/ws/Controlleur/class.ws.services.php +++ b/inc/ws/Controlleur/class.ws.services.php @@ -216,7 +216,12 @@ class wsServices extends cubeFlashGateway { return $terms; } - public function exportpdf() { + public function printpdf() { + $this->outputXML = false; + $this->exportpdf(true); + } + + public function exportpdf($print = false) { global $core; $daoBook = new wsDAOBook($core->con); @@ -226,7 +231,7 @@ class wsServices extends cubeFlashGateway { return; } - if (!$book->parametres->pdfComplex || !$book->parametres->pdf) { + if (!$book->parametres->pdfComplex && !$book->parametres->pdf && $book->parametres->printMode != 'pdf') { return; } // Normalize range @@ -255,29 +260,48 @@ class wsServices extends cubeFlashGateway { $destURL = '/fluidbook/cache/exportpdf/' . $book->book_id . '/' . $fname; // If result exists, don't make the pdf again if (file_exists($destFile) && filemtime($destFile) > filemtime($baseDocument)) { + + } else { + // Prepare the command line + $l = array('A=' . $baseDocument, 'cat'); + foreach ($range as $page) { + if ($page < 1 || $page > $book->parametres->pages) { + continue; + } + $l[] = 'A' . $page; + } + $l[] = 'output'; + $l[] = $destFile; + + $args = implode(' ', $l); + // Execute the command line + $pdftk = new cubeCommandLine('pdftk'); + $pdftk->setPath(CONVERTER_PATH); + $pdftk->setManualArg($args); + $pdftk->execute(); + } + + if (!$print) { + // Return the url of the resulting pdf http::redirect($destURL); exit; + } else { + $res = ' + + + + + + + + + + '; + fb($res); + ob_end_clean(); + echo $res; + exit; } - // Prepare the command line - $l = array('A=' . $baseDocument, 'cat'); - foreach ($range as $page) { - if ($page < 1 || $page > $book->parametres->pages) { - continue; - } - $l[] = 'A' . $page; - } - $l[] = 'output'; - $l[] = $destFile; - - $args = implode(' ', $l); - // Execute the command line - $pdftk = new cubeCommandLine('pdftk'); - $pdftk->setPath(CONVERTER_PATH); - $pdftk->setManualArg($args); - $pdftk->execute(); - // Return the url of the resulting pdf - http::redirect($destURL); - exit; } public function grdfValidForm() { diff --git a/inc/ws/Metier/class.ws.book.parametres.php b/inc/ws/Metier/class.ws.book.parametres.php index e86eee388..d571f597b 100644 --- a/inc/ws/Metier/class.ws.book.parametres.php +++ b/inc/ws/Metier/class.ws.book.parametres.php @@ -109,7 +109,8 @@ class wsBookParametres extends wsParametres { $this->fields['print'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Activer l'impression")); $this->fields['printMode'] = array('type' => 'combo', 'default' => 'vector', 'editable' => true, 'label' => __("Mode d'impression"), 'datas' => array(__('Bitmap') => 'bitmap', - __('Vectoriel') => 'vector')); + __('Vectoriel') => 'vector', + __('PDF') => 'pdf')); $this->fields['printCoverWithMarks'] = array('type' => 'boolean', 'default' => true, 'editable' => true, 'label' => __("Imprimer les couvertures avec les pages marquées"), 'grade' => 3); $this->forms['print'] = array('label' => __('Impression'), 'fieldsnames' => array('print', 'printMode', 'printCoverWithMarks')); diff --git a/js/pdfprint.js b/js/pdfprint.js new file mode 100644 index 000000000..60ed934f1 --- /dev/null +++ b/js/pdfprint.js @@ -0,0 +1,31 @@ +$(function() { + $("iframe").load(function() { + printPDF(this); + }); + + $("iframe").on('readystatechange', function() { + if (this.readyState === 'complete') { + printPDF(this); + } + }); +}) +function printPDF(iframe) { + if (iframe == undefined) { + iframe = document.getElementById('pdf'); + } + + setTimeout(function() { + try { + iframe.contentWindow.print(); + } catch (err) { + } + }, 1500); +} + +function fb(o) { + try { + console.log(o); + } catch (err) { + + } +} \ No newline at end of file diff --git a/style/ws/printpdf.css b/style/ws/printpdf.css new file mode 100644 index 000000000..4a58c2208 --- /dev/null +++ b/style/ws/printpdf.css @@ -0,0 +1,11 @@ +*{ + padding:0; + margin:0; +} +html,body{ + height:100%; +} + +body{ + overflow: hidden; +} \ No newline at end of file